-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
166 Integrate VC Data Model Spec Test Suite (#167)
1. Refactored `Credential`, `Presentation` & `VerifiablePresentation` structs in SSI to support full flexibility required by the VC Data Model 2. Integrated vc test suite spec tests and added it as a GH Action on every PR
- Loading branch information
Showing
12 changed files
with
628 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: VC Model Spec Test | ||
# Tests the VC Model Spec against the vc-test-suite - https://github.com/w3c/vc-test-suite | ||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Cache Rust dependencies | ||
uses: Swatinem/rust-cache@v2 | ||
|
||
- name: Install Protoc and cargo-make | ||
run: ./container/deps.sh protoc cargo-make | ||
|
||
- uses: knox-networks/github-actions-public/.github/actions/setup-protofetch@main | ||
with: | ||
cross-repo-username: "developersKnox" | ||
cross-repo-token: ${{ secrets.PROTOFETCH_GITHUB_TOKEN }} | ||
|
||
- name: Test protos | ||
run: (cd registry_resolver; protofetch fetch) && git diff --exit-code | ||
|
||
- name: Build CLI | ||
run: cargo build --package cli --release | ||
|
||
- name: Add CLI to bin | ||
run: sudo cp $PWD/target/release/ssi_cli /bin/ssi_cli | ||
|
||
- name: Install Node & NPM | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "20" | ||
|
||
- name: Clone & Install vc-test-suite | ||
run: | | ||
git clone https://github.com/knox-networks/vc-test-suite | ||
cd vc-test-suite | ||
npm install | ||
- name: Copy vc-test-suite config | ||
run: cp tests/vc_model_spec_test/config.json vc-test-suite/config.json | ||
|
||
- name: Run vc-test-suite | ||
run: | | ||
cd vc-test-suite | ||
npm run test |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,8 @@ members = [ | |
"signature", | ||
"ssi", | ||
"ephemeral_resolver", | ||
"ffi" | ||
"ffi", | ||
"cli", | ||
] | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[package] | ||
name = "cli" | ||
version.workspace = true | ||
edition.workspace = true | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clap = {version = "4.4.8", features = ["derive"]} | ||
ssi = {path = "../ssi"} | ||
|
||
# binary definition | ||
[[bin]] | ||
name = "ssi_cli" | ||
path = "src/main.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::str::FromStr; | ||
|
||
use clap::{command, Parser, Subcommand}; | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(author, version, about, long_about = None)] | ||
#[command(propagate_version = true)] | ||
struct CliArguments { | ||
#[command(subcommand)] | ||
command: Command, | ||
} | ||
|
||
#[derive(Subcommand, Debug)] | ||
enum Command { | ||
/// Read the JSON string file in input_file and parse it into a VerifiableCredential. Then prints the VerifiableCredential | ||
TestIssueCredential { | ||
#[arg(short, long)] | ||
input_file: String, | ||
}, | ||
/// Read the JSON string file in input_file and parse it into a VerifiablePresentation. Then prints the VerifiablePresentation | ||
TestIssuePresentation { | ||
#[arg(short, long)] | ||
input_file: String, | ||
}, | ||
} | ||
|
||
fn main() { | ||
let args = CliArguments::parse(); | ||
match args.command { | ||
Command::TestIssueCredential { | ||
input_file: input_file_path, | ||
} => { | ||
let input = std::fs::read_to_string(input_file_path).unwrap(); | ||
let vc = ssi::credential::VerifiableCredential::from_str(&input).unwrap(); | ||
println!("{}", vc); | ||
} | ||
Command::TestIssuePresentation { | ||
input_file: input_file_path, | ||
} => { | ||
let input = std::fs::read_to_string(input_file_path).unwrap(); | ||
let vc = ssi::credential::VerifiablePresentation::from_str(&input).unwrap(); | ||
println!("{}", vc); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.