[java-oidfed-common] 01/02: Improve tests to cover cases for private jwk(s)

Codeberg noreply at shibboleth.net
Thu Oct 8 05:32:18 UTC 2026


This is an automated email from the git hooks/post-receive script.

codeberg pushed a commit to branch main
in repository java-oidfed-common.

View the commit online:
https://codeberg.org/Shibboleth/java-oidfed-common/commit/0a50435111f8bf6a08c1b7d1985275f2d42daf6a

commit 0a50435111f8bf6a08c1b7d1985275f2d42daf6a
Author: Henri Mikkonen <henri.mikkonen at iki.fi>
AuthorDate: Wed Oct 7 18:54:27 2026 +0300

    Improve tests to cover cases for private jwk(s)
---
 .../cache/EntityConfigurationMetadataCacheTest.java    | 16 ++++++++++++++++
 .../flow/cache/SignedKeysetMetadataCacheTest.java      | 18 ++++++++++++++++++
 .../cache/SubordinateStatementMetadataCacheTest.java   | 18 ++++++++++++++++++
 3 files changed, 52 insertions(+)

diff --git a/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/EntityConfigurationMetadataCacheTest.java b/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/EntityConfigurationMetadataCacheTest.java
index 7b85b37..f1dc35a 100644
--- a/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/EntityConfigurationMetadataCacheTest.java
+++ b/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/EntityConfigurationMetadataCacheTest.java
@@ -134,6 +134,22 @@ public class EntityConfigurationMetadataCacheTest extends AbstractFederationFlow
         }
     }
 
+    @Test
+    public void testValidEntityConfiguration_privateJwks()
+            throws MetadataCacheException, UnsupportedOperationException, IOException, URISyntaxException {
+        final String entityId = uniqueClientId();
+        final JWTClaimsSet.Builder builder = new JWTClaimsSet.Builder().issuer(entityId).subject(entityId)
+                .issueTime(Date.from(Instant.now()))
+                .expirationTime(Date.from(Instant.now().plusSeconds(300)))
+                .claim("jwks", new JWKSet(leafKey).toJSONObject(false))
+                .claim("metadata", Map.of("federation_entity", Collections.emptyMap()));
+        final String entityConfiguration = FederationJwtSupport.signedJwt(
+                JWSAlgorithm.RS256, leafKey, "entity-statement+jwt", builder.build()).serialize();
+
+        mapResponse(entityConfigurationUrl(entityId), mockResponse(entityConfiguration));
+        assertNoEntityConfiguration(entityId);
+    }
+
     @Test
     public void testUnsignedEntityConfiguration()
             throws MetadataCacheException, UnsupportedOperationException, IOException, URISyntaxException {
diff --git a/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/SignedKeysetMetadataCacheTest.java b/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/SignedKeysetMetadataCacheTest.java
index f75c980..d4248b7 100644
--- a/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/SignedKeysetMetadataCacheTest.java
+++ b/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/SignedKeysetMetadataCacheTest.java
@@ -130,6 +130,24 @@ public class SignedKeysetMetadataCacheTest extends AbstractFederationFlowTest {
         }
     }
 
+    @Test
+    public void testValidSignedKeyset_privateJwk()
+            throws MetadataCacheException, UnsupportedOperationException, IOException, URISyntaxException {
+        final String entityId = uniqueClientId();
+        final String signedJwksUri = entityId + "/jwks.jwt";
+        final OIDCClientMetadata metadata = new OIDCClientMetadata();
+        metadata.setRedirectionURI(new URI(redirectUri));
+        metadata.setCustomField("signed_jwks_uri", signedJwksUri);
+        final JWTClaimsSet.Builder builder = new JWTClaimsSet.Builder().issuer(entityId).subject(entityId)
+                .issueTime(Date.from(Instant.now()))
+                .claim("keys", new JWKSet(rpKey).toJSONObject(false).get("keys"));
+        final String signedKeyset = FederationJwtSupport.signedJwt(
+                JWSAlgorithm.RS256, leafKey, "jwk-set+jwt", builder.build()).serialize();
+
+        mapResponse(signedJwksUri, mockResponse(200, "application/jwk-set+jwt", signedKeyset));
+        assertNoSignedKeyset(signedJwksUri, buildEntityConfiguration(entityId, metadata));
+    }
+
     @Test
     public void testInvalidSignedKeyset_expired()
             throws MetadataCacheException, UnsupportedOperationException, IOException, URISyntaxException {
diff --git a/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/SubordinateStatementMetadataCacheTest.java b/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/SubordinateStatementMetadataCacheTest.java
index e24eea6..9ab38a9 100644
--- a/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/SubordinateStatementMetadataCacheTest.java
+++ b/oidfed-common-conf-impl/src/test/java/net/shibboleth/oidfed/flow/cache/SubordinateStatementMetadataCacheTest.java
@@ -186,6 +186,24 @@ public class SubordinateStatementMetadataCacheTest extends AbstractFederationFlo
         }
     }
 
+    @Test
+    public void testValidSubordinateStatement_privateJwks()
+            throws MetadataCacheException, UnsupportedOperationException, IOException, URISyntaxException {
+        final String entityId = uniqueClientId();
+        final JWTClaimsSet.Builder builder = new JWTClaimsSet.Builder().issuer(anchorId).subject(entityId)
+                .issueTime(Date.from(Instant.now()))
+                .expirationTime(Date.from(Instant.now().plusSeconds(300)))
+                .claim("jwks", new JWKSet(leafKey).toJSONObject(false))
+                .claim("metadata", Map.of("federation_entity", Collections.emptyMap()));
+        final String subordinateStatement = FederationJwtSupport.signedJwt(
+                JWSAlgorithm.RS256, trustedAnchorKey, "entity-statement+jwt", builder.build()).serialize();
+
+        mapResponse(entityConfigurationUrl(anchorId), mockResponse(trustedAnchorConfiguration()));
+        mapResponse(subordinateStatementUrl(anchorFetchEndpoint, entityId),
+                mockResponse(subordinateStatement));
+        assertNoSubordinateStatement(entityId);
+    }
+
     @Test
     public void testUnsignedSubordinateStatement()
             throws MetadataCacheException, UnsupportedOperationException, IOException, URISyntaxException {

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list