Skip to content
Snippets Groups Projects
Verified Commit 050b1cd0 authored by Ira ¯\_(ツ)_/¯'s avatar Ira ¯\_(ツ)_/¯
Browse files

Add password validation integration tests

parent 0aef9056
No related branches found
No related tags found
No related merge requests found
......@@ -122,4 +122,43 @@ public class MailPassResourceIntegrationTest {
assertEquals("password object not detected in provided JSON body", error);
}
@Test
public void testInvalidLengthPasswordRaisesBadRequestException400() {
Response response =
given()
.header("Authorization", "Bearer " + adminToken)
.contentType(ContentType.JSON)
.body("{ \"password\": \"123456\" }")
.when()
.post(MessageFormat.format(ROOT_URI, port) + "/compute-password-hash");
assertEquals(400, response.getStatusCode());
}
@Test
public void testUserNameAsPasswordRaisesBadRequestException400() {
Response response =
given()
.header("Authorization", "Bearer " + adminToken)
.contentType(ContentType.JSON)
.body("{ \"password\": \"admin\" }")
.when()
.post(MessageFormat.format(ROOT_URI, port) + "/compute-password-hash");
assertEquals(400, response.getStatusCode());
}
@Test
public void testInvalidPasswordExceptionMessage() {
Response response =
given()
.header("Authorization", "Bearer " + adminToken)
.contentType(ContentType.JSON)
.body("{ \"password\": \"admin\" }")
.when()
.post(MessageFormat.format(ROOT_URI, port) + "/compute-password-hash");
String error = response.jsonPath().getString("error");
assertEquals("password policy error(length(8) and notUsername)", error);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment