Search in sources :

Example 1 with ChallengeQuestionMgtAdminClient

use of org.wso2.identity.integration.common.clients.challenge.questions.mgt.ChallengeQuestionMgtAdminClient in project product-is by wso2.

the class ChallengeQuestionManagementAdminServiceTestCase method checkSaaSAccess.

@Test(groups = "wso2.is", description = "Testing cross tenant access.")
public void checkSaaSAccess() throws Exception {
    challengeQuestionsAdminClient = new ChallengeQuestionMgtAdminClient(backendURL, BOB_USERNAME, BOB_PASSWORD);
    try {
        challengeQuestionsAdminClient.getChallengeQuestionsForTenant(WSO2_TENANT);
        fail(SUPER_TENANT + " user was able to access challenge questions in " + WSO2_TENANT);
    } catch (Exception ex) {
        assertTrue(ex.getMessage().contains("Unauthorized Access"));
    }
}
Also used : ChallengeQuestionMgtAdminClient(org.wso2.identity.integration.common.clients.challenge.questions.mgt.ChallengeQuestionMgtAdminClient) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 2 with ChallengeQuestionMgtAdminClient

use of org.wso2.identity.integration.common.clients.challenge.questions.mgt.ChallengeQuestionMgtAdminClient in project product-is by wso2.

the class ChallengeQuestionManagementAdminServiceTestCase method getDefaultChallengeQuestionsForUser.

@Test(groups = "wso2.is", description = "Get default questions if the locale doesn't have any questions set.", priority = 7, sequential = true)
public void getDefaultChallengeQuestionsForUser() throws Exception {
    challengeQuestionsAdminClient = new ChallengeQuestionMgtAdminClient(backendURL, BOB_USERNAME, BOB_PASSWORD);
    User bob = new User();
    bob.setUserName(BOB_USERNAME);
    bob.setTenantDomain(SUPER_TENANT);
    // we need to confirm there are no challenge questions in Bob's locale
    ChallengeQuestion[] localeQuestions = challengeQuestionsAdminClient.getChallengeQuestionsForLocale(SUPER_TENANT, BOB_LOCALE);
    int bobLocale = localeQuestions == null ? 0 : localeQuestions.length;
    assertTrue(bobLocale == 0, "Cannot have challenge questions in " + BOB_LOCALE);
    // this should return us with default questions since Bob's locale doesn't have any challenge questions.
    int count = challengeQuestionsAdminClient.getChallengeQuestionsForUser(bob).length;
    assertTrue(count > 1, "Default Challenge Questions not retrieved for user : " + bob.toString());
}
Also used : User(org.wso2.carbon.identity.application.common.model.xsd.User) ChallengeQuestionMgtAdminClient(org.wso2.identity.integration.common.clients.challenge.questions.mgt.ChallengeQuestionMgtAdminClient) ChallengeQuestion(org.wso2.carbon.identity.recovery.stub.model.ChallengeQuestion) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 3 with ChallengeQuestionMgtAdminClient

use of org.wso2.identity.integration.common.clients.challenge.questions.mgt.ChallengeQuestionMgtAdminClient in project product-is by wso2.

the class ChallengeQuestionManagementAdminServiceTestCase method getChallengeQuestionByUser.

@Test(groups = "wso2.is", description = "Getting challenge questions of a user", priority = 5, sequential = true)
public void getChallengeQuestionByUser() throws Exception {
    challengeQuestionsAdminClient = new ChallengeQuestionMgtAdminClient(backendURL, BOB_USERNAME, BOB_PASSWORD);
    User bob = new User();
    bob.setUserName(BOB_USERNAME);
    bob.setTenantDomain(SUPER_TENANT);
    int count = challengeQuestionsAdminClient.getChallengeQuestionsForUser(bob).length;
    assertTrue(count == 1, "Challenge Questions not retrieved successfully for user : " + bob.toString());
}
Also used : User(org.wso2.carbon.identity.application.common.model.xsd.User) ChallengeQuestionMgtAdminClient(org.wso2.identity.integration.common.clients.challenge.questions.mgt.ChallengeQuestionMgtAdminClient) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Example 4 with ChallengeQuestionMgtAdminClient

use of org.wso2.identity.integration.common.clients.challenge.questions.mgt.ChallengeQuestionMgtAdminClient in project product-is by wso2.

the class ChallengeQuestionManagementAdminServiceTestCase method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    loginManger = new AuthenticatorClient(backendURL);
    // login as super tenant admin
    loginManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), isServer.getSuperTenant().getTenantAdmin().getPassword(), isServer.getInstance().getHosts().get("default"));
    userMgtClient = new UserManagementClient(backendURL, sessionCookie);
    remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie);
    challengeQuestionsAdminClient = new ChallengeQuestionMgtAdminClient(backendURL, sessionCookie);
    challengeQuestionsBobClient = new ChallengeQuestionMgtAdminClient(backendURL, BOB_USERNAME, BOB_PASSWORD);
    createUsersAndRoles();
    setSystemproperties();
}
Also used : AuthenticatorClient(org.wso2.carbon.integration.common.admin.client.AuthenticatorClient) UserManagementClient(org.wso2.identity.integration.common.clients.UserManagementClient) RemoteUserStoreManagerServiceClient(org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient) ChallengeQuestionMgtAdminClient(org.wso2.identity.integration.common.clients.challenge.questions.mgt.ChallengeQuestionMgtAdminClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with ChallengeQuestionMgtAdminClient

use of org.wso2.identity.integration.common.clients.challenge.questions.mgt.ChallengeQuestionMgtAdminClient in project product-is by wso2.

the class ChallengeQuestionManagementAdminServiceTestCase method deleteChallengeQuestionsByLocale.

@Test(groups = "wso2.is", description = "Deleting challenge question in a locale", priority = 6, sequential = true)
public void deleteChallengeQuestionsByLocale() throws Exception {
    challengeQuestionsAdminClient = new ChallengeQuestionMgtAdminClient(backendURL, isServer.getSuperTenant().getTenantAdmin().getUserName(), isServer.getSuperTenant().getTenantAdmin().getUserName());
    // get challenge challenge questions of xx_YY locale
    ChallengeQuestion[] challengeQuestions = challengeQuestionsAdminClient.getChallengeQuestionsForLocale(SUPER_TENANT, BOB_LOCALE);
    // we should have challenge questions in the locale by now.
    assertTrue(challengeQuestions != null && challengeQuestions.length > 0);
    // delete all the challenge questions in the xx_YY locale
    challengeQuestionsAdminClient.deleteChallengeQuestions(challengeQuestions, SUPER_TENANT);
    // delete all added challenge questions in the en_US locale
    challengeQuestionsAdminClient.deleteChallengeQuestions(new ChallengeQuestion[] { challengeQuestionSet1 }, SUPER_TENANT);
    // retrieve challenge questions once again.
    challengeQuestions = challengeQuestionsAdminClient.getChallengeQuestionsForLocale(SUPER_TENANT, BOB_LOCALE);
    int numberOfQuestions = challengeQuestions == null ? 0 : challengeQuestions.length;
    // now we shouldn't have challenge questions.
    assertTrue(numberOfQuestions == 0);
}
Also used : ChallengeQuestionMgtAdminClient(org.wso2.identity.integration.common.clients.challenge.questions.mgt.ChallengeQuestionMgtAdminClient) ChallengeQuestion(org.wso2.carbon.identity.recovery.stub.model.ChallengeQuestion) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest) Test(org.testng.annotations.Test)

Aggregations

ChallengeQuestionMgtAdminClient (org.wso2.identity.integration.common.clients.challenge.questions.mgt.ChallengeQuestionMgtAdminClient)6 Test (org.testng.annotations.Test)5 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)5 ChallengeQuestion (org.wso2.carbon.identity.recovery.stub.model.ChallengeQuestion)3 User (org.wso2.carbon.identity.application.common.model.xsd.User)2 BeforeClass (org.testng.annotations.BeforeClass)1 AuthenticatorClient (org.wso2.carbon.integration.common.admin.client.AuthenticatorClient)1 UserManagementClient (org.wso2.identity.integration.common.clients.UserManagementClient)1 RemoteUserStoreManagerServiceClient (org.wso2.identity.integration.common.clients.usermgt.remote.RemoteUserStoreManagerServiceClient)1