Skip to content

Commit

Permalink
Fix didpeer test, fix did:peer:2 regex validation
Browse files Browse the repository at this point in the history
Signed-off-by: Patrik Stas <patrik.stas@absa.africa>
  • Loading branch information
Patrik-Stas committed Jan 8, 2024
1 parent c63028c commit 5f29bb8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ mod tests {
.routing_keys(vec![ServiceKeyKind::Reference(
"did:example:somemediator#somekey".parse().unwrap(),
)])
.accept(vec!["didcomm/aip2;env=rfc587".into()])
.accept(vec!["didcomm/v2".into(), "didcomm/aip2;env=rfc587".into()])
.build();

let service = Service::new(
Expand All @@ -214,17 +214,14 @@ mod tests {
let did = append_encoded_service_segment(did.to_string(), &did_document).unwrap();

let did_parsed = PeerDid::<Numalgo2>::parse(did.clone()).unwrap();
let DidResolutionOutput { did_document, .. } =
PeerDidResolver::resolve_peerdid2(&did_parsed, PublicKeyEncoding::Base58)
.await
.unwrap();
let ddo = did_parsed.to_did_doc(PublicKeyEncoding::Base58).unwrap();

let did_expected_parsed = PeerDid::<Numalgo2>::parse(did_expected.clone()).unwrap();
let ddo_expected = did_expected_parsed
.to_did_doc(PublicKeyEncoding::Base58)
.unwrap();

assert_eq!(did_document, ddo_expected);
assert_eq!(ddo, ddo_expected);
assert_eq!(did, did_expected);
}

Expand Down
2 changes: 1 addition & 1 deletion did_core/did_methods/did_peer/src/peer_did/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::error::DidPeerError;

static GROUP_NUMALGO_0_AND_1: &str = r"([01](z)([1-9a-km-zA-HJ-NP-Z]{5,200}))";
static GROUP_NUMALGO_2: &str =
r"(2((.[AEVID](z)([1-9a-km-zA-HJ-NP-Z]{5,200}))+(.(S)[0-9a-zA-Z=]*)?))";
r"(2((.[AEVID](z)([1-9a-km-zA-HJ-NP-Z]{5,200}))?(.(S)[0-9a-zA-Z=]*)?))";
static GROUP_NUMALGO_3: &str = r"(3\.[0-9a-fA-F]{64})";

pub static PEER_DID_REGEX: Lazy<Regex> = Lazy::new(|| {
Expand Down

0 comments on commit 5f29bb8

Please sign in to comment.