use of org.wso2.carbon.identity.oauth.listener.IdentityOathEventListener in project identity-inbound-auth-oauth by wso2-extensions.
the class IdentityOathEventListenerTest method testDoPostSetUserClaimValues.
@Test
public void testDoPostSetUserClaimValues() throws Exception {
IdentityEventListenerConfig listenerConfig = mock(IdentityEventListenerConfig.class);
IdentityCacheConfig identityCacheConfig = mock(IdentityCacheConfig.class);
ClaimCache claimCache = mock(ClaimCache.class);
when(IdentityUtil.readEventListenerProperty(anyString(), anyString())).thenReturn(listenerConfig);
when(StringUtils.isNotBlank(anyString())).thenReturn(true);
assertTrue(identityOathEventListener.doPostSetUserClaimValues(username, mockedMapClaims, profileName, userStoreManager));
when(IdentityUtil.readEventListenerProperty(anyString(), anyString())).thenReturn(null);
when(UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration())).thenReturn("DOMAIN_NAME");
when(IdentityUtil.getIdentityCacheConfig(anyString(), anyString())).thenReturn(identityCacheConfig);
when(claimCache.isEnabled()).thenReturn(false);
IdentityOathEventListener listener = new IdentityOathEventListener();
assertTrue(listener.doPostSetUserClaimValues(username, mockedMapClaims, profileName, userStoreManager));
}
use of org.wso2.carbon.identity.oauth.listener.IdentityOathEventListener in project identity-inbound-auth-oauth by wso2-extensions.
the class IdentityOathEventListenerTest method testDoPostUpdateCredential.
@Test
public void testDoPostUpdateCredential() throws Exception {
IdentityEventListenerConfig listenerConfig = mock(IdentityEventListenerConfig.class);
IdentityCacheConfig identityCacheConfig = mock(IdentityCacheConfig.class);
ClaimCache claimCache = mock(ClaimCache.class);
OAuthServerConfiguration mockedServerConfig = mock(OAuthServerConfiguration.class);
when(IdentityUtil.readEventListenerProperty(anyString(), anyString())).thenReturn(listenerConfig);
when(StringUtils.isNotBlank(anyString())).thenReturn(true);
IdentityOathEventListener ioeListener = new IdentityOathEventListener();
assertTrue(ioeListener.doPostUpdateCredential(username, new Object(), userStoreManager));
when(IdentityUtil.readEventListenerProperty(anyString(), anyString())).thenReturn(null);
when(UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration())).thenReturn("DOMAIN_NAME");
when(IdentityUtil.getIdentityCacheConfig(anyString(), anyString())).thenReturn(identityCacheConfig);
when(claimCache.isEnabled()).thenReturn(false);
when(OAuthServerConfiguration.getInstance()).thenReturn(mockedServerConfig);
IdentityOathEventListener listener = new IdentityOathEventListener();
assertTrue(listener.doPostUpdateCredential(username, new Object(), userStoreManager));
}
use of org.wso2.carbon.identity.oauth.listener.IdentityOathEventListener in project identity-inbound-auth-oauth by wso2-extensions.
the class IdentityOathEventListenerTest method testForExceptionInTokenRevocationPath4.
@Test
public void testForExceptionInTokenRevocationPath4() throws Exception {
IdentityCacheConfig identityCacheConfig = mock(IdentityCacheConfig.class);
when(IdentityUtil.readEventListenerProperty(anyString(), anyString())).thenReturn(null);
when(UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration())).thenReturn("DOMAIN_NAME");
when(IdentityUtil.getIdentityCacheConfig(anyString(), anyString())).thenReturn(identityCacheConfig);
Set<String> clientIds = new HashSet<String>();
clientIds.add("CLIENT_ID_ONE");
AccessTokenDO accessTokenDO = new AccessTokenDO();
accessTokenDO.setConsumerKey("CONSUMER_KEY");
accessTokenDO.setAuthzUser(authenticatedUser);
accessTokenDO.setScope(new String[] { "OPEN_ID", "PROFILE" });
accessTokenDO.setAccessToken("ACCESS_TOKEN ");
when(IdentityUtil.isUserStoreInUsernameCaseSensitive(anyString())).thenReturn(true);
IdentityOathEventListener listener = new IdentityOathEventListener();
assertTrue(listener.doPostUpdateCredentialByAdmin(username, new Object(), userStoreManager));
}
use of org.wso2.carbon.identity.oauth.listener.IdentityOathEventListener in project identity-inbound-auth-oauth by wso2-extensions.
the class IdentityOathEventListenerTest method testDoPreDeleteUser.
@Test
public void testDoPreDeleteUser() throws Exception {
IdentityEventListenerConfig listenerConfig = mock(IdentityEventListenerConfig.class);
IdentityCacheConfig identityCacheConfig = mock(IdentityCacheConfig.class);
ClaimCache claimCache = mock(ClaimCache.class);
OAuthServerConfiguration mockedServerConfig = mock(OAuthServerConfiguration.class);
when(IdentityUtil.readEventListenerProperty(anyString(), anyString())).thenReturn(listenerConfig);
when(StringUtils.isNotBlank(anyString())).thenReturn(true);
IdentityOathEventListener listener = new IdentityOathEventListener();
assertTrue(listener.doPreDeleteUser(username, userStoreManager));
when(IdentityUtil.readEventListenerProperty(anyString(), anyString())).thenReturn(null);
when(UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration())).thenReturn("DOMAIN_NAME");
when(IdentityUtil.getIdentityCacheConfig(anyString(), anyString())).thenReturn(identityCacheConfig);
when(claimCache.isEnabled()).thenReturn(false);
when(ClaimMetaDataCache.getInstance()).thenReturn(claimMetaDataCache);
when(OAuthServerConfiguration.getInstance()).thenReturn(mockedServerConfig);
IdentityOathEventListener listener2 = new IdentityOathEventListener();
assertTrue(listener2.doPreDeleteUser(username, userStoreManager));
}
use of org.wso2.carbon.identity.oauth.listener.IdentityOathEventListener in project identity-inbound-auth-oauth by wso2-extensions.
the class IdentityOathEventListenerTest method testDoPreSetUserClaimValueWithAuthorizationCode.
@Test
public void testDoPreSetUserClaimValueWithAuthorizationCode() throws Exception {
Set<String> accessToken = new HashSet<>();
accessToken.add("kljdslfjljdsfjldsflkdsjkfjdsjlkj");
Set<String> authorizationCodes = new HashSet<String>();
authorizationCodes.add("AUTHORIZATION_CODE");
AuthorizationGrantCache authorizationGrantCache = mock(AuthorizationGrantCache.class);
when(UserCoreUtil.getDomainName(userStoreManager.getRealmConfiguration())).thenReturn("DOMAIN_NAME");
when(IdentityTenantUtil.getTenantDomain(anyInt())).thenReturn("TENANT_DOMAIN_NAME");
whenNew(AuthenticatedUser.class).withNoArguments().thenReturn(authenticatedUser);
when(AuthorizationGrantCache.getInstance()).thenReturn(authorizationGrantCache);
IdentityOathEventListener identityOathEventListener = new IdentityOathEventListener();
assertTrue(identityOathEventListener.doPreSetUserClaimValue(username, claimUri, claimValue, profileName, userStoreManager));
}
Aggregations