use of com.thoughtworks.go.server.service.PluginRoleService in project gocd by gocd.
the class AuthorizationRequestProcessorTest method shouldProcessInvalidateCacheRequest.
@Test
public void shouldProcessInvalidateCacheRequest() throws Exception {
PluginRoleService pluginRoleService = mock(PluginRoleService.class);
when(authorizationExtension.getMessageConverter(AuthorizationMessageConverterV1.VERSION)).thenReturn(new AuthorizationMessageConverterV1());
GoApiRequest request = new DefaultGoApiRequest(INVALIDATE_CACHE_REQUEST.requestName(), "1.0", null);
AuthorizationRequestProcessor authorizationRequestProcessor = new AuthorizationRequestProcessor(registry, null, authorizationExtension, pluginRoleService);
GoApiResponse response = authorizationRequestProcessor.process(pluginDescriptor, request);
assertThat(response.responseCode(), is(200));
verify(pluginRoleService).invalidateRolesFor("cd.go.authorization.github");
}
use of com.thoughtworks.go.server.service.PluginRoleService in project gocd by gocd.
the class PreAuthenticatedAuthenticationProviderTest method setUp.
@Before
public void setUp() throws Exception {
pluginId = "github.oauth";
user = new User("username", "displayname", "emailId");
authorities = new GrantedAuthority[] { GoAuthority.ROLE_USER.asAuthority() };
authorizationExtension = mock(AuthorizationExtension.class);
authorityGranter = mock(AuthorityGranter.class);
userService = mock(UserService.class);
pluginRoleService = mock(PluginRoleService.class);
goConfigService = mock(GoConfigService.class);
authenticationProvider = new PreAuthenticatedAuthenticationProvider(authorizationExtension, pluginRoleService, userService, authorityGranter, goConfigService);
AuthenticationResponse authenticationResponse = new AuthenticationResponse(user, asList("admin"));
securityConfig = new SecurityConfig();
stub(goConfigService.security()).toReturn(securityConfig);
stub(authorizationExtension.authenticateUser(any(String.class), any(Map.class), any(List.class), any(List.class))).toReturn(authenticationResponse);
stub(authorityGranter.authorities(anyString())).toReturn(authorities);
securityConfig.securityAuthConfigs().add(new SecurityAuthConfig("github", pluginId));
}
Aggregations