Created
November 5, 2011 14:23
-
-
Save eugenp/1341570 to your computer and use it in GitHub Desktop.
part 5 - the Security test utils
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String authenticateAsAdmin(){ | |
return this.authenticate( "eparaschiv", "eparaschiv" ); | |
} | |
public String authenticate( String username, String password ){ | |
Response response = RestAssured.given(). | |
.param( UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_USERNAME_KEY, username ) | |
.param( UsernamePasswordAuthenticationFilter.SPRING_SECURITY_FORM_PASSWORD_KEY, password ) | |
.post( this.examplePaths.getLoginURL() ); | |
Preconditions.checkState( response.getStatusCode() == 302 ); | |
return JSESSIONID + "=" + response.getCookie( JSESSIONID ); | |
} | |
public RequestSpecification givenAuthenticated( String cookie ){ | |
return RestAssured.given().header( COOKIE_HEADER, cookie ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment