Search in sources :

Example 1 with ClaimFilter

use of org.wso2.carbon.identity.application.authentication.framework.handler.claims.ClaimFilter in project identity-inbound-auth-oauth by wso2-extensions.

the class OpenIDConnectClaimFilterImplTest method testGetClaimsFilteredByUserConsentWithException.

@Test
public void testGetClaimsFilteredByUserConsentWithException() throws Exception {
    claims = getClaims();
    AuthenticatedUser user = getDefaultAuthenticatedLocalUser();
    when(ssoConsentService.isSSOConsentManagementEnabled(any())).thenReturn(false);
    Mockito.doThrow(new IdentityApplicationManagementException("")).when(applicationMgtService).getServiceProviderByClientId("dummy", IdentityApplicationConstants.OAuth2.NAME, SP_TENANT_DOMAIN);
    Map<String, Object> claimFilter = openIDConnectClaimFilter.getClaimsFilteredByUserConsent(claims, user, "dummy", SP_TENANT_DOMAIN);
    Assert.assertEquals(((ScopeDTO) claimFilter.get("testUserClaimURI")).getName(), "email");
    Assert.assertEquals(((ScopeDTO) claimFilter.get("testUserClaimURI")).getDescription(), "emailDescription");
    Assert.assertEquals(((ScopeDTO) claimFilter.get("testUserClaimURI2")).getName(), "address");
    Assert.assertEquals(((ScopeDTO) claimFilter.get("testUserClaimURI2")).getDescription(), "addressDescription");
}
Also used : IdentityApplicationManagementException(org.wso2.carbon.identity.application.common.IdentityApplicationManagementException) Matchers.anyString(org.mockito.Matchers.anyString) AuthenticatedUser(org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser) Test(org.testng.annotations.Test)

Example 2 with ClaimFilter

use of org.wso2.carbon.identity.application.authentication.framework.handler.claims.ClaimFilter in project identity-inbound-auth-oauth by wso2-extensions.

the class OpenIDConnectClaimFilterImplTest method testGetClaimsFilteredByUserConsent.

@Test
public void testGetClaimsFilteredByUserConsent() throws Exception {
    claims = getClaims();
    AuthenticatedUser user = getDefaultAuthenticatedLocalUser();
    when(ssoConsentService.isSSOConsentManagementEnabled(any())).thenReturn(true);
    Map<String, Object> claimFilter = openIDConnectClaimFilter.getClaimsFilteredByUserConsent(claims, user, CLIENT_ID, SP_TENANT_DOMAIN);
    Assert.assertEquals(((ScopeDTO) claimFilter.get("testUserClaimURI")).getName(), "email");
    Assert.assertEquals(((ScopeDTO) claimFilter.get("testUserClaimURI")).getDescription(), "emailDescription");
    Assert.assertNull(claimFilter.get("testUserClaimURI2"));
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) AuthenticatedUser(org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser) Test(org.testng.annotations.Test)

Example 3 with ClaimFilter

use of org.wso2.carbon.identity.application.authentication.framework.handler.claims.ClaimFilter in project identity-inbound-auth-oauth by wso2-extensions.

the class OpenIDConnectClaimFilterImplTest method testGetClaimsFilteredByUserConsentWithManagementServiceDisabled.

@Test
public void testGetClaimsFilteredByUserConsentWithManagementServiceDisabled() throws Exception {
    claims = getClaims();
    AuthenticatedUser user = getDefaultAuthenticatedLocalUser();
    when(ssoConsentService.isSSOConsentManagementEnabled(any())).thenReturn(false);
    Map<String, Object> claimFilter = openIDConnectClaimFilter.getClaimsFilteredByUserConsent(claims, user, CLIENT_ID, SP_TENANT_DOMAIN);
    Assert.assertEquals(((ScopeDTO) claimFilter.get("testUserClaimURI")).getName(), "email");
    Assert.assertEquals(((ScopeDTO) claimFilter.get("testUserClaimURI")).getDescription(), "emailDescription");
    Assert.assertEquals(((ScopeDTO) claimFilter.get("testUserClaimURI2")).getName(), "address");
    Assert.assertEquals(((ScopeDTO) claimFilter.get("testUserClaimURI2")).getDescription(), "addressDescription");
}
Also used : Matchers.anyString(org.mockito.Matchers.anyString) AuthenticatedUser(org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser) Test(org.testng.annotations.Test)

Aggregations

Matchers.anyString (org.mockito.Matchers.anyString)3 Test (org.testng.annotations.Test)3 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)3 IdentityApplicationManagementException (org.wso2.carbon.identity.application.common.IdentityApplicationManagementException)1