use of org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient in project product-is by wso2.
the class UserInformationRecoveryServiceTestCase method testInit.
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.ALL })
@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
super.init();
String carbonHome = Utils.getResidentCarbonHome();
identityMgtServerFile = new File(carbonHome + File.separator + "repository" + File.separator + "conf" + File.separator + "identity" + File.separator + "identity-mgt.properties");
File identityMgtConfigFile = new File(getISResourceLocation() + File.separator + "identityMgt" + File.separator + "identity-mgt-enabled.properties");
axisServerFile = new File(carbonHome + File.separator + "repository" + File.separator + "conf" + File.separator + "axis2" + File.separator + "axis2.xml");
File axisConfigFile = new File(getISResourceLocation() + File.separator + "identityMgt" + File.separator + "axis2.xml");
scm = new ServerConfigurationManager(isServer);
scm.applyConfigurationWithoutRestart(identityMgtConfigFile, identityMgtServerFile, true);
scm.applyConfigurationWithoutRestart(axisConfigFile, axisServerFile, true);
scm.restartGracefully();
super.init();
loginManger = new AuthenticatorClient(backendURL);
userMgtClient = new UserManagementClient(backendURL, sessionCookie);
infoRecoveryClient = new UserInformationRecoveryServiceClient(backendURL, sessionCookie);
profileClient = new UserProfileMgtServiceClient(backendURL, sessionCookie);
loginManger.login(isServer.getSuperTenant().getTenantAdmin().getUserName(), isServer.getSuperTenant().getTenantAdmin().getPassword(), isServer.getInstance().getHosts().get("default"));
claimMgtClient = new ClaimManagementServiceClient(backendURL, sessionCookie);
ClaimDTO claim1 = new ClaimDTO();
claim1.setDialectURI("http://wso2.org/claims");
claim1.setClaimUri("http://wso2.org/claims/identity/unlockTime");
claim1.setDescription("Account Unlock time");
ClaimDTO claim2 = new ClaimDTO();
claim2.setDialectURI("http://wso2.org/claims");
claim2.setClaimUri("http://wso2.org/claims/identity/failedLoginAttempts");
claim2.setDescription("Failed login attempts");
ClaimMappingDTO claimMapping1 = new ClaimMappingDTO();
claimMapping1.setClaim(claim1);
claimMapping1.setMappedAttribute("description");
claimMgtClient.addNewClaimMapping(claimMapping1);
ClaimMappingDTO claimMapping2 = new ClaimMappingDTO();
claimMapping2.setClaim(claim2);
claimMapping2.setMappedAttribute("employeeType");
claimMgtClient.addNewClaimMapping(claimMapping2);
userMgtClient.addUser("user11", "passWord1@", null, "default");
userMgtClient.addRole("umRole11", new String[] { "user11" }, new String[] { "/permission/admin/login" }, false);
}
use of org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient in project product-is by wso2.
the class OAuth2ServiceJWTGrantTestCase method setup.
@BeforeClass
public void setup() throws Exception {
super.init(TestUserMode.SUPER_TENANT_ADMIN);
changeISConfiguration("jwt_token_issuer_enabled.toml");
super.init(TestUserMode.SUPER_TENANT_ADMIN);
OAuthConsumerAppDTO appDto = createApplication(createApplicationWithJWTGrantType());
consumerKey = appDto.getOauthConsumerKey();
consumerSecret = appDto.getOauthConsumerSecret();
userManagementClient = new UserManagementClient(backendURL, sessionCookie);
oauthAdminClient = new OauthAdminClient(backendURL, sessionCookie);
userProfileMgtServiceClient = new UserProfileMgtServiceClient(backendURL, sessionCookie);
identityProviderMgtServiceClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL);
addNewUserWithClaims();
claimMetadataManagementServiceClient = new ClaimMetadataManagementServiceClient(backendURL, sessionCookie);
changeCountryOIDDialect();
ExternalClaimDTO externalClaimDTO = new ExternalClaimDTO();
externalClaimDTO.setExternalClaimDialectURI(OAuth2ServiceAuthCodeGrantOpenIdRequestObjectTestCase.OIDC_CLAIM_DIALECT);
externalClaimDTO.setMappedLocalClaimURI(COUNTRY_LOCAL_CLAIM_URI);
externalClaimDTO.setExternalClaimURI(COUNTRY_NEW_OIDC_CLAIM);
claimMetadataManagementServiceClient.addExternalClaim(externalClaimDTO);
String[] openidValue = new String[1];
openidValue[0] = COUNTRY_NEW_OIDC_CLAIM;
oauthAdminClient.updateScope(openIdScope, openidValue, null);
}
use of org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient in project product-is by wso2.
the class RESTTestBase method init.
/**
* Initialize the RestAssured environment and create SwaggerRequestResponseValidator with the swagger definition
*
* @param swaggerDefinition swagger definition name
* @param basePathInSwagger basepath that is defined in the swagger definition (ex: /api/users/v1)
* @param basePath basepath of the current test run (ex: /t/carbon.super/api/users/v1)
* @throws IOException
* @throws XPathExpressionException
*/
protected void init(String swaggerDefinition, String basePathInSwagger, String basePath) throws RemoteException {
this.basePath = basePath;
this.swaggerDefinition = swaggerDefinition;
RestAssured.baseURI = backendURL.replace(SERVICES, "");
String swagger = replaceInSwaggerDefinition(swaggerDefinition, basePathInSwagger, basePath);
OpenApiInteractionValidator openAPIValidator = OpenApiInteractionValidator.createForInlineApiSpecification(swagger).withLevelResolver(LevelResolverFactory.withAdditionalPropertiesIgnored()).build();
validationFilter = new OpenApiValidationFilter(openAPIValidator);
remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie);
userProfileMgtServiceClient = new UserProfileMgtServiceClient(backendURL, sessionCookie);
identityProviderMgtServiceClient = new IdentityProviderMgtServiceClient(sessionCookie, backendURL);
}
use of org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient in project product-is by wso2.
the class UserManagementServiceAbstractTest method testListUserByClaim.
@SetEnvironment(executionEnvironments = { ExecutionEnvironment.STANDALONE })
@Test(groups = "wso2.is", description = "Check list users by claim value", dependsOnMethods = "testGetRolesOfCurrentUser")
public void testListUserByClaim() throws Exception {
UserProfileMgtServiceClient userProfileMgtServiceClient = new UserProfileMgtServiceClient(backendURL, getSessionCookie());
UserProfileDTO profile = userProfileMgtServiceClient.getUserProfile(newUserName, "default");
UserFieldDTO[] fields = userProfileMgtServiceClient.getProfileFieldsForInternalStore().getFieldValues();
String profileConfigs = profile.getProfileName();
for (UserFieldDTO field : fields) {
if (field.getDisplayName().equalsIgnoreCase("Last Name")) {
field.setFieldValue(newUserName + "LastName");
continue;
}
if (field.getRequired()) {
if (field.getDisplayName().equalsIgnoreCase("Email")) {
field.setFieldValue(newUserName + "@wso2.com");
} else {
field.setFieldValue(newUserName);
}
continue;
}
if (field.getFieldValue() == null) {
field.setFieldValue("");
}
}
// creating a new profile with updated values
UserProfileDTO newProfile = new UserProfileDTO();
newProfile.setProfileName(profile.getProfileName());
newProfile.setFieldValues(fields);
newProfile.setProfileConifuration(profileConfigs);
userProfileMgtServiceClient.setUserProfile(newUserName, newProfile);
ClaimValue claimValue = new ClaimValue();
claimValue.setClaimURI("http://wso2.org/claims/lastname");
claimValue.setValue(newUserName + "LastName");
FlaggedName[] allNames = userMgtClient.listUserByClaim(claimValue, newUserName, 10);
Assert.assertTrue(nameExists(allNames, newUserName), "List user with claim value has failed");
}
use of org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient in project product-is by wso2.
the class UserProfileAdminTestCase method testUserAccountAssociationAdd.
@Test(priority = 4, groups = "wso2.is", description = "Check Fed User Account Association")
public void testUserAccountAssociationAdd() throws Exception {
super.init();
userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, sessionCookie);
userMgtClient = new UserManagementClient(backendURL, sessionCookie);
String username = "testUser2";
String password = "passWord1@";
String idpName = "idp1";
// create a user
userMgtClient.addUser(username, password, new String[] { "admin" }, "default");
Assert.assertTrue(userMgtClient.getUserList().contains(username));
idpMgtClient = new IdentityProviderMgtServiceClient(username, password, backendURL);
userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, username, password);
IdentityProvider idp = new IdentityProvider();
idp.setIdentityProviderName(idpName);
idpMgtClient.addIdP(idp);
Assert.assertNotNull(idpMgtClient.getIdPByName(idpName));
// create a federated user account association
userProfileMgtClient.addFedIdpAccountAssociation(idpName, "dummy_idp_account_1");
userProfileMgtClient.addFedIdpAccountAssociation(idpName, "dummy_idp_account_2");
AssociatedAccountDTO[] associatedFedUserAccountIds = userProfileMgtClient.getAssociatedFedUserAccountIds();
Assert.assertNotNull(associatedFedUserAccountIds);
Assert.assertEquals(associatedFedUserAccountIds.length, 2);
// delete the user, this should clear the federated idp account associations
userMgtClient.deleteUser(username);
Assert.assertEquals(userMgtClient.getUserList().contains(username), false);
// create the same user
userMgtClient.addUser(username, password, new String[] { "admin" }, "default");
userProfileMgtClient = new UserProfileMgtServiceClient(backendURL, username, password);
associatedFedUserAccountIds = userProfileMgtClient.getAssociatedFedUserAccountIds();
// assert to make sure there are no federated idp user account associations for this user
Assert.assertEquals(associatedFedUserAccountIds == null || associatedFedUserAccountIds.length == 0, true);
}
Aggregations