From a43f09ff4d156c608e973cfd1f0e317b19931910 Mon Sep 17 00:00:00 2001 From: Maduranga Siriwardena Date: Fri, 23 Feb 2024 07:48:07 +0530 Subject: [PATCH] Revert "Modify tests temporarily" --- .../selfRegister/SelfRegisterTestCase.java | 9 +-- .../test/scim2/SCIM2UserTestCase.java | 56 +++++++++---------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/selfRegister/SelfRegisterTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/selfRegister/SelfRegisterTestCase.java index 0052c1fe698..823787d43e3 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/selfRegister/SelfRegisterTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/rest/api/user/selfRegister/SelfRegisterTestCase.java @@ -69,8 +69,7 @@ public void testSelfRegisterBeforeEnable() throws Exception { Assert.assertEquals(responseOfPost.statusCode(), HttpStatus.SC_BAD_REQUEST, "Self register user not enabled"); } - @Test(alwaysRun = true, dependsOnMethods = "testSelfRegisterBeforeEnable", groups = "wso2.is", - description = "Create self registered user with invalid password") + @Test(alwaysRun = true, groups = "wso2.is", description = "Create self registered user with invalid password") public void testSelfRegisterWithInvalidPassword() throws Exception { updateResidentIDPProperty(ENABLE_SELF_SIGN_UP, "true", true); @@ -81,8 +80,7 @@ public void testSelfRegisterWithInvalidPassword() throws Exception { "Self register user password invalid"); } - @Test(alwaysRun = true, dependsOnMethods = "testSelfRegisterWithInvalidPassword", groups = "wso2.is", - description = "Create self registered user") + @Test(alwaysRun = true, groups = "wso2.is", description = "Create self registered user") public void testSelfRegister() throws Exception { updateResidentIDPProperty(ENABLE_SELF_SIGN_UP, "true", true); @@ -103,8 +101,7 @@ public void testSelfRegisterWithExistingUsername() throws Exception { Assert.assertEquals(responseOfPost.statusCode(), HttpStatus.SC_CONFLICT, "Self register user already exists"); } - @Test(alwaysRun = true, dependsOnMethods = "testSelfRegisterWithExistingUsername", groups = "wso2.is", - description = "Create self registered user with invalid username") + @Test(alwaysRun = true, groups = "wso2.is", description = "Create self registered user with invalid username") public void testSelfRegisterWithInvalidUsername() throws Exception { updateResidentIDPProperty(ENABLE_SELF_SIGN_UP, "true", true); diff --git a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/scim2/SCIM2UserTestCase.java b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/scim2/SCIM2UserTestCase.java index ca3953dbf8c..df7f584a172 100644 --- a/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/scim2/SCIM2UserTestCase.java +++ b/modules/integration/tests-integration/tests-backend/src/test/java/org/wso2/identity/integration/test/scim2/SCIM2UserTestCase.java @@ -243,34 +243,34 @@ public void testCreateUserWithCharsetEncodingHeader() throws Exception { @Test public void testAddUserFailure() throws Exception { -// HttpPost request = new HttpPost(getPath()); -// request.addHeader(HttpHeaders.AUTHORIZATION, getAuthzHeader()); -// request.addHeader(HttpHeaders.CONTENT_TYPE, "application/json"); -// -// JSONObject rootObject = new JSONObject(); -// -// JSONArray schemas = new JSONArray(); -// rootObject.put(SCHEMAS_ATTRIBUTE, schemas); -// -// JSONObject names = new JSONObject(); -// rootObject.put(NAME_ATTRIBUTE, names); -// rootObject.put(USER_NAME_ATTRIBUTE, "passwordIncompatibleUser"); -// rootObject.put(PASSWORD_ATTRIBUTE, "a"); -// -// StringEntity entity = new StringEntity(rootObject.toString()); -// request.setEntity(entity); -// -// HttpResponse response = client.execute(request); -// -// Object responseObj = JSONValue.parse(EntityUtils.toString(response.getEntity())); -// EntityUtils.consume(response.getEntity()); -// -// LOG.info("Response of testAddUserFailure method:" + responseObj.toString()); -// -// JSONArray schemasArray = (JSONArray)((JSONObject) responseObj).get("schemas"); -// Assert.assertNotNull(schemasArray); -// Assert.assertEquals(schemasArray.size(), 1); -// Assert.assertEquals(schemasArray.get(0).toString(), ERROR_SCHEMA); + HttpPost request = new HttpPost(getPath()); + request.addHeader(HttpHeaders.AUTHORIZATION, getAuthzHeader()); + request.addHeader(HttpHeaders.CONTENT_TYPE, "application/json"); + + JSONObject rootObject = new JSONObject(); + + JSONArray schemas = new JSONArray(); + rootObject.put(SCHEMAS_ATTRIBUTE, schemas); + + JSONObject names = new JSONObject(); + rootObject.put(NAME_ATTRIBUTE, names); + rootObject.put(USER_NAME_ATTRIBUTE, "passwordIncompatibleUser"); + rootObject.put(PASSWORD_ATTRIBUTE, "a"); + + StringEntity entity = new StringEntity(rootObject.toString()); + request.setEntity(entity); + + HttpResponse response = client.execute(request); + + Object responseObj = JSONValue.parse(EntityUtils.toString(response.getEntity())); + EntityUtils.consume(response.getEntity()); + + LOG.info("Response of testAddUserFailure method:" + responseObj.toString()); + + JSONArray schemasArray = (JSONArray)((JSONObject) responseObj).get("schemas"); + Assert.assertNotNull(schemasArray); + Assert.assertEquals(schemasArray.size(), 1); + Assert.assertEquals(schemasArray.get(0).toString(), ERROR_SCHEMA); } @Test(dependsOnMethods = "testCreateUser")