@@ -12,111 +12,119 @@ import {expect} from 'chai';
12
12
export function dataModelSuite ( {
13
13
issuers,
14
14
suiteName,
15
- keyType ,
15
+ keyTypes ,
16
16
vcVersion,
17
17
credential,
18
18
mandatoryPointers
19
19
} ) {
20
20
return describe ( `${ suiteName } - Data Model - VC ${ vcVersion } ` , function ( ) {
21
21
this . matrix = true ;
22
22
this . report = true ;
23
- this . implemented = [ ... issuers ] ;
23
+ this . implemented = [ ] ;
24
24
this . rowLabel = 'Test Name' ;
25
25
this . columnLabel = 'Implementation' ;
26
26
for ( const [ name , { endpoints} ] of issuers ) {
27
- const [ issuer ] = endpoints ;
28
- // does the endpoint support this test?
29
- if ( ! endpointCheck ( { endpoint : issuer , keyType, vcVersion} ) ) {
30
- continue ;
31
- }
32
- describe ( `${ name } : ${ keyType } ` , function ( ) {
33
- let securedCredential = null ;
34
- let proofs = [ ] ;
35
- before ( async function ( ) {
36
- securedCredential = await createInitialVc ( {
37
- issuer,
38
- vcVersion,
39
- vc : credential ,
40
- mandatoryPointers
41
- } ) ;
42
- if ( securedCredential ) {
43
- proofs = Array . isArray ( securedCredential . proof ) ?
44
- securedCredential ?. proof : [ securedCredential ?. proof ] ;
45
- // only test proofs that match the relevant cryptosuite
46
- proofs = proofs . filter ( p => p ?. cryptosuite === suiteName ) ;
27
+ for ( const keyType of keyTypes ) {
28
+ for ( const issuer of endpoints ) {
29
+ // does the endpoint support this test?
30
+ if ( ! endpointCheck ( { endpoint : issuer , keyType, vcVersion} ) ) {
31
+ continue ;
47
32
}
48
- } ) ;
49
- beforeEach ( function ( ) {
50
- this . currentTest . cell = {
51
- rowId : this . currentTest . title ,
52
- columnId : this . currentTest . parent . title
53
- } ;
54
- } ) ;
55
- function assertBefore ( ) {
56
- expect (
57
- securedCredential ,
58
- `Expected issuer ${ name } : ${ keyType } to issue a VC.`
59
- ) . to . exist ;
60
- expect (
61
- securedCredential ,
62
- 'Expected VC to be an object.'
63
- ) . to . be . an ( 'object' ) ;
64
- }
65
- it ( 'The publicKeyMultibase value of the verification method MUST ' +
66
- 'start with the base-58-btc prefix (z), as defined in the ' +
67
- 'Multibase section of Controller Documents 1.0. ' ,
68
- async function ( ) {
69
- this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#data-model:~:text=The%20publicKeyMultibase%20value%20of%20the%20verification%20method%20MUST%20start%20with%20the%20base%2D58%2Dbtc%20prefix%20(z)%2C%20as%20defined%20in%20the%20Multibase%20section%20of%20Controller%20Documents%201.0.' ;
70
- assertBefore ( ) ;
71
- for ( const proof of proofs ) {
72
- expect ( proof . verificationMethod ) . to . exist ;
73
- expect ( proof . verificationMethod ) . to . be . a ( 'string' ) ;
74
- const didDoc = await didResolver ( { url : proof . verificationMethod } ) ;
75
- expect ( didDoc ) . to . be . an ( 'object' ) ;
76
- expect ( didDoc . publicKeyMultibase ) . to . be . a ( 'string' ) ;
77
- expect (
78
- assertions . shouldBeBs58 ( didDoc . publicKeyMultibase ) ,
79
- 'Expected "publicKeyMultibase" to be Base58 encoded.'
80
- ) . to . be . true ;
81
- }
82
- } ) ;
83
- it ( 'Any other encoding MUST NOT be allowed. (verificationMethod)' ,
84
- async function ( ) {
85
- this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#multikey' ;
86
- assertBefore ( ) ;
87
- for ( const proof of proofs ) {
88
- expect ( proof . verificationMethod ) . to . exist ;
89
- expect ( proof . verificationMethod ) . to . be . a ( 'string' ) ;
90
- const didDoc = await didResolver ( { url : proof . verificationMethod } ) ;
91
- expect ( didDoc ) . to . be . an ( 'object' ) ;
92
- expect ( didDoc . publicKeyMultibase ) . to . be . a ( 'string' ) ;
33
+ // add implementer name and keyType to test report
34
+ this . implemented . push ( `${ name } : ${ keyType } ` ) ;
35
+ describe ( `${ name } : ${ keyType } ` , function ( ) {
36
+ let securedCredential = null ;
37
+ let proofs = [ ] ;
38
+ before ( async function ( ) {
39
+ securedCredential = await createInitialVc ( {
40
+ issuer,
41
+ vcVersion,
42
+ vc : credential ,
43
+ mandatoryPointers
44
+ } ) ;
45
+ if ( securedCredential ) {
46
+ proofs = Array . isArray ( securedCredential . proof ) ?
47
+ securedCredential ?. proof : [ securedCredential ?. proof ] ;
48
+ // only test proofs that match the relevant cryptosuite
49
+ proofs = proofs . filter ( p => p ?. cryptosuite === suiteName ) ;
50
+ }
51
+ } ) ;
52
+ beforeEach ( function ( ) {
53
+ this . currentTest . cell = {
54
+ rowId : this . currentTest . title ,
55
+ columnId : this . currentTest . parent . title
56
+ } ;
57
+ } ) ;
58
+ function assertBefore ( ) {
59
+ expect (
60
+ securedCredential ,
61
+ `Expected issuer ${ name } : ${ keyType } to issue a VC.`
62
+ ) . to . exist ;
93
63
expect (
94
- assertions . shouldBeBs58 ( didDoc . publicKeyMultibase ) ,
95
- 'Expected "publicKeyMultibase" to be Base58 encoded .'
96
- ) . to . be . true ;
64
+ securedCredential ,
65
+ 'Expected VC to be an object .'
66
+ ) . to . be . an ( 'object' ) ;
97
67
}
68
+ it ( 'The publicKeyMultibase value of the verification method MUST ' +
69
+ 'start with the base-58-btc prefix (z), as defined in the ' +
70
+ 'Multibase section of Controller Documents 1.0. ' ,
71
+ async function ( ) {
72
+ this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#data-model:~:text=The%20publicKeyMultibase%20value%20of%20the%20verification%20method%20MUST%20start%20with%20the%20base%2D58%2Dbtc%20prefix%20(z)%2C%20as%20defined%20in%20the%20Multibase%20section%20of%20Controller%20Documents%201.0.' ;
73
+ assertBefore ( ) ;
74
+ for ( const proof of proofs ) {
75
+ expect ( proof . verificationMethod ) . to . exist ;
76
+ expect ( proof . verificationMethod ) . to . be . a ( 'string' ) ;
77
+ const didDoc = await didResolver ( {
78
+ url : proof . verificationMethod } ) ;
79
+ expect ( didDoc ) . to . be . an ( 'object' ) ;
80
+ expect ( didDoc . publicKeyMultibase ) . to . be . a ( 'string' ) ;
81
+ expect (
82
+ assertions . shouldBeBs58 ( didDoc . publicKeyMultibase ) ,
83
+ 'Expected "publicKeyMultibase" to be Base58 encoded.'
84
+ ) . to . be . true ;
85
+ }
86
+ } ) ;
87
+ it ( 'Any other encoding MUST NOT be allowed. (verificationMethod)' ,
88
+ async function ( ) {
89
+ this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#multikey' ;
90
+ assertBefore ( ) ;
91
+ for ( const proof of proofs ) {
92
+ expect ( proof . verificationMethod ) . to . exist ;
93
+ expect ( proof . verificationMethod ) . to . be . a ( 'string' ) ;
94
+ const didDoc = await didResolver ( {
95
+ url : proof . verificationMethod } ) ;
96
+ expect ( didDoc ) . to . be . an ( 'object' ) ;
97
+ expect ( didDoc . publicKeyMultibase ) . to . be . a ( 'string' ) ;
98
+ expect (
99
+ assertions . shouldBeBs58 ( didDoc . publicKeyMultibase ) ,
100
+ 'Expected "publicKeyMultibase" to be Base58 encoded.'
101
+ ) . to . be . true ;
102
+ }
103
+ } ) ;
104
+ it ( 'The type property MUST be DataIntegrityProof.' ,
105
+ async function ( ) {
106
+ this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#multikey:~:text=The%20type%20property%20MUST%20be%20DataIntegrityProof.' ;
107
+ assertBefore ( ) ;
108
+ for ( const proof of proofs ) {
109
+ expect ( proof . type ) . to . exist ;
110
+ expect ( proof . type ) . to . be . a ( 'string' ) ;
111
+ expect ( proof . type ) . to . equal ( 'DataIntegrityProof' ) ;
112
+ }
113
+ } ) ;
114
+ it ( 'The cryptosuite property MUST be ecdsa-rdfc-2019, ' +
115
+ 'ecdsa-jcs-2019, or ecdsa-sd-2023.' , async function ( ) {
116
+ this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#multikey:~:text=The%20cryptosuite%20property%20MUST%20be%20ecdsa%2Drdfc%2D2019%2C%20ecdsa%2Djcs%2D2019%2C%20or%20ecdsa%2Dsd%2D2023.' ;
117
+ assertBefore ( ) ;
118
+ for ( const proof of proofs ) {
119
+ expect ( proof . cryptosuite ) . to . exist ;
120
+ expect ( proof . cryptosuite ) . to . be . a ( 'string' ) ;
121
+ expect ( proof . cryptosuite ) . to . be . oneOf (
122
+ [ 'ecdsa-rdfc-2019' , 'edcsa-jcs-2019' , 'ecdsa-sd-2023' ] ) ;
123
+ }
124
+ } ) ;
98
125
} ) ;
99
- it ( 'The type property MUST be DataIntegrityProof.' , async function ( ) {
100
- this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#multikey:~:text=The%20type%20property%20MUST%20be%20DataIntegrityProof.' ;
101
- assertBefore ( ) ;
102
- for ( const proof of proofs ) {
103
- expect ( proof . type ) . to . exist ;
104
- expect ( proof . type ) . to . be . a ( 'string' ) ;
105
- expect ( proof . type ) . to . equal ( 'DataIntegrityProof' ) ;
106
- }
107
- } ) ;
108
- it ( 'The cryptosuite property MUST be ecdsa-rdfc-2019, ' +
109
- 'ecdsa-jcs-2019, or ecdsa-sd-2023.' , async function ( ) {
110
- this . test . link = 'https://w3c.github.io/vc-di-ecdsa/#multikey:~:text=The%20cryptosuite%20property%20MUST%20be%20ecdsa%2Drdfc%2D2019%2C%20ecdsa%2Djcs%2D2019%2C%20or%20ecdsa%2Dsd%2D2023.' ;
111
- assertBefore ( ) ;
112
- for ( const proof of proofs ) {
113
- expect ( proof . cryptosuite ) . to . exist ;
114
- expect ( proof . cryptosuite ) . to . be . a ( 'string' ) ;
115
- expect ( proof . cryptosuite ) . to . be . oneOf (
116
- [ 'ecdsa-rdfc-2019' , 'edcsa-jcs-2019' , 'ecdsa-sd-2023' ] ) ;
117
- }
118
- } ) ;
119
- } ) ;
126
+ }
127
+ }
120
128
}
121
129
} ) ;
122
130
}
0 commit comments