Add testParseJWKSWithEmptyKeysArray (#233)
Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
This commit is contained in:
parent
5ec96673c9
commit
026f3c51e7
|
|
@ -11,6 +11,7 @@ import org.junit.jupiter.api.Test;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
|
@ -219,6 +220,25 @@ class JwtBundleTest {
|
|||
assertNotNull(jwtBundle.getJwtAuthorities().get("C6vs25welZOx6WksNYfbMfiw9l96pMnD"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParseJWKSWithEmptyKeysArray_Success() {
|
||||
TrustDomain trustDomain = TrustDomain.parse("example.org");
|
||||
String jwksEmptyKeysJson = "{\"keys\": []}";
|
||||
byte[] bundleBytes = jwksEmptyKeysJson.getBytes(StandardCharsets.UTF_8);
|
||||
|
||||
|
||||
JwtBundle jwtBundle = null;
|
||||
try {
|
||||
jwtBundle = JwtBundle.parse(trustDomain, bundleBytes);
|
||||
} catch (JwtBundleException e) {
|
||||
fail("Parsing failed with exception: " + e.getMessage());
|
||||
}
|
||||
|
||||
assertNotNull(jwtBundle, "JwtBundle should not be null");
|
||||
assertEquals(trustDomain, jwtBundle.getTrustDomain(), "Trust domain should match");
|
||||
assertTrue(jwtBundle.getJwtAuthorities().isEmpty(), "JwtAuthorities should be empty");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testParse_MissingKid_Fails() throws URISyntaxException, IOException {
|
||||
Path path = Paths.get(toUri("testdata/jwtbundle/jwks_missing_kid.json"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue