Skip to content

Commit

Permalink
test(dataverse): add data integrity & ecdsa related cases
Browse files Browse the repository at this point in the history
  • Loading branch information
amimart committed Feb 9, 2024
1 parent 84bb4a6 commit 7b475f5
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
22 changes: 15 additions & 7 deletions contracts/okp4-dataverse/src/credential/vc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ mod test {

#[test]
fn proper_vc_from_dataset() {
let owned_quads = testutil::read_test_quads("vc-ok-unsecured.nq");
let owned_quads = testutil::read_test_quads("vc-eddsa-2020-ok-unsecured.nq");
let unsecure_dataset = Dataset::from(owned_quads.as_slice());

let owned_quads = testutil::read_test_quads("vc-ok.nq");
let owned_quads = testutil::read_test_quads("vc-eddsa-2020-ok.nq");
let dataset = Dataset::from(owned_quads.as_slice());

let vc_res = VerifiableCredential::try_from(&dataset);
Expand Down Expand Up @@ -336,11 +336,19 @@ mod test {

#[test]
fn vc_verify() {
let cases = vec![
"vc-eddsa-2020-ok.nq",
"vc-ecdsa-2019-ok.nq",
"vc-di-ed-ok.nq",
];
let mut deps = mock_dependencies();
let owned_quads = testutil::read_test_quads("vc-ok.nq");
let dataset = Dataset::from(owned_quads.as_slice());
let vc = VerifiableCredential::try_from(&dataset).unwrap();
let verif_res = vc.verify(deps.as_mut());
assert!(verif_res.is_ok());

for case in cases {
let owned_quads = testutil::read_test_quads(case);
let dataset = Dataset::from(owned_quads.as_slice());
let vc = VerifiableCredential::try_from(&dataset).unwrap();
let verif_res = vc.verify(deps.as_mut());
assert!(verif_res.is_ok());
}
}
}
11 changes: 11 additions & 0 deletions contracts/okp4-dataverse/testdata/vc-di-ed-ok.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<http://example.edu/credentials/58473> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2018/credentials#VerifiableCredential> .
<http://example.edu/credentials/58473> <https://w3id.org/security#proof> _:b0 .
<http://example.edu/credentials/58473> <https://www.w3.org/2018/credentials#credentialSubject> <did:key:z6MkpwdnLPAm4apwcrRYQ6fZ3rAcqjLZR4AMk14vimfnozqY> .
<http://example.edu/credentials/58473> <https://www.w3.org/2018/credentials#issuanceDate> "2023-05-01T06:09:10Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://example.edu/credentials/58473> <https://www.w3.org/2018/credentials#issuer> <did:key:z6MkpwdnLPAm4apwcrRYQ6fZ3rAcqjLZR4AMk14vimfnozqY> .
_:b1 <http://purl.org/dc/terms/created> "2024-02-07T13:24:37.636307Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> _:b0 .
_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/security#DataIntegrityProof> _:b0 .
_:b1 <https://w3id.org/security#cryptosuite> "eddsa-2022" _:b0 .
_:b1 <https://w3id.org/security#proofPurpose> <https://w3id.org/security#assertionMethod> _:b0 .
_:b1 <https://w3id.org/security#proofValue> "z4JEgstWKYH2UxQK7VA6tYumr9XpEYUr66FdW4BtbbMBfxo3khn3ueHTAEL6c7EL9FU1pecZ471PkuRNSwHtNx7dz"^^<https://w3id.org/security#multibase> _:b0 .
_:b1 <https://w3id.org/security#verificationMethod> <did:key:z6MkpwdnLPAm4apwcrRYQ6fZ3rAcqjLZR4AMk14vimfnozqY#z6MkpwdnLPAm4apwcrRYQ6fZ3rAcqjLZR4AMk14vimfnozqY> _:b0 .
10 changes: 10 additions & 0 deletions contracts/okp4-dataverse/testdata/vc-ecdsa-2019-ok.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<http://example.edu/credentials/58473> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://www.w3.org/2018/credentials#VerifiableCredential> .
<http://example.edu/credentials/58473> <https://w3id.org/security#proof> _:b0 .
<http://example.edu/credentials/58473> <https://www.w3.org/2018/credentials#credentialSubject> <did:key:zQ3shofi77hSewXdJWj5VsdS5spLrY5EZevwWN1t5adqBM8vM> .
<http://example.edu/credentials/58473> <https://www.w3.org/2018/credentials#issuanceDate> "2023-05-01T06:09:10Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> .
<http://example.edu/credentials/58473> <https://www.w3.org/2018/credentials#issuer> <did:key:zQ3shofi77hSewXdJWj5VsdS5spLrY5EZevwWN1t5adqBM8vM> .
_:b1 <http://purl.org/dc/terms/created> "2024-02-08T17:44:07.477489Z"^^<http://www.w3.org/2001/XMLSchema#dateTime> _:b0 .
_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <https://w3id.org/security#EcdsaSecp256k1Signature2019> _:b0 .
_:b1 <https://w3id.org/security#jws> "eyJhbGciOiJFUzI1NksiLCJjcml0IjpbImI2NCJdLCJiNjQiOmZhbHNlfQ..Zhj537ApzBdQqfMKe2J9-I6CiNKzY6O2MZMrGwA2KZxMBSt81ExQJm2AKfX39OzeLn_gkP9Gmn_Bb_Yz2jFgtA" _:b0 .
_:b1 <https://w3id.org/security#proofPurpose> <https://w3id.org/security#assertionMethod> _:b0 .
_:b1 <https://w3id.org/security#verificationMethod> <did:key:zQ3shofi77hSewXdJWj5VsdS5spLrY5EZevwWN1t5adqBM8vM#zQ3shofi77hSewXdJWj5VsdS5spLrY5EZevwWN1t5adqBM8vM> _:b0 .
File renamed without changes.

0 comments on commit 7b475f5

Please sign in to comment.