Search in sources :

Example 26 with ClaimValue

use of org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue in project identity-governance by wso2-extensions.

the class IdentityStoreEventListenerTest method testDoPreGetUserList.

@Test(dataProvider = "getuserlistHandler")
public void testDoPreGetUserList(String claimUri, String claimValue, final List<String> userList, String userStore) throws Exception {
    userStoreManager = mock(UserStoreManager.class);
    realmConfiguration = mock(RealmConfiguration.class);
    userIdentityDataStore = mock(UserIdentityDataStore.class);
    Field fieldIdentityStore = IdentityStoreEventListener.class.getDeclaredField("identityDataStore");
    fieldIdentityStore.setAccessible(true);
    fieldIdentityStore.set(identityStoreEventListener, userIdentityDataStore);
    final List<String> userIds = new ArrayList<>();
    userIds.add("PRIMARY/user1@carbon.super");
    userIds.add("PRIMARY/user2@abc.com");
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            return userIds;
        }
    }).when(userIdentityDataStore).list(claimUri, claimValue, userStoreManager);
    Mockito.when(userStoreManager.getRealmConfiguration()).thenReturn(realmConfiguration);
    Mockito.when(UserCoreUtil.getDomainName(realmConfiguration)).thenReturn(userStore);
    assertTrue(identityStoreEventListener.doPreGetUserList(claimUri, claimValue, userList, userStoreManager));
}
Also used : RealmConfiguration(org.wso2.carbon.user.api.RealmConfiguration) Field(java.lang.reflect.Field) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) UserIdentityDataStore(org.wso2.carbon.identity.governance.store.UserIdentityDataStore) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ArrayList(java.util.ArrayList) UserStoreManager(org.wso2.carbon.user.core.UserStoreManager) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 27 with ClaimValue

use of org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue in project product-is by wso2.

the class AccountLockEnabledTestCase method testSuccessfulEmailTemplateRetrieval.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.is", description = "Check whether the user account lock email " + "template successfully retrieved when admin triggered account lock.", dependsOnMethods = "testSuccessfulLockedInitially")
public void testSuccessfulEmailTemplateRetrieval() throws Exception {
    ClaimValue claimValue = new ClaimValue();
    claimValue.setClaimURI(defaultLocalityClaimUri);
    claimValue.setValue(defaultLocalityClaimValue);
    ClaimValue[] claimvalues = { claimValue };
    usmClient.addUser(testLockUser2, testLockUser2Password, new String[] { "admin" }, claimvalues, null, false);
    String userLocale = usmClient.getUserClaimValue(testLockUser2, defaultLocalityClaimUri, "default");
    String emailTemplateResourceName = accountLockTemplateWhenUserExceedsFailedAttempts + "/" + userLocale;
    String emailTemplateResourceContent = resourceAdminServiceClient.getTextContent(registryResourcePath + emailTemplateResourceName);
    Assert.assertTrue("Test Failure : Email Content applicable for account lock is not available.", StringUtils.isNotEmpty(emailTemplateResourceContent));
    String emailTemplateResourceNameAdminTriggered = accountLockTemplateWhenAdminTriggered + "/" + userLocale;
    String emailTemplateResourceContentAdminTriggered = resourceAdminServiceClient.getTextContent(registryResourcePath + emailTemplateResourceNameAdminTriggered);
    Assert.assertTrue("Test Failure : Email Content applicable for account lock is not available.", StringUtils.isNotEmpty(emailTemplateResourceContentAdminTriggered));
}
Also used : ClaimValue(org.wso2.carbon.um.ws.api.stub.ClaimValue) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 28 with ClaimValue

use of org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue in project product-is by wso2.

the class AccountLockEnabledTestCase method testSuccessfulEmailTemplateRetrievalAccountUnLock.

@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@Test(groups = "wso2.is", description = "Check whether the user account unlocklock email " + "template successfully retrieved when admin triggered account lock.")
public void testSuccessfulEmailTemplateRetrievalAccountUnLock() throws Exception {
    ClaimValue claimValue = new ClaimValue();
    claimValue.setClaimURI(defaultLocalityClaimUri);
    claimValue.setValue(defaultLocalityClaimValue);
    ClaimValue[] claimvalues = { claimValue };
    usmClient.addUser(testLockUser3, testLockUser3Password, new String[] { "admin" }, claimvalues, null, false);
    String userLocale = usmClient.getUserClaimValue(testLockUser2, defaultLocalityClaimUri, "default");
    String emailTemplateResourceName = accountUnlockTemplateTimeBased + "/" + userLocale;
    String emailTemplateResourceContent = resourceAdminServiceClient.getTextContent(registryResourcePath + emailTemplateResourceName);
    Assert.assertTrue("Test Failure : Email Content applicable for account unlock is not available.", StringUtils.isNotEmpty(emailTemplateResourceContent));
    String emailTemplateResourceNameAdminTriggered = accountUnlockTemplateAdminTriggered + "/" + userLocale;
    String emailTemplateResourceContentAdminTriggered = resourceAdminServiceClient.getTextContent(registryResourcePath + emailTemplateResourceNameAdminTriggered);
    Assert.assertTrue("Test Failure : Email Content applicable for account unlock is not available.", StringUtils.isNotEmpty(emailTemplateResourceContentAdminTriggered));
}
Also used : ClaimValue(org.wso2.carbon.um.ws.api.stub.ClaimValue) SetEnvironment(org.wso2.carbon.automation.engine.annotations.SetEnvironment) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 29 with ClaimValue

use of org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue in project product-is by wso2.

the class AccountLockWhileCaseInsensitiveUserFalseTestCase method setAccountLockClaim.

private ClaimValue[] setAccountLockClaim() {
    ClaimValue[] claimValues = new ClaimValue[1];
    ClaimValue lockedClaim = new ClaimValue();
    lockedClaim.setClaimURI(ACCOUNT_LOCK_CLAIM_URI);
    lockedClaim.setValue(Boolean.TRUE.toString());
    claimValues[0] = lockedClaim;
    return claimValues;
}
Also used : ClaimValue(org.wso2.carbon.um.ws.api.stub.ClaimValue)

Example 30 with ClaimValue

use of org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue in project product-is by wso2.

the class EmailOTPTestCase method getUserClaims.

private ClaimValue[] getUserClaims() {
    ClaimValue[] claimValues = new ClaimValue[3];
    ClaimValue firstName = new ClaimValue();
    firstName.setClaimURI(FIRST_NAME_CLAIM_URI);
    firstName.setValue(config.getUsername());
    claimValues[0] = firstName;
    ClaimValue lastName = new ClaimValue();
    lastName.setClaimURI(LAST_NAME_CLAIM_URI);
    lastName.setValue(config.getUsername());
    claimValues[1] = lastName;
    ClaimValue email = new ClaimValue();
    email.setClaimURI(EMAIL_CLAIM_URI);
    email.setValue(config.getEmailAddress());
    claimValues[2] = email;
    return claimValues;
}
Also used : ClaimValue(org.wso2.carbon.um.ws.api.stub.ClaimValue)

Aggregations

ClaimValue (org.wso2.carbon.um.ws.api.stub.ClaimValue)23 HashMap (java.util.HashMap)21 Test (org.testng.annotations.Test)19 UserStoreException (org.wso2.carbon.user.core.UserStoreException)14 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)14 Map (java.util.Map)13 ArrayList (java.util.ArrayList)11 RemoteException (java.rmi.RemoteException)9 RegistryException (org.wso2.carbon.registry.core.exceptions.RegistryException)9 UserStoreException (org.wso2.carbon.user.api.UserStoreException)9 ClaimValue (org.wso2.carbon.user.mgt.stub.types.carbon.ClaimValue)9 IdentityException (org.wso2.carbon.identity.base.IdentityException)8 WorkflowAdminServiceWorkflowException (org.wso2.carbon.identity.workflow.mgt.stub.WorkflowAdminServiceWorkflowException)8 Association (org.wso2.carbon.identity.workflow.mgt.stub.metadata.Association)8 Matchers.anyString (org.mockito.Matchers.anyString)7 FlaggedName (org.wso2.carbon.user.mgt.stub.types.carbon.FlaggedName)7 UserStoreManager (org.wso2.carbon.user.core.UserStoreManager)6 AuthenticatedUser (org.wso2.carbon.identity.application.authentication.framework.model.AuthenticatedUser)5 ClaimValue (org.wso2.carbon.user.mgt.common.ClaimValue)5 HashSet (java.util.HashSet)4