Skip to content

Commit

Permalink
update the model
Browse files Browse the repository at this point in the history
  • Loading branch information
Thumimku committed Jan 8, 2024
1 parent bc605fd commit e7cdcc7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,29 +79,8 @@ public void testDefaultResponse() throws Exception {
"Response of the get /validation-rules doesn't match.");
}

@Test (description = "test put email type user name validation update", dependsOnMethods = "testDefaultResponse")
public void testEnableEmailTypeUserNameValidation() throws Exception {

ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory());
String emailTypeValidationRequestBody
= readResource("put-enable-email-type-username-validation-positive.json");

Response responseOfPut = getResponseOfPut(VALIDATION_RULES_PATH, emailTypeValidationRequestBody);
responseOfPut.then()
.log().ifValidationFails()
.assertThat()
.statusCode(HttpStatus.SC_OK);
List<ValidationConfigModel> retrievedValidationConfigModels =
Arrays.asList(jsonWriter.readValue(responseOfPut.asString(), ValidationConfigModel[].class));
Assert.assertEquals(retrievedValidationConfigModels.get(1).getField(), "username",
"Response of the put /validation-rules doesn't contain username filed.");
Assert.assertEquals(retrievedValidationConfigModels.get(1).getRules().get(0).getValidator(),
"EmailFormatValidator",
"Response of the put /validation-rules doesn't contain email as username validator.");
}

@Test (description = "test for put /validation-rules/password end point",
dependsOnMethods = "testEnableEmailTypeUserNameValidation")
dependsOnMethods = "testDefaultResponse")
public void testUpdatePasswordValidation() throws Exception {

ObjectMapper jsonWriter = new ObjectMapper(new JsonFactory());
Expand All @@ -121,8 +100,27 @@ public void testUpdatePasswordValidation() throws Exception {
RuleModel ruleModel = new RuleModel();
ruleModel.setValidator("LengthValidator");
ruleModel.addPropertiesItem(new MappingModel().key("min.length").value("10"));
ruleModel.addPropertiesItem(new MappingModel().key("max.length").value("30"));
Assert.assertTrue(retrievedValidationConfigModel.getRules().contains(ruleModel),
"Response of the put /validation-rules/password doesn't contain 10 as min length.");

ruleModel = new RuleModel();
ruleModel.setValidator("UpperCaseValidator");
ruleModel.addPropertiesItem(new MappingModel().key("min.length").value("0"));
Assert.assertTrue(retrievedValidationConfigModel.getRules().contains(ruleModel),
"Response of the put /validation-rules/password doesn't contain 0 as UpperCaseValidator.");

ruleModel = new RuleModel();
ruleModel.setValidator("LowerCaseValidator");
ruleModel.addPropertiesItem(new MappingModel().key("min.length").value("0"));
Assert.assertTrue(retrievedValidationConfigModel.getRules().contains(ruleModel),
"Response of the put /validation-rules/password doesn't contain 0 as LowerCaseValidator.");

ruleModel = new RuleModel();
ruleModel.setValidator("SpecialCharacterValidator");
ruleModel.addPropertiesItem(new MappingModel().key("min.length").value("0"));
Assert.assertTrue(retrievedValidationConfigModel.getRules().contains(ruleModel),
"Response of the put /validation-rules/password doesn't contain 0 as SpecialCharacterValidator.");
}

@Test (description = "Test to set configuration to default.",dependsOnMethods = "testUpdatePasswordValidation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
}
]
},
{
"validator": "LengthValidator",
"properties": [
{
"key": "max.length",
"value": "30"
}
]
},
{
"validator": "NumeralValidator",
"properties": [
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
}
]
},
{
"validator": "LengthValidator",
"properties": [
{
"key": "max.length",
"value": "30"
}
]
},
{
"validator": "NumeralValidator",
"properties": [
Expand All @@ -23,7 +32,7 @@
"properties": [
{
"key": "min.length",
"value": "1"
"value": "0"
}
]
},
Expand All @@ -32,7 +41,7 @@
"properties": [
{
"key": "min.length",
"value": "1"
"value": "0"
}
]
},
Expand All @@ -41,7 +50,7 @@
"properties": [
{
"key": "min.length",
"value": "1"
"value": "0"
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@
<class name="org.wso2.identity.integration.test.rest.api.server.organization.management.v1.OrganizationManagementSuccessTest"/>
<class name="org.wso2.identity.integration.test.rest.api.server.validation.rules.v1.ValidationRulesSuccessTest"/>
<class name="org.wso2.identity.integration.test.rest.api.server.validation.rules.v1.ValidationRulesNegativeTest"/>
<class name="org.wso2.identity.integration.test.rest.api.server.validation.rules.v1.ValidationRulesTestBase"/>
</classes>
</test>

Expand Down

0 comments on commit e7cdcc7

Please sign in to comment.