From 2338c3cc57c4fb89cf2f369820833b9803da0dfc Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Wed, 18 Dec 2024 17:20:33 +0100 Subject: [PATCH] do not require CAS service ticket for tests --- .../hostsharing/hsadminng/config/CasAuthenticationFilter.java | 2 +- .../hostsharing/hsadminng/config/CasServiceTicketValidator.java | 2 +- .../java/net/hostsharing/hsadminng/hs/scenarios/UseCase.java | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/hostsharing/hsadminng/config/CasAuthenticationFilter.java b/src/main/java/net/hostsharing/hsadminng/config/CasAuthenticationFilter.java index d81c13a8..9f7be5bc 100644 --- a/src/main/java/net/hostsharing/hsadminng/config/CasAuthenticationFilter.java +++ b/src/main/java/net/hostsharing/hsadminng/config/CasAuthenticationFilter.java @@ -25,7 +25,7 @@ public class CasAuthenticationFilter implements Filter { final var ticket = httpRequest.getHeader("Authorization"); - if (ticket == null || !ticketValidator.validateTicket(ticket)) { + if (!ticketValidator.validateTicket(ticket)) { httpResponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED); return; } diff --git a/src/main/java/net/hostsharing/hsadminng/config/CasServiceTicketValidator.java b/src/main/java/net/hostsharing/hsadminng/config/CasServiceTicketValidator.java index bb1c78cb..18f5a52a 100644 --- a/src/main/java/net/hostsharing/hsadminng/config/CasServiceTicketValidator.java +++ b/src/main/java/net/hostsharing/hsadminng/config/CasServiceTicketValidator.java @@ -22,7 +22,7 @@ public class CasServiceTicketValidator { @SneakyThrows public boolean validateTicket(final String ticket) { - if (casServerUrl.equals("fake") && ticket.equals("test")) { + if (casServerUrl.equals("fake")) { return true; } diff --git a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/UseCase.java b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/UseCase.java index d0167933..93943e73 100644 --- a/src/test/java/net/hostsharing/hsadminng/hs/scenarios/UseCase.java +++ b/src/test/java/net/hostsharing/hsadminng/hs/scenarios/UseCase.java @@ -207,7 +207,6 @@ public abstract class UseCase> { .uri(new URI("http://localhost:" + testSuite.port + uriPath)) .header("Content-Type", "application/json") .header("current-subject", ScenarioTest.RUN_AS_USER) - .header("Authorization", "test") .timeout(seconds(10)) .build(); final var response = client.send(request, BodyHandlers.ofString());