mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-07-11 02:53:16 +02:00
Unify password validation (#2077)
Passwords should be checked when created or changed in the frontend just as they are in the backend for REST and CLI. Also extend the password validation to allow upto 1024 characters instead of 32. Co-authored-by: Eduard Heimbuch <eduard.heimbuch@cloudogu.com>
This commit is contained in:
@@ -78,7 +78,7 @@ public class DefaultUserManagerTest extends UserManagerTestBase {
|
||||
public void shouldFailChangePasswordForWrongOldPassword() {
|
||||
UserManager userManager = new DefaultUserManager(userDAO);
|
||||
|
||||
userManager.changePasswordForLoggedInUser("wrongPassword", "---");
|
||||
userManager.changePasswordForLoggedInUser("wrongPassword", "$shiro1$secret");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -97,6 +97,7 @@ class UserConvertToInternalCommandTest {
|
||||
@Test
|
||||
void shouldPrintUserAfterActivationInEnglish() {
|
||||
testRenderer.setLocale("en");
|
||||
command.setPassword("havelock123");
|
||||
|
||||
command.run();
|
||||
|
||||
@@ -116,6 +117,7 @@ class UserConvertToInternalCommandTest {
|
||||
@Test
|
||||
void shouldPrintUserAfterActivationInGerman() {
|
||||
testRenderer.setLocale("de");
|
||||
command.setPassword("havelock123");
|
||||
|
||||
command.run();
|
||||
|
||||
|
||||
@@ -218,7 +218,7 @@ class UserCreateCommandTest {
|
||||
|
||||
verifyNoInteractions(manager);
|
||||
assertThat(testRenderer.getStdOut()).isEmpty();
|
||||
assertThat(testRenderer.getStdErr()).contains("Password is required for internal users");
|
||||
assertThat(testRenderer.getStdErr()).contains("Valid password is required for internal users");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -229,12 +229,13 @@ class UserCreateCommandTest {
|
||||
|
||||
verifyNoInteractions(manager);
|
||||
assertThat(testRenderer.getStdOut()).isEmpty();
|
||||
assertThat(testRenderer.getStdErr()).contains("Für interne Benutzer muss ein Passwort gesetzt werden");
|
||||
assertThat(testRenderer.getStdErr()).contains("Für interne Benutzer muss ein gültiges Passwort gesetzt werden");
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldFailWithEnglishMsgIfExternalUserAndInactive() {
|
||||
testRenderer.setLocale("en");
|
||||
command.setPassword("123456");
|
||||
command.setExternal(true);
|
||||
command.setInactive(true);
|
||||
|
||||
@@ -248,6 +249,7 @@ class UserCreateCommandTest {
|
||||
@Test
|
||||
void shouldFailWithGermanMsgIfExternalUserWithInactive() {
|
||||
testRenderer.setLocale("de");
|
||||
command.setPassword("123456");
|
||||
command.setExternal(true);
|
||||
command.setInactive(true);
|
||||
|
||||
|
||||
@@ -158,6 +158,7 @@ class UserModifyCommandTest {
|
||||
@Test
|
||||
void shouldPrintUserAfterModificationInEnglish() {
|
||||
testRenderer.setLocale("en");
|
||||
command.setPassword("havelock");
|
||||
command.setDisplayName("Lord Vetinari");
|
||||
command.setEmail("patrician@discworld");
|
||||
|
||||
@@ -179,6 +180,7 @@ class UserModifyCommandTest {
|
||||
@Test
|
||||
void shouldPrintUserAfterModificationInGerman() {
|
||||
testRenderer.setLocale("de");
|
||||
command.setPassword("havelock");
|
||||
command.setDisplayName("Lord Vetinari");
|
||||
command.setEmail("patrician@discworld");
|
||||
|
||||
@@ -216,6 +218,7 @@ class UserModifyCommandTest {
|
||||
@Test
|
||||
void shouldFailWithEnglishMsgIfUserNotFound() {
|
||||
testRenderer.setLocale("en");
|
||||
command.setPassword("havelock");
|
||||
when(manager.get(any())).thenReturn(null);
|
||||
|
||||
assertThrows(CliExitException.class, () -> command.run());
|
||||
@@ -228,6 +231,7 @@ class UserModifyCommandTest {
|
||||
@Test
|
||||
void shouldFailWithGermanMsgIfUserNotFound() {
|
||||
testRenderer.setLocale("de");
|
||||
command.setPassword("havelock");
|
||||
when(manager.get(any())).thenReturn(null);
|
||||
|
||||
assertThrows(CliExitException.class, () -> command.run());
|
||||
|
||||
Reference in New Issue
Block a user