Skip to content

Commit

Permalink
Fix tests to fit new features
Browse files Browse the repository at this point in the history
  • Loading branch information
fabian-schlegel committed Dec 3, 2024
1 parent 349d191 commit 537e997
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/test/java/io/kokuwa/keycloak/FailoverIT.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.kokuwa.keycloak;

import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.stream.IntStream;

Expand All @@ -13,7 +12,6 @@
import io.kokuwa.keycloak.k8s.KubernetesExtension;
import io.kokuwa.keycloak.keycloak.KeycloakExtension;
import io.kokuwa.keycloak.keycloak.OpenIDConnect;
import jakarta.ws.rs.NotAuthorizedException;

@DisplayName("failover")
@ExtendWith(KubernetesExtension.class)
Expand All @@ -40,9 +38,9 @@ void rollingRestart(Kubernetes kubernetes, OpenIDConnect oidc) {
"session should be available after restart"));
}

@DisplayName("session should be lost after scaling keycloak to 0")
@DisplayName("session should remain after scaling keycloak to 0")
@Test
void sessionLost(Kubernetes kubernetes, OpenIDConnect oidc) {
void sessionRemains(Kubernetes kubernetes, OpenIDConnect oidc) {

// get token and validate on userinfo endpoint

Expand All @@ -54,8 +52,8 @@ void sessionLost(Kubernetes kubernetes, OpenIDConnect oidc) {
kubernetes.scaleKeycloak(0);
kubernetes.scaleKeycloak(Kubernetes.KEYCLOAK_REPLICAS);

// try to validate old token, should fail because session was lost
// try to validate old token, should be fine because session should be stored since KeyCloak >= 26

assertThrows(NotAuthorizedException.class, () -> oidc.userinfo("test", token), "session should be lost");
assertDoesNotThrow(() -> oidc.userinfo("test", token), "session should still be valid");
}
}

0 comments on commit 537e997

Please sign in to comment.