Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate of develop did resolution for did method did:web #38

Closed
francis-pouatcha opened this issue Sep 12, 2023 · 3 comments · Fixed by #52
Closed

Integrate of develop did resolution for did method did:web #38

francis-pouatcha opened this issue Sep 12, 2023 · 3 comments · Fixed by #52

Comments

@francis-pouatcha
Copy link
Member

francis-pouatcha commented Sep 12, 2023

Spec at https://w3c-ccg.github.io/did-method-web/

It can be implemented as a sub-module of the did-utils project

@francis-pouatcha francis-pouatcha converted this from a draft issue Sep 12, 2023
@francis-pouatcha francis-pouatcha moved this from Qualified to Ready for Dev in didcomm-mediator-rs Sep 13, 2023
@hugoib hugoib self-assigned this Sep 14, 2023
@francis-pouatcha
Copy link
Member Author

Simple path testing on an existing online server

There is a unit test in the code base just testing if the server is responding. Could be extended to test if document returned is a did server.

@IngridPuppet
Copy link
Collaborator

mod local;

use did_resolver::{
    did_parser::Did,
    traits::resolvable::{resolution_options::DidResolutionOptions, DidResolvable},
};
use did_resolver_web::resolution::resolver::DidWebResolver;

#[tokio::test]
async fn resolves_did_web_address() -> Result<(), Box<dyn std::error::Error>> {
    //! This test requires that a running instance of
    //! the server be accessible on the internet.

    // Read did:web address from local uncommitted file
    // since it is subject to frequent change
    use local::DID_ADDRESS as did;

    // Resolve via the universal resolver
    let resp = reqwest::get(format!("https://dev.uniresolver.io/1.0/identifiers/{did}"))
        .await?
        .json::<serde_json::Value>()
        .await?;

    // Extract DID document
    let diddoc = resp
        .get("didDocument")
        .expect("Missing didDocument property");

    assert_eq!(did, diddoc.get("id").unwrap());

    Ok(())
}

#[tokio::test]
async fn resolves_did_web_address_with_local_binding() {
    let did = Did::parse(format!("did:web:{}%3A{}", "localhost", "8090")).expect("did parse error");

    let did_web_resolver = DidWebResolver::http();
    let options = DidResolutionOptions::default();
    let result = did_web_resolver
        .resolve(&did, &options)
        .await
        .expect("resolution error");

    let diddoc = result.did_document();
    assert_eq!(&did, diddoc.id());
}

#[tokio::test]
async fn resolves_did_web_address_with_https_local_binding() {
    //! This test requires that a running instance of
    //! the server be accessible on the internet.

    // Read did:web address from local uncommitted file
    // since it is subject to frequent change
    use local::DID_ADDRESS;

    let did = Did::parse(DID_ADDRESS.to_string()).expect("did parse error");

    let did_web_resolver = DidWebResolver::https();
    let options = DidResolutionOptions::default();
    let result = did_web_resolver
        .resolve(&did, &options)
        .await
        .expect("resolution error");

    let diddoc = result.did_document();
    assert_eq!(&did, diddoc.id());
}

@IngridPuppet
Copy link
Collaborator

[package]
name = "somebank"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tokio = { version = "1.30.0", features = ["full"] }
axum = "0.6.20"
serde_json = "1.0.104"
chrono = "0.4.26"
tower-http = { version = "0.4.3", features = ["fs"] }
reqwest = { version = "0.11.18", features = ["blocking", "json"] }

# aries-vcx
did_resolver = { path = "../../aries-vcx/did_resolver" }
did_resolver_web = { path = "../../aries-vcx/did_resolver_web" }

@francis-pouatcha francis-pouatcha moved this from Ready for Dev to In Progress in didcomm-mediator-rs Sep 14, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in didcomm-mediator-rs Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants