Search in sources :

Example 1 with WebAuthenticationDetails

use of org.springframework.security.ui.WebAuthenticationDetails in project gocd by gocd.

the class AnonymousProcessingFilterTest method shouldGiveAnonymousUserRoleSupervisorAuthorityWhenSecurityIsOFFInCruiseConfig.

@Test
public void shouldGiveAnonymousUserRoleSupervisorAuthorityWhenSecurityIsOFFInCruiseConfig() throws Exception {
    context.checking(new Expectations() {

        {
            allowing(goConfigService).isSecurityEnabled();
            will(returnValue(false));
        }
    });
    MockHttpServletRequest mockHttpServletRequest = new MockHttpServletRequest();
    Authentication authentication = filter.createAuthentication(mockHttpServletRequest);
    assertThat(authentication.getAuthorities().length, is(1));
    final String role = authentication.getAuthorities()[0].getAuthority();
    assertThat(role, is(GoAuthority.ROLE_SUPERVISOR.toString()));
    assertTrue(authentication.getDetails() instanceof WebAuthenticationDetails);
}
Also used : Expectations(org.jmock.Expectations) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Authentication(org.springframework.security.Authentication) WebAuthenticationDetails(org.springframework.security.ui.WebAuthenticationDetails) Test(org.junit.Test)

Aggregations

Expectations (org.jmock.Expectations)1 Test (org.junit.Test)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 Authentication (org.springframework.security.Authentication)1 WebAuthenticationDetails (org.springframework.security.ui.WebAuthenticationDetails)1