Skip to content

Commit

Permalink
Move test and make it more focused
Browse files Browse the repository at this point in the history
  • Loading branch information
sbihel committed Dec 19, 2024
1 parent 87adaf9 commit 3489df1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 81 deletions.
19 changes: 19 additions & 0 deletions crates/claims/crates/data-integrity/src/core_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use super::*;

#[test]
fn single_domain_de_serialization() {
let json_proof = serde_json::json!(
{
"type": "DataIntegrityProof",
"cryptosuite": "ecdsa-rdfc-2019",
"created": "2024-12-18T10:31:42.962679Z",
"verificationMethod": "did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IndPTjRDTmlHX1BxaWl1R0JEbnpRa1lqVG9jaDJnaTRBTHluWVIwdnN1c0kiLCJ5Ijoia2JlZ25iRzUxZHFETW9wdHgtOVIxcmpIU1B6TkhYLWdQbnFhbWJ6a1pzNCJ9#0",
"proofPurpose": "authentication",
"domain": "https://qa.veresexchanger.dev/exchangers/z19vRLNoFaBKDeDaMzRjUj8hi/exchanges/z19jYTCujFf4b6JFdCNMTXJ3s/openid/client/authorization/response",
"challenge": "z19jYTCujFf4b6JFdCNMTXJ3s",
"proofValue": "z3H5Bi3cF6BGEgoWdAqp13gQHEibVGtNtVbJECwfQStGmBio1gmjHrq2TGtjJ3L18pd1pKCsb4Pos9oMDpginN68h"
}
);
let proof: Proof<AnySuite> = serde_json::from_value(json_proof.clone()).expect("Could not deserialize");
assert_eq!(json_proof, serde_json::to_value(&proof).unwrap());
}
3 changes: 3 additions & 0 deletions crates/claims/crates/data-integrity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ pub use ssi_data_integrity_suites as suites;
mod any;
pub use any::*;

#[cfg(test)]
mod core_tests;

/// Any Data-Integrity proof known by this library.
pub type AnyProof = Proof<AnySuite>;

Expand Down
81 changes: 0 additions & 81 deletions crates/claims/crates/vc/src/v2/syntax/presentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,84 +162,3 @@ where
json.expand_with(ld, loader).await
}
}

#[cfg(test)]
mod test {
use ssi_data_integrity::{AnySuite, DataIntegrity};

use super::*;

#[test]
fn deserialize_single_domain() {
let _: DataIntegrity<JsonPresentation, AnySuite> = serde_json::from_value(serde_json::json!(
{
"@context": [
"https://www.w3.org/ns/credentials/v2"
],
"id": "urn:uuid:e6f93061-dcac-46a0-8aba-9d6278e2ada1",
"type": [
"VerifiablePresentation"
],
"holder": "did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IndPTjRDTmlHX1BxaWl1R0JEbnpRa1lqVG9jaDJnaTRBTHluWVIwdnN1c0kiLCJ5Ijoia2JlZ25iRzUxZHFETW9wdHgtOVIxcmpIU1B6TkhYLWdQbnFhbWJ6a1pzNCJ9",
"verifiableCredential": {
"@context": [
"https://www.w3.org/ns/credentials/v2",
"https://examples.vcplayground.org/contexts/movie-ticket-vcdm-v2/v1.json"
],
"id": "urn:uuid:df7bbd25-6f01-46dc-b65c-c483a7841739",
"type": [
"VerifiableCredential",
"MovieTicketCredential"
],
"credentialSubject": {
"id": "did:example:b34AA2I0ZdwAACBDu",
"owns": {
"location": {
"address": {
"addressLocality": "Your Town",
"addressRegion": "VA",
"postalCode": "24060",
"streetAddress": "123 Main St."
},
"name": "Hometown Theatres, Inc."
},
"startDate": "2022-08-26T19:00:00.000Z",
"ticketNumber": "457812",
"ticketToken": "urn:1a1e549a-2867",
"ticketedSeat": {
"seatNumber": "11",
"seatRow": "E",
"seatSection": "Theatre 3"
},
"type": "Ticket"
}
},
"issuer": {
"id": "did:key:zDnaerPmH7xAjZoWanUBkRzY6xi9aTywRRoyAaHyRAsAYHCRq",
"name": "Hometown Theatres, Inc."
},
"description": "Admit one: Plan 9 from Outer Space, 3pm showing.",
"image": "data:image/png;base64,iVBO...",
"proof": {
"created": "2024-12-18T09:55:11Z",
"cryptosuite": "ecdsa-rdfc-2019",
"proofPurpose": "assertionMethod",
"proofValue": "znvWgrZtpc9aqGRhyCnf22WLddL6L1rGA1CRPEBPWRbw7sKUCC1DrC2GrASDEyA5W3C3DCV3p4zZg6Zp4sYSKduT",
"type": "DataIntegrityProof",
"verificationMethod": "did:key:zDnaerPmH7xAjZoWanUBkRzY6xi9aTywRRoyAaHyRAsAYHCRq#zDnaerPmH7xAjZoWanUBkRzY6xi9aTywRRoyAaHyRAsAYHCRq"
}
},
"proof": {
"type": "DataIntegrityProof",
"cryptosuite": "ecdsa-rdfc-2019",
"created": "2024-12-18T10:31:42.962679Z",
"verificationMethod": "did:jwk:eyJjcnYiOiJQLTI1NiIsImt0eSI6IkVDIiwieCI6IndPTjRDTmlHX1BxaWl1R0JEbnpRa1lqVG9jaDJnaTRBTHluWVIwdnN1c0kiLCJ5Ijoia2JlZ25iRzUxZHFETW9wdHgtOVIxcmpIU1B6TkhYLWdQbnFhbWJ6a1pzNCJ9#0",
"proofPurpose": "authentication",
"domain": "https://qa.veresexchanger.dev/exchangers/z19vRLNoFaBKDeDaMzRjUj8hi/exchanges/z19jYTCujFf4b6JFdCNMTXJ3s/openid/client/authorization/response",
"challenge": "z19jYTCujFf4b6JFdCNMTXJ3s",
"proofValue": "z3H5Bi3cF6BGEgoWdAqp13gQHEibVGtNtVbJECwfQStGmBio1gmjHrq2TGtjJ3L18pd1pKCsb4Pos9oMDpginN68h"
}
}
)).expect("Could not deserialize");
}
}

0 comments on commit 3489df1

Please sign in to comment.