File tree 4 files changed +44
-3
lines changed
4 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ public struct BearerDID {
105
105
uri: did. uri,
106
106
document: document,
107
107
privateKeys: privateKeys,
108
- metadata: metadata
108
+ metadata: metadata ?? [ : ]
109
109
)
110
110
}
111
111
}
Original file line number Diff line number Diff line change @@ -20,5 +20,5 @@ public struct PortableDID: Codable {
20
20
let privateKeys : [ Jwk ]
21
21
22
22
/// Additional DID method specific information to be included
23
- let metadata : Metadata ?
23
+ let metadata : Metadata
24
24
}
Original file line number Diff line number Diff line change
1
+ import XCTest
2
+ import AnyCodable
3
+ @testable import Web5
4
+
5
+ final class Web5TestVectorsPortableDid : XCTestCase {
6
+
7
+ func test_parse( ) throws {
8
+
9
+ struct Output : Codable { }
10
+ /// TestVector Input could not be optional.
11
+ /// We need an optional structure to temporary store incomplete did json
12
+ struct OptionalPortableDid : Codable {
13
+ typealias Metadata = [ String : AnyCodable ]
14
+ let uri : String ?
15
+ let document : DIDDocument ?
16
+ let privateKeys : [ Jwk ] ?
17
+ let metadata : Metadata ?
18
+ }
19
+
20
+ let testVector = try TestVector < OptionalPortableDid , Output > (
21
+ fileName: " parse " ,
22
+ subdirectory: " test-vectors/portable_did "
23
+ )
24
+
25
+ testVector. run { vector in
26
+
27
+ guard let isError: Bool = vector. errors else {
28
+ return XCTFail ( " Missing `errors` property " )
29
+ }
30
+
31
+ let data = try JSONEncoder ( ) . encode ( vector. input)
32
+
33
+ if ( isError) {
34
+ XCTAssertThrowsError ( try JSONDecoder ( ) . decode ( PortableDID . self, from: data) )
35
+ } else {
36
+ let dataModel = try JSONDecoder ( ) . decode ( PortableDID . self, from: data)
37
+ XCTAssertNotNil ( dataModel) ;
38
+ }
39
+ }
40
+ }
41
+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ final class BearerDIDTests: XCTestCase {
12
12
XCTAssertNoDifference ( portableDID. uri, didJWK. uri)
13
13
XCTAssertNoDifference ( portableDID. document, didJWK. document)
14
14
XCTAssertNoDifference ( portableDID. privateKeys. count, 1 )
15
- XCTAssertNil ( portableDID. metadata)
15
+ XCTAssertNoDifference ( portableDID. metadata, [ : ] )
16
16
}
17
17
18
18
func test_getSigner( ) throws {
You can’t perform that action at this time.
0 commit comments