Skip to content

Commit

Permalink
Revert "Modify tests temporarily"
Browse files Browse the repository at this point in the history
  • Loading branch information
madurangasiriwardena authored Feb 23, 2024
1 parent c07775c commit a43f09f
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 a43f09f

Please sign in to comment.