-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Indicio-tech/test/initial-testing-round
Test/initial testing round
- Loading branch information
Showing
4 changed files
with
141 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import pytest | ||
|
||
from didcomm_messaging.resolver import ( | ||
DIDMethodNotSupported, | ||
DIDResolver, | ||
PrefixResolver, | ||
) | ||
|
||
|
||
class TestResolver(DIDResolver): | ||
async def resolve(self, did: str) -> dict: | ||
return {"did": did} | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def test_resolver(): | ||
yield TestResolver() | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_prefix_resolver(test_resolver: DIDResolver): | ||
did = "did:test:example_did" | ||
|
||
resolver = PrefixResolver(resolvers={"did:test:": test_resolver}) | ||
|
||
doc = await resolver.resolve(did) | ||
assert doc["did"] == did | ||
|
||
with pytest.raises(DIDMethodNotSupported): | ||
await resolver.resolve("This won't work") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import pytest | ||
from didcomm_messaging.crypto import SecretKey | ||
|
||
from didcomm_messaging.crypto.backend.basic import InMemorySecretsManager | ||
|
||
|
||
class MockSecretKey(SecretKey): | ||
def __init__(self, kid) -> None: | ||
self._kid = kid | ||
|
||
@property | ||
def kid(self): | ||
return self._kid | ||
|
||
|
||
@pytest.fixture() | ||
def in_memory_secrets_manager(): | ||
yield InMemorySecretsManager() | ||
|
||
|
||
@pytest.fixture() | ||
def secret(): | ||
kid = "did:example:alice#key-1" | ||
key = MockSecretKey(kid=kid) | ||
yield key | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_in_memory_secrets( | ||
in_memory_secrets_manager: InMemorySecretsManager, secret: MockSecretKey | ||
): | ||
await in_memory_secrets_manager.add_secret(secret) | ||
|
||
assert await in_memory_secrets_manager.get_secret_by_kid(secret.kid) == secret |