Skip to content

Commit

Permalink
Test p256 and secp256k1 did:key in HTTP and CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
clehner committed Apr 8, 2021
1 parent 98452e5 commit 325a0e3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ use std::process::{Command, Stdio};

static BIN: &str = env!("CARGO_BIN_EXE_didkit");

const DID_KEY_K256: &'static str = "did:key:zQ3shokFTS3brHcDQrn82RUDfCZESWL1ZdCEJwekUDPQiYBme";
const DID_KEY_P256: &'static str = "did:key:zrurwcJZss4ruepVNu1H3xmSirvNbzgBk9qrCktB6kaewXnJAhYWwtP3bxACqBpzjZdN7TyHNzzGGSSH5qvZsSDir9z";

#[test]
fn generate_key() {
Command::new(BIN)
Expand Down Expand Up @@ -147,6 +150,20 @@ fn didkit_cli() {
assert_ne!(res_result["didDocumentMetadata"], Value::Null);
assert_eq!(res_result["didResolutionMetadata"]["error"], Value::Null);

// Resolve more DIDs
let resolve = Command::new(BIN)
.args(&["did-resolve", DID_KEY_K256])
.stderr(Stdio::inherit())
.output()
.unwrap();
assert!(resolve.status.success());
let resolve = Command::new(BIN)
.args(&["did-resolve", DID_KEY_P256])
.stderr(Stdio::inherit())
.output()
.unwrap();
assert!(resolve.status.success());

// Dereference a DID URL to a verification method
let deref = Command::new(BIN)
.args(&["did-dereference", "-m", &verification_method])
Expand Down
11 changes: 11 additions & 0 deletions http/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const DID_KEY_JSON: &'static str = include_str!("../../cli/tests/ed25519-key.jwk
const DID_KEY: &'static str = "did:key:z6MkiVpwA241guqtKWAkohHpcAry7S94QQb6ukW3GcCsugbK";
const VERIFICATION_METHOD: &'static str = "did:key:z6MkiVpwA241guqtKWAkohHpcAry7S94QQb6ukW3GcCsugbK#z6MkiVpwA241guqtKWAkohHpcAry7S94QQb6ukW3GcCsugbK";

const DID_KEY_K256: &'static str = "did:key:zQ3shokFTS3brHcDQrn82RUDfCZESWL1ZdCEJwekUDPQiYBme";
const DID_KEY_P256: &'static str = "did:key:zrurwcJZss4ruepVNu1H3xmSirvNbzgBk9qrCktB6kaewXnJAhYWwtP3bxACqBpzjZdN7TyHNzzGGSSH5qvZsSDir9z";

const ISSUE_CRED_REQ: &str = r#"{
"credential": {
"@context": "https://www.w3.org/2018/credentials/v1",
Expand Down Expand Up @@ -354,6 +357,14 @@ async fn resolve_dereference() {
assert_eq!(res_meta.content_type.unwrap(), TYPE_DID_LD_JSON);
assert_eq!(http_content_type, TYPE_DID_RESOLUTION);

// Resolve more DIDs
let uri = Uri::from_str(&format!("{}/identifiers/{}", base, DID_KEY_K256)).unwrap();
let resp = client.get(uri).await.unwrap();
assert_eq!(resp.status(), 200);
let uri = Uri::from_str(&format!("{}/identifiers/{}", base, DID_KEY_P256)).unwrap();
let resp = client.get(uri).await.unwrap();
assert_eq!(resp.status(), 200);

// Dereference DID URL
let uri_string = format!(
"{}/identifiers/{}",
Expand Down

0 comments on commit 325a0e3

Please sign in to comment.