From 446b0b29a89f9f81d46e1c26b0dd5e8a0f1f50a4 Mon Sep 17 00:00:00 2001 From: Max Lambrecht Date: Mon, 8 Apr 2024 07:21:55 -0700 Subject: [PATCH] Add Test for Parsing JWKS with Empty Keys Array (#89) Add test_parse_jwks_with_empty_keys_array Signed-off-by: Max Lambrecht --- spiffe/src/bundle/jwt/mod.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spiffe/src/bundle/jwt/mod.rs b/spiffe/src/bundle/jwt/mod.rs index 85b5a0d..1ed082f 100644 --- a/spiffe/src/bundle/jwt/mod.rs +++ b/spiffe/src/bundle/jwt/mod.rs @@ -256,4 +256,17 @@ mod jwt_bundle_test { JwtBundleError::Deserialize(..) )); } + + #[test] + fn test_parse_jwks_with_empty_keys_array() { + let bundle_bytes = r#"{"keys": []}"#.as_bytes(); + let trust_domain = TrustDomain::new("domain.test").unwrap(); + let jwt_bundle = JwtBundle::from_jwt_authorities(trust_domain, bundle_bytes) + .expect("Failed to parse JWKS with empty keys array"); + + assert!( + jwt_bundle.jwt_authorities.is_empty(), + "JWT authorities should be empty" + ); + } }