Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
part 5 - the Security test utils
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
Something went wrong with that request. Please try again.