[CST-6108] implemented community feedbacks

This commit is contained in:
Mykhaylo
2022-09-16 12:19:06 +02:00
parent a0e633f1d4
commit a31bb4bf61
3 changed files with 26 additions and 10 deletions

View File

@@ -120,5 +120,4 @@ org.dspace.app.rest.exception.RESTEmptyWorkflowGroupException.message = Refused
org.dspace.app.rest.exception.EPersonNameNotProvidedException.message = The eperson.firstname and eperson.lastname values need to be filled in org.dspace.app.rest.exception.EPersonNameNotProvidedException.message = The eperson.firstname and eperson.lastname values need to be filled in
org.dspace.app.rest.exception.GroupNameNotProvidedException.message = Cannot create group, no group name is provided org.dspace.app.rest.exception.GroupNameNotProvidedException.message = Cannot create group, no group name is provided
org.dspace.app.rest.exception.GroupHasPendingWorkflowTasksException.message = Cannot delete group, the associated workflow role still has pending tasks org.dspace.app.rest.exception.GroupHasPendingWorkflowTasksException.message = Cannot delete group, the associated workflow role still has pending tasks
org.dspace.app.rest.exception.PasswordNotValidException.message = New password is invalid. Valid passwords must be between 8-15 characters long and must \ org.dspace.app.rest.exception.PasswordNotValidException.message = New password is invalid. Valid passwords must have at least 8 characters long!
include a minimum of: one uppercase letter, one lowercase letter, one number, and one special character (!?$@#$%^&+=).

View File

@@ -9,21 +9,36 @@ package org.dspace.authorize;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
import static org.mockito.Mockito.when;
import org.dspace.AbstractIntegrationTest; import org.dspace.AbstractIntegrationTest;
import org.dspace.authorize.service.PasswordValidatorService; import org.dspace.services.ConfigurationService;
import org.dspace.passwordvalidation.factory.PasswordValidationFactory; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
/** /**
* Unit tests for {@link RegexPasswordValidator}. * Unit tests for {@link RegexPasswordValidator}.
* *
* @author Luca Giamminonni (luca.giamminonni at 4science.it) * @author Luca Giamminonni (luca.giamminonni at 4science.it)
*/ */
@RunWith(MockitoJUnitRunner.class)
public class RegexPasswordValidatorTest extends AbstractIntegrationTest { public class RegexPasswordValidatorTest extends AbstractIntegrationTest {
private PasswordValidatorService regexPasswordValidator = PasswordValidationFactory.getInstance() @Mock
.getPasswordValidationService(); private ConfigurationService configurationService;
@InjectMocks
private RegexPasswordValidator regexPasswordValidator;
@Before
public void setup() {
when(configurationService.getProperty("authentication-password.regex-validation.pattern"))
.thenReturn("^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[^\\da-zA-Z]).{8,15}$");
}
@Test @Test
public void testValidPassword() { public void testValidPassword() {

View File

@@ -31,10 +31,10 @@
# (by default is enabled, to disable, either comment out this configuration or set it to an empty value) # (by default is enabled, to disable, either comment out this configuration or set it to an empty value)
# This regular expression is used to validate password during creation of EPerson # This regular expression is used to validate password during creation of EPerson
# or during the patch of password. # or during the patch of password.
# NOTE: when you configure a custom regex, you have to update the rules on angular's i18n end, # NOTE: when you configure a custom regex, you will also need to update the text of
# variable: "profile.security.form.notifications.error.robust-password". # "org.dspace.app.rest.exception.PasswordNotValidException.message" in Messages.properties to describe the minimum requirements.
# #
# The following regex applies subsequent rules: # The following regex applies subsequent rules: ^(?=.*?[a-z])(?=.*?[A-Z])(?=\\S*?[0-9])(?=\\S*?[!?$@#$%^&+=]).{8\,15}$
# 1) (?=.*?[a-z]) - the password must contain at least one lowercase character # 1) (?=.*?[a-z]) - the password must contain at least one lowercase character
# 2) (?=.*?[A-Z]) - the password must contain at least one uppercase character # 2) (?=.*?[A-Z]) - the password must contain at least one uppercase character
# 3) (?=\\S*?[0-9]) - the password must contain at least one numeric character # 3) (?=\\S*?[0-9]) - the password must contain at least one numeric character
@@ -42,6 +42,8 @@
# 5) {8\,15} - the password must be at least 8 and at most 15 characters long # 5) {8\,15} - the password must be at least 8 and at most 15 characters long
# REMARK: {8\,15} - the slash in this regex is an exception of the Apache library, as "," is a special character, # REMARK: {8\,15} - the slash in this regex is an exception of the Apache library, as "," is a special character,
# consequently to interpret it correctly you have to add the slash in front # consequently to interpret it correctly you have to add the slash in front
authentication-password.regex-validation.pattern = ^(?=.*?[a-z])(?=.*?[A-Z])(?=\\S*?[0-9])(?=\\S*?[!?$@#$%^&+=]).{8\,15}$
# By default, DSpace just requires a password of 8 or more characters.
# However, we recommend most sites consider either increasing the required length or complexity (see example above)
authentication-password.regex-validation.pattern = ^.{8\,}$