Skip to content

Commit 15177d8

Browse files
committed
Enhances presentation verification tests
Updates VcVerifier tests to correctly handle presentation SD-JWTs that include a Key Binding JWT.
1 parent 56cb4c3 commit 15177d8

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

Tests/Verification/VcVerifierTest.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,8 +1197,7 @@ final class VcVerifierTest: XCTestCase {
11971197
// MARK: - Claims Validation Tests (Presentation)
11981198

11991199
func testVerifyPresentation_WithClaimsVerifier_ShouldVerifyClaims() async throws {
1200-
// Given
1201-
let sdJwtString = SDJWTConstants.issuer_metadata_sd_jwt.clean()
1200+
let sdJwtString = SDJWTConstants.presentation_sd_jwt.clean()
12021201

12031202
// Create a claims verifier that will validate whatever claims are in the JWT
12041203
let claimsVerifier = ClaimsVerifier(
@@ -1207,21 +1206,20 @@ final class VcVerifierTest: XCTestCase {
12071206
currentDate: Date()
12081207
)
12091208

1210-
// When
1209+
// When - Must provide KB verifier since presentation has KB-JWT
12111210
let result = try await metadataVerifier.verifyPresentation(
12121211
unverifiedSdJwt: sdJwtString,
12131212
claimsVerifier: claimsVerifier,
1214-
keyBindingVerifier: nil,
1215-
expectedNonce: nil
1213+
keyBindingVerifier: KeyBindingVerifier(),
1214+
expectedNonce: "123456789"
12161215
)
12171216

12181217
// Then - should succeed because claims are validated
12191218
XCTAssertNoThrow(try result.get())
12201219
}
12211220

12221221
func testVerifyPresentation_JSON_WithClaimsVerifier_ShouldVerifyClaims() async throws {
1223-
// Given
1224-
let sdJwtString = SDJWTConstants.issuer_metadata_sd_jwt.clean()
1222+
let sdJwtString = SDJWTConstants.presentation_sd_jwt.clean()
12251223
let parser = CompactParser()
12261224
let sdJwt = try parser.getSignedSdJwt(serialisedString: sdJwtString)
12271225
let json = try sdJwt.asJwsJsonObject(
@@ -1237,12 +1235,11 @@ final class VcVerifierTest: XCTestCase {
12371235
currentDate: Date()
12381236
)
12391237

1240-
// When
12411238
let result = try await metadataVerifier.verifyPresentation(
12421239
unverifiedSdJwt: json,
12431240
claimsVerifier: claimsVerifier,
1244-
keyBindingVerifier: nil,
1245-
expectedNonce: nil
1241+
keyBindingVerifier: KeyBindingVerifier(),
1242+
expectedNonce: "123456789"
12461243
)
12471244

12481245
// Then - should succeed because claims are validated

0 commit comments

Comments
 (0)