Skip to content

Commit

Permalink
Update VC API test suites and setup and add failing test to rust
Browse files Browse the repository at this point in the history
  • Loading branch information
sbihel committed Jun 1, 2024
1 parent f65dc24 commit 57a9414
Show file tree
Hide file tree
Showing 12 changed files with 153 additions and 45 deletions.
12 changes: 4 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
# di-ed25519-test-suite fails one test because issuer != proof VM
# did-key-test-suite requires more checks in ssi
# di-eddsa-2022-test-suite passes but currently it's depending on a (npm) git branch that doesn't exist anymore
suite: ["vc-api-issuer-test-suite", "vc-api-verifier-test-suite"] # "di-eddsa-2022-test-suite", "di-ed25519-test-suite", "did-key-test-suite"]
suite: ["vc-api-issuer-test-suite", "vc-api-verifier-test-suite", "vc-di-eddsa-test-suite", "vc-di-ed25519-suite", "did-key-test-suite", "vc-data-model-2.0-test-suite"]
steps:
- name: Checkout DIDKit repository
uses: actions/checkout@v4
Expand All @@ -154,7 +151,7 @@ jobs:
shared-key: "vc-api"
- uses: actions/setup-node@v4
with:
node-version: 16
node-version: 18
- name: Start VC API
run: |
cd http
Expand All @@ -166,12 +163,11 @@ jobs:
run: |
cd http/tests/${{ matrix.suite }}
npm i
rm node_modules/vc-api-test-suite-implementations/implementations/*.json
ln ../vcApiTestImplementationsConfig.cjs .vcApiTestImplementationsConfig.cjs
ln ../localConfig.cjs localConfig.cjs
- name: Run Test Suite
run: |
cd http/tests/${{ matrix.suite }}
ISSUER_NAME="Spruce" KEY_SEED_DB=z1Aaj5A4UCsdMpXwdYAReXa4bxWYiKJtdAvB1zMzCHtCbtD npm test
npm test
build_ios:
runs-on: macos-latest
Expand Down
15 changes: 9 additions & 6 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[submodule "http/tests/di-ed25519-test-suite"]
path = http/tests/di-ed25519-test-suite
url = https://github.com/w3c-ccg/di-ed25519-test-suite.git
[submodule "http/tests/vc-api-issuer-test-suite"]
path = http/tests/vc-api-issuer-test-suite
url = https://github.com/w3c-ccg/vc-api-issuer-test-suite.git
Expand All @@ -10,6 +7,12 @@
[submodule "http/tests/did-key-test-suite"]
path = http/tests/did-key-test-suite
url = https://github.com/w3c-ccg/did-key-test-suite.git
[submodule "http/tests/di-eddsa-2022-test-suite"]
path = http/tests/di-eddsa-2022-test-suite
url = https://github.com/w3c-ccg/di-eddsa-2022-test-suite.git
[submodule "http/tests/vc-data-model-2.0-test-suite"]
path = http/tests/vc-data-model-2.0-test-suite
url = https://github.com/w3c/vc-data-model-2.0-test-suite.git
[submodule "http/tests/vc-di-ed25519signature2020-test-suite"]
path = http/tests/vc-di-ed25519signature2020-test-suite
url = https://github.com/w3c/vc-di-ed25519signature2020-test-suite.git
[submodule "http/tests/vc-di-eddsa-test-suite"]
path = http/tests/vc-di-eddsa-test-suite
url = https://github.com/w3c/vc-di-eddsa-test-suite.git
85 changes: 85 additions & 0 deletions http/src/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,89 @@ mod test {

let _ = issue(Extension(keys), CustomErrorJson(req)).await.unwrap();
}

#[test]
fn deserialize_body_issuer_test_suite() {
let _: IssueRequest = serde_json::from_value(json!({
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1"
],
"type": [
"VerifiableCredential"
],
"credentialSubject": {
"id": "did:key:z6MkhTNL7i2etLerDK8Acz5t528giE5KA4p75T6ka1E1D74r"
},
"issuanceDate": "2024-06-01T09:09:48Z",
"id": "urn:uuid:7a6cafb9-11c3-41a8-98d8-8b5a45c2548f",
"issuer": "did:key:z6MkgYAGxLBSXa6Ygk1PnUbK2F7zya8juE9nfsZhrvY7c9GD"
},
"options": {
"type": "Ed25519Signature2020"
}
}
))
.unwrap();
}

#[tokio::test]
async fn validate_valid_vc_verifier_test_suite() {
let req = serde_json::from_value(json!({
"verifiableCredential": {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/security/suites/ed25519-2020/v1"
],
"id": "urn:uuid:0c71c76a-5dca-4537-a86d-7851b8f85c25",
"type": [
"VerifiableCredential"
],
"credentialSubject": {
"id": "did:key:z6MkhTNL7i2etLerDK8Acz5t528giE5KA4p75T6ka1E1D74r"
},
"issuer": "did:key:z6MkgND5U5Kedizov5nxeh2ZCVUTDRSmAfbNqPhzCq8b72Ra",
"issuanceDate": "2024-06-01T09:34:12.834Z",
"proof": {
"type": "Ed25519Signature2020",
"proofPurpose": "assertionMethod",
"proofValue": "zB6pd365FSMVZbkn51nhEtLCyuxLj5qGFaZi6uv1dweLUiR1qvCqM1cqaAFMgjyB5ZATvU2brPDn6z6XwxoFyeHD",
"verificationMethod": "did:key:z6MkgND5U5Kedizov5nxeh2ZCVUTDRSmAfbNqPhzCq8b72Ra#z6MkgND5U5Kedizov5nxeh2ZCVUTDRSmAfbNqPhzCq8b72Ra",
"created": "2024-06-01T09:34:12.834Z"
}
},
"options": {
"checks": [
"proof"
]
}
})).unwrap();
let _ = verify(CustomErrorJson(req)).await.unwrap();
}

#[tokio::test]
async fn issue_valid_di_eddsa_test_suite() {
let keys = default_keys();
let req = serde_json::from_value(json!({
"credential": {
"@context": [
"https://www.w3.org/2018/credentials/v1"
],
"id": "urn:uuid:991721d2-2336-4979-aa10-1709061b7261",
"type": [
"VerifiableCredential"
],
"issuer": "did:key:z6MkgYAGxLBSXa6Ygk1PnUbK2F7zya8juE9nfsZhrvY7c9GD",
"issuanceDate": "2020-03-16T22:37:26.544Z",
"credentialSubject": {
"id": "did:key:z6MktKwz7Ge1Yxzr4JHavN33wiwa8y81QdcMRLXQsrH9T53b"
}
},
"options": {
"type": "DataIntegrityProof"
}
}))
.unwrap();
let _ = issue(Extension(keys), CustomErrorJson(req)).await.unwrap();
}
}
2 changes: 2 additions & 0 deletions http/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use axum::{
};
use axum_extra::headers::Header;
use serde::{Deserialize, Serialize};
use tracing::debug;

pub struct CustomErrorJson<T>(pub T);

Expand Down Expand Up @@ -35,6 +36,7 @@ where
} else {
rejection.status()
};
debug!("JSON rejection: {message}");
Err((code, message))
}
}
Expand Down
1 change: 0 additions & 1 deletion http/tests/di-ed25519-test-suite
Submodule di-ed25519-test-suite deleted from f627dc
1 change: 0 additions & 1 deletion http/tests/di-eddsa-2022-test-suite
Submodule di-eddsa-2022-test-suite deleted from 53f05d
49 changes: 49 additions & 0 deletions http/tests/localConfig.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
module.exports = {
settings: {
// don't test live implementations
enableInteropTests: false,
testAllImplementations: false
},
implementations: [{
"name": "Spruce",
"implementation": "Spruce",
"issuers": [{
"id": "did:key:z6MkgYAGxLBSXa6Ygk1PnUbK2F7zya8juE9nfsZhrvY7c9GD",
"endpoint": "https://127.0.0.1:9000/credentials/issue",
"options": {
"type": "Ed25519Signature2020"
},
"supports": {
"vc": ['1.1', '2.0']
},
"tags": ["vc-api", "Ed25519Signature2020", "JWT", "vc2.0"]
}, {
"id": "did:key:z6MkgYAGxLBSXa6Ygk1PnUbK2F7zya8juE9nfsZhrvY7c9GD",
"endpoint": "https://127.0.0.1:9000/credentials/issue",
"options": {
"type": "DataIntegrityProof"
},
"supports": {
"vc": ['1.1', '2.0']
},
"tags": ["vc-api", "eddsa-rdfc-2022", "eddsa-jcs-2022", "JWT", "vc2.0"]
}],
"verifiers": [{
"id": "https://spruceid.com",
"endpoint": "https://127.0.0.1:9000/credentials/verify",
"supportedEcdsaKeyTypes": ["P-256"],
"tags": ["vc-api", "Ed25519Signature2020", "JWT", "eddsa-rdfc-2022", "eddsa-jcs-2022", "vc2.0"]
}],
"vpVerifiers": [{
"id": "https://spruceid.com",
"endpoint": "https://127.0.0.1:9000/presentations/verify",
"supportedEcdsaKeyTypes": ["P-256"],
"tags": ["vc-api", "Ed25519Signature2020", "JWT", "eddsa-rdfc-2022", "eddsa-jcs-2022", "vc2.0"]
}],
"didResolvers": [{
"id": "https://spruceid.com",
"endpoint": "https://127.0.0.1:9000/identifiers",
"tags": ["did-key"]
}]
}]
};
1 change: 1 addition & 0 deletions http/tests/vc-data-model-2.0-test-suite
1 change: 1 addition & 0 deletions http/tests/vc-di-ecdsa-test-suite
Submodule vc-di-ecdsa-test-suite added at da5425
1 change: 1 addition & 0 deletions http/tests/vc-di-ed25519signature2020-test-suite
1 change: 1 addition & 0 deletions http/tests/vc-di-eddsa-test-suite
Submodule vc-di-eddsa-test-suite added at 5de612
29 changes: 0 additions & 29 deletions http/tests/vcApiTestImplementationsConfig.cjs

This file was deleted.

0 comments on commit 57a9414

Please sign in to comment.