Skip to content

Commit

Permalink
Merge pull request quarkusio#44936 from sberyozkin/mutable_oidc_reque…
Browse files Browse the repository at this point in the history
…st_context_props

Make sure OidcRequestContextProperties are always modifiable
  • Loading branch information
sberyozkin authored Dec 5, 2024
2 parents a47ad60 + 201460b commit a0a8950
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.quarkus.oidc.common;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

public class OidcRequestContextProperties {
Expand All @@ -16,7 +17,7 @@ public OidcRequestContextProperties() {
}

public OidcRequestContextProperties(Map<String, Object> properties) {
this.properties = properties;
this.properties = new HashMap<>(properties);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.quarkus.oidc.common.runtime;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.util.Map;

import org.junit.jupiter.api.Test;

import io.quarkus.oidc.common.OidcRequestContextProperties;

public class OidcRequestContextPropertiesTest {

@Test
public void testModifyPropertiesDefaultConstructor() throws Exception {
OidcRequestContextProperties props = new OidcRequestContextProperties();
assertNull(props.get("a"));
props.put("a", "value");
assertEquals("value", props.get("a"));
}

@Test
public void testModifyExistinProperties() throws Exception {
OidcRequestContextProperties props = new OidcRequestContextProperties(Map.of("a", "value"));
assertEquals("value", props.get("a"));
props.put("a", "avalue");
assertEquals("avalue", props.get("a"));
props.put("b", "bvalue");
assertEquals("bvalue", props.get("b"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void testGetAccessTokenWithConfiguredExpiresIn() {
long expectedExpiresAt = now + 5;
long accessTokenExpiresAt = Long.valueOf(data[1]);
assertTrue(accessTokenExpiresAt >= expectedExpiresAt
&& accessTokenExpiresAt <= expectedExpiresAt + 2);
&& accessTokenExpiresAt <= expectedExpiresAt + 4);
}

@Test
Expand Down

0 comments on commit a0a8950

Please sign in to comment.