22import pytest
33
44from acapy_agent .resolver .did_resolver import DIDResolver
5+ from ...resolver .tests .test_did_resolver import MockResolver
56
67from ...did .did_key import DIDKey
78from ...utils .testing import create_test_profile
1213TEST_DID_SOV = "did:sov:LjgpST2rjsoxYegQDRm7EL"
1314TEST_DID_KEY = "did:key:z6Mkgg342Ycpuk263R9d8Aq6MUaxPn1DDeHyGo38EefXmgDL"
1415
15-
1616class TestDefaultVerificationKeyStrategy (IsolatedAsyncioTestCase ):
1717 async def asyncSetUp (self ) -> None :
1818 self .profile = await create_test_profile ()
1919 resolver = DIDResolver ()
20+ resolver .register_resolver (
21+ MockResolver (
22+ ["example" ],
23+ resolved = {
24+ "@context" : [
25+ "https://www.w3.org/ns/did/v1" ,
26+ "https://w3id.org/security/multikey/v1" ,
27+ ],
28+ "id" : "did:example:123" ,
29+ "verificationMethod" : [
30+ {
31+ "id" : "did:example:123#key-1" ,
32+ "type" : "Multikey" ,
33+ "controller" : "did:example:123" ,
34+ "publicKeyMultibase" : "z6MkjYXizfaAXTriV3h2Vc9uxJ9AMQpfG7mE1WKMnn1KJvFE" ,
35+ },
36+ {
37+ "id" : "did:example:123#key-2" ,
38+ "type" : "Multikey" ,
39+ "controller" : "did:example:123" ,
40+ "publicKeyMultibase" : "z6MkjYXizfaAXTriV3h2Vc9uxJ9AMQpfG7mE1WKMnn1KJvFE" ,
41+ },
42+ {
43+ "id" : "did:example:123#key-3" ,
44+ "type" : "Ed25519VerificationKey2018" ,
45+ "controller" : "did:example:123" ,
46+ "publicKeyBase58" : "66GgQRKjBvNFNYrKp3C57CbAXqYorEWsKVQRxW3JPhTr" ,
47+ },
48+ ],
49+ "authentication" : ["did:example:123#key-1" ],
50+ "assertionMethod" : ["did:example:123#key-2" , "did:example:123#key-3" ],
51+ }
52+ )
53+ )
2054 self .profile .context .injector .bind_instance (DIDResolver , resolver )
2155
2256 async def test_with_did_sov (self ):
@@ -32,6 +66,27 @@ async def test_with_did_key(self):
3266 await strategy .get_verification_method_id_for_did (TEST_DID_KEY , self .profile )
3367 == DIDKey .from_did (TEST_DID_KEY ).key_id
3468 )
69+
70+ async def test_with_did_for_assertion (self ):
71+ strategy = DefaultVerificationKeyStrategy ()
72+ assert (
73+ await strategy .get_verification_method_id_for_did (
74+ "did:example:123" ,
75+ self .profile ,
76+ proof_type = "Ed25519Signature2020" ,
77+ proof_purpose = "assertionMethod"
78+ )
79+ == "did:example:123#key-2"
80+ )
81+ assert (
82+ await strategy .get_verification_method_id_for_did (
83+ "did:example:123" ,
84+ self .profile ,
85+ proof_type = "Ed25519Signature2018" ,
86+ proof_purpose = "assertionMethod"
87+ )
88+ == "did:example:123#key-3"
89+ )
3590
3691 async def test_unsupported_did_method (self ):
3792 strategy = DefaultVerificationKeyStrategy ()
0 commit comments