Skip to content

Commit

Permalink
Add VCDM tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
timothee-haudebourg committed Jul 8, 2024
1 parent 9a91841 commit 31fa720
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
25 changes: 25 additions & 0 deletions crates/claims/crates/vc/src/v1/syntax/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,28 @@ where
json.expand_with(ld, loader).await
}
}

#[cfg(test)]
mod tests {
use ssi_json_ld::{CompactJsonLd, ContextLoader, Expandable};

#[async_std::test]
async fn reject_undefined_type() {
let input = CompactJsonLd(json_syntax::json!({
"@context": [
"https://www.w3.org/2018/credentials/v1",
{ "@vocab": null }
],
"type": [
"VerifiableCredential",
"ExampleTestCredential"
],
"issuer": "did:example:issuer",
"credentialSubject": {
"id": "did:example:subject"
}
}));

assert!(input.expand(&ContextLoader::default()).await.is_err());
}
}
25 changes: 25 additions & 0 deletions crates/claims/crates/vc/src/v2/syntax/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,28 @@ where
json.expand_with(ld, loader).await
}
}

#[cfg(test)]
mod tests {
use ssi_json_ld::{CompactJsonLd, ContextLoader, Expandable};

#[async_std::test]
async fn reject_undefined_type() {
let input = CompactJsonLd(json_syntax::json!({
"@context": [
"https://www.w3.org/ns/credentials/v2",
{ "@vocab": null }
],
"type": [
"VerifiableCredential",
"ExampleTestCredential"
],
"issuer": "did:example:issuer",
"credentialSubject": {
"id": "did:example:subject"
}
}));

assert!(input.expand(&ContextLoader::default()).await.is_err());
}
}

0 comments on commit 31fa720

Please sign in to comment.