Skip to content

Commit

Permalink
Merge pull request #19816 from wso2/revert-19813-version-bump
Browse files Browse the repository at this point in the history
Revert "Modify tests temporarily"
  • Loading branch information
DMHP committed Feb 23, 2024
2 parents c07775c + a43f09f commit 6fb0b49
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 6fb0b49

Please sign in to comment.