use of org.wso2.carbon.automation.engine.context.TestUserMode in project product-iots by wso2.
the class TestBase method init.
protected void init(TestUserMode userMode) throws Exception {
automationContext = new AutomationContext(Constants.AUTOMATION_CONTEXT, userMode);
String tenantDomain = automationContext.getContextTenant().getDomain();
backendHTTPSURL = automationContext.getContextUrls().getWebAppURLHttps().replace("9443", String.valueOf(Constants.HTTPS_GATEWAY_PORT)).replace("/t/" + tenantDomain, "");
backendHTTPURL = automationContext.getContextUrls().getWebAppURL().replace("9763", String.valueOf(Constants.HTTP_GATEWAY_PORT)).replace("/t/" + tenantDomain, "");
User currentUser = getAutomationContext().getContextTenant().getContextUser();
byte[] bytesEncoded = Base64.encodeBase64((currentUser.getUserName() + ":" + currentUser.getPassword()).getBytes());
String encoded = new String(bytesEncoded);
accessToken = OAuthUtil.getOAuthTokenPair(encoded, backendHTTPSURL, backendHTTPSURL, currentUser.getUserName(), currentUser.getPassword());
accessTokenString = "Bearer " + accessToken;
}
use of org.wso2.carbon.automation.engine.context.TestUserMode in project product-iots by wso2.
the class TestBase method initPublisher.
protected void initPublisher(String productGroupName, String instanceName, TestUserMode userMode) throws XPathExpressionException {
automationContext = new AutomationContext(productGroupName, instanceName, userMode);
backendHTTPSURL = automationContext.getContextUrls().getBackEndUrl();
}
use of org.wso2.carbon.automation.engine.context.TestUserMode in project product-is by wso2.
the class OAuth2ServiceAbstractIntegrationTest method init.
/**
* Initialize
*
* @param userMode
* - User Id
* @throws Exception
*/
protected void init(TestUserMode userMode) throws Exception {
super.init(userMode);
appMgtclient = new ApplicationManagementServiceClient(sessionCookie, backendURL, null);
adminClient = new OauthAdminClient(backendURL, sessionCookie);
remoteUSMServiceClient = new RemoteUserStoreManagerServiceClient(backendURL, sessionCookie);
}
use of org.wso2.carbon.automation.engine.context.TestUserMode 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"));
}
use of org.wso2.carbon.automation.engine.context.TestUserMode in project product-is by wso2.
the class ISIntegrationTest method initPublisher.
protected void initPublisher(String productGroupName, String instanceName, TestUserMode userMode, String userKey) throws XPathExpressionException {
isServer = new AutomationContext(productGroupName, instanceName, userMode);
backendURL = isServer.getContextUrls().getBackEndUrl();
}
Aggregations