Skip to content

Commit 1e8bcad

Browse files
committed
Fix didpeer test, fix did:peer:2 regex validation
Signed-off-by: Patrik Stas <[email protected]>
1 parent c63028c commit 1e8bcad

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

did_core/did_methods/did_peer/src/peer_did/numalgos/numalgo2/encoding.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,13 @@ mod tests {
136136
verification_method::{VerificationMethod, VerificationMethodType},
137137
};
138138
use did_parser::DidUrl;
139-
use did_resolver::traits::resolvable::resolution_output::DidResolutionOutput;
140139
use pretty_assertions::assert_eq;
141140

142141
use super::*;
143142
use crate::{
144143
helpers::convert_to_hashmap,
145144
peer_did::{numalgos::numalgo2::Numalgo2, PeerDid},
146-
resolver::{options::PublicKeyEncoding, PeerDidResolver},
145+
resolver::{options::PublicKeyEncoding},
147146
};
148147

149148
fn create_verification_method(
@@ -197,7 +196,7 @@ mod tests {
197196
.routing_keys(vec![ServiceKeyKind::Reference(
198197
"did:example:somemediator#somekey".parse().unwrap(),
199198
)])
200-
.accept(vec!["didcomm/aip2;env=rfc587".into()])
199+
.accept(vec!["didcomm/v2".into(), "didcomm/aip2;env=rfc587".into()])
201200
.build();
202201

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

216215
let did_parsed = PeerDid::<Numalgo2>::parse(did.clone()).unwrap();
217-
let DidResolutionOutput { did_document, .. } =
218-
PeerDidResolver::resolve_peerdid2(&did_parsed, PublicKeyEncoding::Base58)
219-
.await
220-
.unwrap();
216+
let ddo = did_parsed.to_did_doc(PublicKeyEncoding::Base58).unwrap();
221217

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

227-
assert_eq!(did_document, ddo_expected);
223+
assert_eq!(ddo, ddo_expected);
228224
assert_eq!(did, did_expected);
229225
}
230226

did_core/did_methods/did_peer/src/peer_did/numalgos/numalgo2/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ impl Numalgo for Numalgo2 {
5555
mod test {
5656
use did_doc::schema::did_doc::DidDocument;
5757
use serde_json::{from_value, json};
58+
use pretty_assertions::assert_eq;
5859

5960
use crate::{
6061
peer_did::{numalgos::numalgo2::Numalgo2, PeerDid},

did_core/did_methods/did_peer/src/peer_did/validate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::error::DidPeerError;
66

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

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

0 commit comments

Comments
 (0)