|
11 | 11 |
|
12 | 12 | import java.io.IOException; |
13 | 13 | import java.net.URISyntaxException; |
| 14 | +import java.nio.charset.StandardCharsets; |
14 | 15 | import java.nio.file.Files; |
15 | 16 | import java.nio.file.Path; |
16 | 17 | import java.nio.file.Paths; |
@@ -219,6 +220,25 @@ void testParseJsonWithRsaAndEcKeys_Success() throws URISyntaxException, IOExcept |
219 | 220 | assertNotNull(jwtBundle.getJwtAuthorities().get("C6vs25welZOx6WksNYfbMfiw9l96pMnD")); |
220 | 221 | } |
221 | 222 |
|
| 223 | + @Test |
| 224 | + void testParseJWKSWithEmptyKeysArray_Success() { |
| 225 | + TrustDomain trustDomain = TrustDomain.parse("example.org"); |
| 226 | + String jwksEmptyKeysJson = "{\"keys\": []}"; |
| 227 | + byte[] bundleBytes = jwksEmptyKeysJson.getBytes(StandardCharsets.UTF_8); |
| 228 | + |
| 229 | + |
| 230 | + JwtBundle jwtBundle = null; |
| 231 | + try { |
| 232 | + jwtBundle = JwtBundle.parse(trustDomain, bundleBytes); |
| 233 | + } catch (JwtBundleException e) { |
| 234 | + fail("Parsing failed with exception: " + e.getMessage()); |
| 235 | + } |
| 236 | + |
| 237 | + assertNotNull(jwtBundle, "JwtBundle should not be null"); |
| 238 | + assertEquals(trustDomain, jwtBundle.getTrustDomain(), "Trust domain should match"); |
| 239 | + assertTrue(jwtBundle.getJwtAuthorities().isEmpty(), "JwtAuthorities should be empty"); |
| 240 | + } |
| 241 | + |
222 | 242 | @Test |
223 | 243 | void testParse_MissingKid_Fails() throws URISyntaxException, IOException { |
224 | 244 | Path path = Paths.get(toUri("testdata/jwtbundle/jwks_missing_kid.json")); |
@@ -269,7 +289,7 @@ void testgetBundleForTrustDomain_Success() { |
269 | 289 | JwtBundle bundle = jwtBundle.getBundleForTrustDomain(TrustDomain.parse("example.org")); |
270 | 290 | assertEquals(jwtBundle, bundle); |
271 | 291 | } catch (BundleNotFoundException e) { |
272 | | - fail(e); |
| 292 | + fail(e); |
273 | 293 | } |
274 | 294 | } |
275 | 295 |
|
@@ -305,8 +325,8 @@ void testJWTAuthoritiesCRUD() { |
305 | 325 | } catch (AuthorityNotFoundException e) { |
306 | 326 | fail(e); |
307 | 327 | } |
308 | | - assertEquals(key1, jwtAuthority1 ); |
309 | | - assertEquals(key2, jwtAuthority2 ); |
| 328 | + assertEquals(key1, jwtAuthority1); |
| 329 | + assertEquals(key2, jwtAuthority2); |
310 | 330 |
|
311 | 331 | // Test RemoveJwtAuthority |
312 | 332 | jwtBundle.removeJwtAuthority("key1"); |
|
0 commit comments