Search in sources :

Example 1 with ClaimMetadataManagementServiceClient

use of org.wso2.identity.scenarios.commons.clients.claims.ClaimMetadataManagementServiceClient 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);
}
Also used : OauthAdminClient(org.wso2.identity.integration.common.clients.oauth.OauthAdminClient) UserProfileMgtServiceClient(org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient) ExternalClaimDTO(org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ExternalClaimDTO) ClaimMetadataManagementServiceClient(org.wso2.identity.integration.common.clients.claim.metadata.mgt.ClaimMetadataManagementServiceClient) OAuthConsumerAppDTO(org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO) UserManagementClient(org.wso2.carbon.integration.common.admin.client.UserManagementClient) IdentityProviderMgtServiceClient(org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with ClaimMetadataManagementServiceClient

use of org.wso2.identity.scenarios.commons.clients.claims.ClaimMetadataManagementServiceClient in project product-is by wso2.

the class OAuth2ServiceJWTGrantTestCase method changeCountryOIDDialect.

/**
 * Change the OIDC dialect claim for local claim country.
 *
 * @throws RemoteException                                      Remote Exception.
 * @throws ClaimMetadataManagementServiceClaimMetadataException Claim
 *                                                              MetadataManagementServiceClaimMetadataException
 */
private void changeCountryOIDDialect() throws RemoteException, ClaimMetadataManagementServiceClaimMetadataException {
    ClaimMetadataManagementServiceClient claimMetadataManagementServiceClient = new ClaimMetadataManagementServiceClient(backendURL, sessionCookie);
    claimMetadataManagementServiceClient.removeExternalClaim(OAuth2ServiceAuthCodeGrantOpenIdRequestObjectTestCase.OIDC_CLAIM_DIALECT, COUNTRY_OIDC_CLAIM);
}
Also used : ClaimMetadataManagementServiceClient(org.wso2.identity.integration.common.clients.claim.metadata.mgt.ClaimMetadataManagementServiceClient)

Example 3 with ClaimMetadataManagementServiceClient

use of org.wso2.identity.scenarios.commons.clients.claims.ClaimMetadataManagementServiceClient in project product-is by wso2.

the class SCIM2UserTestCase method testUpdateUserWhenExternalClaimDeleted.

@Test(dependsOnMethods = "testGetUser")
public void testUpdateUserWhenExternalClaimDeleted() throws Exception {
    AutomationContext context = new AutomationContext("IDENTITY", testUserMode);
    backendURL = context.getContextUrls().getBackEndUrl();
    loginLogoutClient = new LoginLogoutClient(context);
    sessionCookie = loginLogoutClient.login();
    HttpPost postRequest = new HttpPost(getPath());
    postRequest.addHeader(HttpHeaders.AUTHORIZATION, getAuthzHeader());
    postRequest.addHeader(HttpHeaders.CONTENT_TYPE, "application/json");
    JSONObject rootObject = new JSONObject();
    JSONArray schemas = new JSONArray();
    rootObject.put(SCHEMAS_ATTRIBUTE, schemas);
    JSONObject names = new JSONObject();
    names.put(FAMILY_NAME_ATTRIBUTE, "udaranga");
    names.put(GIVEN_NAME_ATTRIBUTE, "buddhima");
    rootObject.put(NAME_ATTRIBUTE, names);
    rootObject.put(USER_NAME_ATTRIBUTE, "wso2is");
    JSONObject emailWork = new JSONObject();
    emailWork.put(TYPE_PARAM, EMAIL_TYPE_WORK_ATTRIBUTE);
    emailWork.put(VALUE_PARAM, EMAIL_TYPE_WORK_CLAIM_VALUE);
    JSONObject emailHome = new JSONObject();
    emailHome.put(TYPE_PARAM, EMAIL_TYPE_HOME_ATTRIBUTE);
    emailHome.put(VALUE_PARAM, EMAIL_TYPE_HOME_CLAIM_VALUE);
    JSONArray emails = new JSONArray();
    emails.add(emailWork);
    emails.add(emailHome);
    rootObject.put(EMAILS_ATTRIBUTE, emails);
    rootObject.put(PASSWORD_ATTRIBUTE, PASSWORD);
    StringEntity entity = new StringEntity(rootObject.toString());
    postRequest.setEntity(entity);
    HttpResponse postResponse = client.execute(postRequest);
    assertEquals(postResponse.getStatusLine().getStatusCode(), 201, "User has not been created in patch process successfully.");
    Object responseObj = JSONValue.parse(EntityUtils.toString(postResponse.getEntity()));
    EntityUtils.consume(postResponse.getEntity());
    String userId = ((JSONObject) responseObj).get(ID_ATTRIBUTE).toString();
    assertNotNull(userId);
    String userResourcePath = getPath() + "/" + userId;
    claimMetadataManagementServiceClient = new ClaimMetadataManagementServiceClient(backendURL, sessionCookie);
    claimMetadataManagementServiceClient.removeExternalClaim("urn:ietf:params:scim:schemas:core:2.0:User", "urn:ietf:params:scim:schemas:core:2.0:User:name.honorificSuffix");
    HttpPatch request = new HttpPatch(userResourcePath);
    StringEntity params = new StringEntity("{\"schemas\":[\"urn:ietf:params:scim:api:messages:2.0:PatchOp\"]," + "\"Operations\":[{\"op\":\"replace\",\"path\":\"name\",\"value\":{\"givenName\":\"mahela\"," + "\"familyName\":\"jayaxxxx\"}}]}");
    request.setEntity(params);
    request.addHeader(HttpHeaders.AUTHORIZATION, getAuthzHeader());
    request.addHeader(HttpHeaders.CONTENT_TYPE, "application/json");
    HttpResponse response = client.execute(request);
    assertEquals(response.getStatusLine().getStatusCode(), 200, "User has not been updated successfully.");
    Object responseObjAfterPatch = JSONValue.parse(EntityUtils.toString(response.getEntity()));
    EntityUtils.consume(response.getEntity());
    String updatedGivenName = ((JSONObject) responseObjAfterPatch).get(NAME_ATTRIBUTE).toString();
    assertTrue(updatedGivenName.contains("mahela"));
}
Also used : AutomationContext(org.wso2.carbon.automation.engine.context.AutomationContext) HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) LoginLogoutClient(org.wso2.carbon.integration.common.utils.LoginLogoutClient) ClaimMetadataManagementServiceClient(org.wso2.identity.integration.common.clients.claim.metadata.mgt.ClaimMetadataManagementServiceClient) JSONObject(org.json.simple.JSONObject) JSONArray(org.json.simple.JSONArray) HttpResponse(org.apache.http.HttpResponse) JSONObject(org.json.simple.JSONObject) HttpPatch(org.apache.http.client.methods.HttpPatch) Test(org.testng.annotations.Test) ISIntegrationTest(org.wso2.identity.integration.common.utils.ISIntegrationTest)

Example 4 with ClaimMetadataManagementServiceClient

use of org.wso2.identity.scenarios.commons.clients.claims.ClaimMetadataManagementServiceClient in project product-is by wso2.

the class SCIM2CustomSchemaMeTestCase method createClaims.

@Test(description = "Creates custom schema dialect, simple attribute and complex attributes.")
private void createClaims() throws Exception {
    AutomationContext context = new AutomationContext("IDENTITY", mode);
    backendURL = context.getContextUrls().getBackEndUrl();
    loginLogoutClient = new LoginLogoutClient(context);
    cookie = loginLogoutClient.login();
    claimMetadataManagementServiceClient = new ClaimMetadataManagementServiceClient(backendURL, cookie);
    int claimDialect = claimMetadataManagementServiceClient.getClaimDialects().length;
    // Set custom schema dialect.
    ClaimDialectDTO claimDialectDTO = new ClaimDialectDTO();
    claimDialectDTO.setClaimDialectURI(CUSTOM_SCHEMA_URI);
    claimMetadataManagementServiceClient.addClaimDialect(claimDialectDTO);
    // Set claims
    setSimpleAttribute();
    setComplexAttribute();
    assertEquals(claimMetadataManagementServiceClient.getClaimDialects().length, claimDialect + 1);
}
Also used : AutomationContext(org.wso2.carbon.automation.engine.context.AutomationContext) LoginLogoutClient(org.wso2.carbon.integration.common.utils.LoginLogoutClient) ClaimMetadataManagementServiceClient(org.wso2.identity.integration.common.clients.claim.metadata.mgt.ClaimMetadataManagementServiceClient) ClaimDialectDTO(org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimDialectDTO) Test(org.testng.annotations.Test) SCIM2BaseTest(org.wso2.identity.integration.test.scim2.rest.api.SCIM2BaseTest)

Example 5 with ClaimMetadataManagementServiceClient

use of org.wso2.identity.scenarios.commons.clients.claims.ClaimMetadataManagementServiceClient in project product-is by wso2.

the class ApplicationManagementTestCase method testInit.

@BeforeClass(alwaysRun = true)
public void testInit() throws Exception {
    super.init();
    loginAndObtainSessionCookie();
    applicationManagementServiceClient = new ApplicationManagementServiceClient(sessionCookie, backendServiceURL, configContext);
    userMgtClient = new UserManagementClient(backendServiceURL, sessionCookie);
    userMgtClient.addRole(IDP_ROLE_1, new String[0], new String[] { PERMISSION_ADMIN_LOGIN });
    identityProviderMgtServiceClient = new IdentityProviderMgtServiceClient(sessionCookie, backendServiceURL);
    claimMetadataManagementServiceClient = new ClaimMetadataManagementServiceClient(backendServiceURL, sessionCookie);
    populateData();
}
Also used : ClaimMetadataManagementServiceClient(org.wso2.identity.scenarios.commons.clients.claims.ClaimMetadataManagementServiceClient) ApplicationManagementServiceClient(org.wso2.identity.scenarios.commons.clients.application.mgt.ApplicationManagementServiceClient) UserManagementClient(org.wso2.identity.scenarios.commons.clients.UserManagementClient) IdentityProviderMgtServiceClient(org.wso2.identity.scenarios.commons.clients.Idp.IdentityProviderMgtServiceClient) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

ClaimMetadataManagementServiceClient (org.wso2.identity.integration.common.clients.claim.metadata.mgt.ClaimMetadataManagementServiceClient)8 BeforeClass (org.testng.annotations.BeforeClass)5 Test (org.testng.annotations.Test)3 AutomationContext (org.wso2.carbon.automation.engine.context.AutomationContext)3 LoginLogoutClient (org.wso2.carbon.integration.common.utils.LoginLogoutClient)3 ClaimDialectDTO (org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ClaimDialectDTO)2 SCIM2BaseTest (org.wso2.identity.integration.test.scim2.rest.api.SCIM2BaseTest)2 HttpResponse (org.apache.http.HttpResponse)1 HttpPatch (org.apache.http.client.methods.HttpPatch)1 HttpPost (org.apache.http.client.methods.HttpPost)1 StringEntity (org.apache.http.entity.StringEntity)1 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)1 JSONArray (org.json.simple.JSONArray)1 JSONObject (org.json.simple.JSONObject)1 ExternalClaimDTO (org.wso2.carbon.identity.claim.metadata.mgt.stub.dto.ExternalClaimDTO)1 OAuthConsumerAppDTO (org.wso2.carbon.identity.oauth.stub.dto.OAuthConsumerAppDTO)1 AuthenticatorClient (org.wso2.carbon.integration.common.admin.client.AuthenticatorClient)1 UserManagementClient (org.wso2.carbon.integration.common.admin.client.UserManagementClient)1 IdentityProviderMgtServiceClient (org.wso2.identity.integration.common.clients.Idp.IdentityProviderMgtServiceClient)1 UserProfileMgtServiceClient (org.wso2.identity.integration.common.clients.UserProfileMgtServiceClient)1