mirror of
https://github.com/dredx/prole.git
synced 2026-09-24 15:44:33 +00:00
fix(prole-auth): update tests for SessionUser groups field
SessionUser record was extended with List<String> groups in the groups feature; test constructors still used the old 2-arg form. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e3ca33e4c7
commit
2bcc40fd50
@ -16,7 +16,7 @@ class SessionTokenServiceTest {
|
|||||||
Clock clock = Clock.fixed(Instant.parse("2026-03-20T00:00:00Z"), ZoneOffset.UTC);
|
Clock clock = Clock.fixed(Instant.parse("2026-03-20T00:00:00Z"), ZoneOffset.UTC);
|
||||||
SessionTokenService svc = SessionTokenService.forTests(om, clock);
|
SessionTokenService svc = SessionTokenService.forTests(om, clock);
|
||||||
|
|
||||||
String token = svc.issue("secret", new SessionUser("alice", "alice@prole.org"), Duration.ofMinutes(5));
|
String token = svc.issue("secret", new SessionUser("alice", "alice@prole.org", java.util.List.of()), Duration.ofMinutes(5));
|
||||||
assertNotNull(token);
|
assertNotNull(token);
|
||||||
|
|
||||||
SessionUser user = svc.verify("secret", token).orElseThrow();
|
SessionUser user = svc.verify("secret", token).orElseThrow();
|
||||||
@ -29,7 +29,7 @@ class SessionTokenServiceTest {
|
|||||||
ObjectMapper om = new ObjectMapper();
|
ObjectMapper om = new ObjectMapper();
|
||||||
Clock clock = Clock.fixed(Instant.parse("2026-03-20T00:00:00Z"), ZoneOffset.UTC);
|
Clock clock = Clock.fixed(Instant.parse("2026-03-20T00:00:00Z"), ZoneOffset.UTC);
|
||||||
SessionTokenService svc = SessionTokenService.forTests(om, clock);
|
SessionTokenService svc = SessionTokenService.forTests(om, clock);
|
||||||
String token = svc.issue("secret", new SessionUser("alice", "alice@prole.org"), Duration.ofMinutes(5));
|
String token = svc.issue("secret", new SessionUser("alice", "alice@prole.org", java.util.List.of()), Duration.ofMinutes(5));
|
||||||
assertTrue(svc.verify("other", token).isEmpty());
|
assertTrue(svc.verify("other", token).isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ class SessionTokenServiceTest {
|
|||||||
ObjectMapper om = new ObjectMapper();
|
ObjectMapper om = new ObjectMapper();
|
||||||
Clock clock = Clock.fixed(Instant.parse("2026-03-20T00:00:00Z"), ZoneOffset.UTC);
|
Clock clock = Clock.fixed(Instant.parse("2026-03-20T00:00:00Z"), ZoneOffset.UTC);
|
||||||
SessionTokenService svc = SessionTokenService.forTests(om, clock);
|
SessionTokenService svc = SessionTokenService.forTests(om, clock);
|
||||||
String token = svc.issue("secret", new SessionUser("alice", "alice@prole.org"), Duration.ofSeconds(1));
|
String token = svc.issue("secret", new SessionUser("alice", "alice@prole.org", java.util.List.of()), Duration.ofSeconds(1));
|
||||||
|
|
||||||
SessionTokenService svcLater = SessionTokenService.forTests(om, Clock.fixed(Instant.parse("2026-03-20T00:10:00Z"), ZoneOffset.UTC));
|
SessionTokenService svcLater = SessionTokenService.forTests(om, Clock.fixed(Instant.parse("2026-03-20T00:10:00Z"), ZoneOffset.UTC));
|
||||||
assertTrue(svcLater.verify("secret", token).isEmpty());
|
assertTrue(svcLater.verify("secret", token).isEmpty());
|
||||||
|
|||||||
@ -34,7 +34,7 @@ class VerifyControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void authenticatedGetsHeaders() throws Exception {
|
void authenticatedGetsHeaders() throws Exception {
|
||||||
String token = tokens.issue("test-secret", new SessionUser("alice", "alice@prole.org"), Duration.ofMinutes(10));
|
String token = tokens.issue("test-secret", new SessionUser("alice", "alice@prole.org", java.util.List.of()), Duration.ofMinutes(10));
|
||||||
mvc.perform(get("/auth/verify").header(HttpHeaders.COOKIE, "prole_session=" + token))
|
mvc.perform(get("/auth/verify").header(HttpHeaders.COOKIE, "prole_session=" + token))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(header().string(VerifyController.USER_HEADER, "alice"));
|
.andExpect(header().string(VerifyController.USER_HEADER, "alice"));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user