use of com.agiletec.aps.system.services.authorization.AuthorizationManager in project entando-core by entando.
the class AbstractControllerTest method mockOAuthInterceptor.
protected String mockOAuthInterceptor(UserDetails user) throws Exception, ApsSystemException {
String accessToken = OAuth2TestUtils.getValidAccessToken();
when(apiOAuth2TokenManager.getApiOAuth2Token(Mockito.anyString())).thenReturn(OAuth2TestUtils.getOAuth2Token(user.getUsername(), accessToken));
when(authenticationProviderManager.getUser(user.getUsername())).thenReturn(user);
when(authorizationManager.isAuthOnPermission(any(UserDetails.class), anyString())).then(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
UserDetails user = (UserDetails) invocation.getArguments()[0];
String permissionName = (String) invocation.getArguments()[1];
return new AuthorizationManager().isAuthOnPermission(user, permissionName);
}
});
return accessToken;
}
use of com.agiletec.aps.system.services.authorization.AuthorizationManager in project entando-core by entando.
the class AbstractControllerIntegrationTest method mockOAuthInterceptor.
protected String mockOAuthInterceptor(UserDetails user) throws Exception, ApsSystemException {
String accessToken = OAuth2TestUtils.getValidAccessToken();
when(apiOAuth2TokenManager.getApiOAuth2Token(Mockito.anyString())).thenReturn(OAuth2TestUtils.getOAuth2Token(user.getUsername(), accessToken));
when(authenticationProviderManager.getUser(user.getUsername())).thenReturn(user);
when(authorizationManager.isAuthOnPermission(any(UserDetails.class), anyString())).then(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
UserDetails user = (UserDetails) invocation.getArguments()[0];
String permissionName = (String) invocation.getArguments()[1];
return new AuthorizationManager().isAuthOnPermission(user, permissionName);
}
});
return accessToken;
}
Aggregations