From 9c7ab2c13a3985da83b7c09a27576060190d046f Mon Sep 17 00:00:00 2001 From: Morten Svanaes Date: Tue, 21 Jan 2025 16:48:27 +0800 Subject: [PATCH] fix: set maxPasswordLength in password tests Signed-off-by: Morten Svanaes --- .../hisp/dhis/webapi/controller/AccountControllerTest.java | 2 ++ .../org/hisp/dhis/webapi/controller/MeControllerTest.java | 3 +++ .../dhis/webapi/controller/UserAccountControllerTest.java | 4 ++-- .../org/hisp/dhis/webapi/controller/UserControllerTest.java | 1 + 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/AccountControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/AccountControllerTest.java index 04aebea47b15..585ecaf8d37b 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/AccountControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/AccountControllerTest.java @@ -191,6 +191,7 @@ void testValidatePasswordGet_PasswordValid() { @Test void testValidatePasswordGet_PasswordNotValid() { + POST("/systemSettings/maxPasswordLength", "72").content(HttpStatus.OK); assertMessage( "response", "error", @@ -209,6 +210,7 @@ void testValidatePasswordPost_PasswordValid() { @Test void testValidatePasswordPost_PasswordNotValid() { + POST("/systemSettings/maxPasswordLength", "72").content(HttpStatus.OK); assertMessage( "response", "error", diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/MeControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/MeControllerTest.java index 57efc656588b..3bb12d3fd5f9 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/MeControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/MeControllerTest.java @@ -136,6 +136,7 @@ void testChangePassword() { @Test void testChangePassword_WrongNew() { + POST("/systemSettings/maxPasswordLength", "72").content(HttpStatus.OK); assertEquals( "Password must have at least 8, and at most 72 characters", PUT("/me/changePassword", "{'oldPassword':'district','newPassword':'secret'}") @@ -203,6 +204,7 @@ void testValidatePasswordText() { @Test void testValidatePasswordText_TooShort() { + POST("/systemSettings/maxPasswordLength", "72").content(HttpStatus.OK); JsonPasswordValidation result = POST("/me/validatePassword", ContentType("text/plain"), Body("secret")) .content() @@ -214,6 +216,7 @@ void testValidatePasswordText_TooShort() { @Test void testValidatePasswordText_TooLong() { + POST("/systemSettings/maxPasswordLength", "72").content(HttpStatus.OK); JsonPasswordValidation result = POST( "/me/validatePassword", diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserAccountControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserAccountControllerTest.java index ab56b78e7b51..7b7c25e51c51 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserAccountControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserAccountControllerTest.java @@ -351,7 +351,7 @@ void selfRegSurnameTooLong() { void selfRegInvalidPassword(String input, String expectedError) { disableRecaptcha(); enableSelfRegistration(); - + POST("/systemSettings/maxPasswordLength", "72").content(HttpStatus.OK); assertWebMessage( "Bad Request", 400, @@ -527,7 +527,7 @@ void inviteRegSurnameTooLong() { @DisplayName("Invite registration error when invalid password data") void inviteRegInvalidPassword(String password, String expectedError) { disableRecaptcha(); - + POST("/systemSettings/maxPasswordLength", "72").content(HttpStatus.OK); assertWebMessage( "Bad Request", 400, diff --git a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserControllerTest.java b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserControllerTest.java index 1f2110a4859a..faa42c786b2b 100644 --- a/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserControllerTest.java +++ b/dhis-2/dhis-test-web-api/src/test/java/org/hisp/dhis/webapi/controller/UserControllerTest.java @@ -663,6 +663,7 @@ void testReplicateUser_PasswordNotSpecified() { @Test void testReplicateUser_PasswordNotValid() { + POST("/systemSettings/maxPasswordLength", "72").content(HttpStatus.OK); assertWebMessage( "Conflict", 409,