feat: switched-on password rules for the hint, named refusals
The system exposes the switched-on admin password rules. mobile-api serves them to signed-in admins and, rate limited, on an exact public route for the first-login screen. Every admin password path now refuses with PASSWORD_RULE naming the first rule broken. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
0b201a51ca
commit
5e68478670
15 files changed
+494
-3
No files matched your search
+44
@@ -0,0 +1,44 @@
|
||||
package com.solvway.services.system.service;
|
||||
|
||||
import com.solvway.services.system.model.PasswordRuleProperty;
|
||||
import com.solvway.services.system.repo.PasswordRuleRepository;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** The admin password hint lists only the switched-on ADMIN rules, in the order the check runs them. */
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class PasswordRuleServiceAdminActiveTest {
|
||||
|
||||
@Mock private PasswordRuleRepository repo;
|
||||
@InjectMocks private PasswordRuleService service;
|
||||
|
||||
private static PasswordRuleProperty rule(String param, String status, String value) {
|
||||
PasswordRuleProperty r = new PasswordRuleProperty();
|
||||
r.setParam(param);
|
||||
r.setStatus(status);
|
||||
r.setValue(value);
|
||||
return r;
|
||||
}
|
||||
|
||||
@Test
|
||||
void adminActive_onlyYRules_withValues_nullForFlags() {
|
||||
when(repo.findByType("ADMIN_PWD_FORMAT")).thenReturn(List.of(
|
||||
rule("INPUT_LENGTH_MIN", "Y", "8"),
|
||||
rule("INPUT_LENGTH_MAX", "N", "20"),
|
||||
rule("SYMBOLIC_LENGTH_MIN", "Y", "2"),
|
||||
rule("SPACE_NOT_ALLOWED", "Y", null)));
|
||||
|
||||
assertThat(service.adminActive()).containsExactly(
|
||||
new PasswordRuleService.ActiveRule("INPUT_LENGTH_MIN", "8"),
|
||||
new PasswordRuleService.ActiveRule("SYMBOLIC_LENGTH_MIN", "2"),
|
||||
new PasswordRuleService.ActiveRule("SPACE_NOT_ALLOWED", null));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user