Skip to content

Commit

Permalink
Small update
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <jamiehalebc@gmail.com>
  • Loading branch information
jamshale committed Feb 24, 2025
1 parent 079fa6f commit fd4a51b
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 52 deletions.
1 change: 0 additions & 1 deletion webvh/integration/tests/test_register_did.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ async def test_create_with_witness_and_manual_attest():
entry = response.get("results", []).pop()
assert isinstance(entry, dict)

print(entry)
await witness.post(
"/did/webvh/witness/attest",
params=params(entry_id=entry["id"]),
Expand Down
10 changes: 5 additions & 5 deletions webvh/webvh/anoncreds/tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
from ..registry import DIDWebVHRegistry

test_scid = "Q"
test_domain = "localhost"
test_server = "http://localhost"
test_domain = "id.test-suite.app"
test_server = "https://id.test-suite.app"
test_issuer_id = f"did:webvh:{test_scid}:{test_domain}"
test_schema = AnonCredsSchema(
issuer_id=test_issuer_id,
attr_names=["name", "age", "vmax"],
name="test_schema",
version="1.0",
)
test_schema_digest = "zQmRmN6TUCRFUWtM8REtx9tvVZQd3fWYAfY2K5T6dVtpieG"
test_schema_digest = "zQmXS77mJCmsKf6aas8uwNgJ2zEh299UKcFgLJa5AVkBHTQ"
test_schema_id = f"{test_issuer_id}/resources/{test_schema_digest}"
test_cred_tag = ""
test_cred_def = {}
Expand Down Expand Up @@ -73,7 +73,7 @@
json=mock.AsyncMock(
return_value={
"@context": ["https://w3id.org/security/data-integrity/v2"],
"id": f"{test_issuer_id}/resources/zQmPNuWdxtjcFiVuSEb2tWbD3jiALskcuUp52yzp1NvyCz2",
"id": f"{test_issuer_id}/resources/zQma3tUVYzMn9UfrFCEvxYv4RjaWgs4vV8MZnhR9utAffLh",
"type": ["AttestedResource"],
"content": {
"issuerId": test_issuer_id,
Expand Down Expand Up @@ -105,7 +105,7 @@ async def asyncSetUp(self):
async with self.profile.session() as session:
await MultikeyManager(session).create(
alg="ed25519",
kid="webvh:localhost:8000@witnessKey",
kid="webvh:id.test-suite.app@witnessKey",
)
self.registry = DIDWebVHRegistry()

Expand Down
25 changes: 15 additions & 10 deletions webvh/webvh/config/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,46 @@ async def test_config(self):
# With only plugin config value
self.profile.settings.set_value(
"plugin_config",
{"did-webvh": {"server_url": "http://localhost:6000", "role": "witness"}},
{
"did-webvh": {
"server_url": "http://id.test-suite.app:6000",
"role": "witness",
}
},
)
config = await get_plugin_config(self.profile)
assert config["server_url"] == "http://localhost:6000"
assert config["server_url"] == "http://id.test-suite.app:6000"
assert config["role"] == "witness"
assert not await is_controller(self.profile)
assert await get_server_url(self.profile) == "http://localhost:6000"
assert await get_server_url(self.profile) == "http://id.test-suite.app:6000"

# With a new set storage record
await set_config(
self.profile,
{
"server_url": "http://localhost:8080",
"server_url": "http://id.test-suite.app:8080",
"role": "controller",
"witness_invitation": "http://localhost:3000?oob=eyJAdHlwZSI6ICJodHRwczovL2RpZGNvbW0ub3JnL291dC1vZi1iYW5kLzEuMS9pbnZpdGF0aW9uIiwgIkBpZCI6ICJlMzI5OGIyNS1mZjRlLTRhZmItOTI2Yi03ZDcyZmVlMjQ1ODgiLCAibGFiZWwiOiAid2VidmgtZW5kb3JzZXIiLCAiaGFuZHNoYWtlX3Byb3RvY29scyI6IFsiaHR0cHM6Ly9kaWRjb21tLm9yZy9kaWRleGNoYW5nZS8xLjAiXSwgInNlcnZpY2VzIjogW3siaWQiOiAiI2lubGluZSIsICJ0eXBlIjogImRpZC1jb21tdW5pY2F0aW9uIiwgInJlY2lwaWVudEtleXMiOiBbImRpZDprZXk6ejZNa3FDQ1pxNURSdkdMcDV5akhlZlZTa2JhN0tYWlQ1Nld2SlJacEQ2Z3RvRzU0I3o2TWtxQ0NacTVEUnZHTHA1eWpIZWZWU2tiYTdLWFpUNTZXdkpSWnBENmd0b0c1NCJdLCAic2VydmljZUVuZHBvaW50IjogImh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCJ9XX0",
"witness_invitation": "http://id.test-suite.app:3000?oob=eyJAdHlwZSI6ICJodHRwczovL2RpZGNvbW0ub3JnL291dC1vZi1iYW5kLzEuMS9pbnZpdGF0aW9uIiwgIkBpZCI6ICJlMzI5OGIyNS1mZjRlLTRhZmItOTI2Yi03ZDcyZmVlMjQ1ODgiLCAibGFiZWwiOiAid2VidmgtZW5kb3JzZXIiLCAiaGFuZHNoYWtlX3Byb3RvY29scyI6IFsiaHR0cHM6Ly9kaWRjb21tLm9yZy9kaWRleGNoYW5nZS8xLjAiXSwgInNlcnZpY2VzIjogW3siaWQiOiAiI2lubGluZSIsICJ0eXBlIjogImRpZC1jb21tdW5pY2F0aW9uIiwgInJlY2lwaWVudEtleXMiOiBbImRpZDprZXk6ejZNa3FDQ1pxNURSdkdMcDV5akhlZlZTa2JhN0tYWlQ1Nld2SlJacEQ2Z3RvRzU0I3o2TWtxQ0NacTVEUnZHTHA1eWpIZWZWU2tiYTdLWFpUNTZXdkpSWnBENmd0b0c1NCJdLCAic2VydmljZUVuZHBvaW50IjogImh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCJ9XX0",
},
)
config = await get_plugin_config(self.profile)
assert config["server_url"] == "http://localhost:8080"
assert config["server_url"] == "http://id.test-suite.app:8080"
assert config["role"] == "controller"
assert config.get("witness_invitation")
assert await is_controller(self.profile)
assert await get_server_url(self.profile) == "http://localhost:8080"
assert await get_server_url(self.profile) == "http://id.test-suite.app:8080"

# Update the config storage record
await set_config(
self.profile,
{
"server_url": "http://localhost:9090",
"server_url": "http://id.test-suite.app:9090",
"role": "witness",
},
)
config = await get_plugin_config(self.profile)
assert config["server_url"] == "http://localhost:9090"
assert config["server_url"] == "http://id.test-suite.app:9090"
assert config["role"] == "witness"
assert not config.get("witness_invitation")
assert not await is_controller(self.profile)
assert await get_server_url(self.profile) == "http://localhost:9090"
assert await get_server_url(self.profile) == "http://id.test-suite.app:9090"
4 changes: 3 additions & 1 deletion webvh/webvh/did/pending_dids.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Module for handling pending webvh dids."""

from acapy_agent.core.profile import Profile
from aries_askar import AskarError

RECORD_TYPE = "pending_webvh_dids"

Expand Down Expand Up @@ -32,9 +33,10 @@ async def _check_and_initialize(self, profile: Profile):

async def _save_pending_dids(self, profile: Profile):
async with profile.session() as session:
# This is used to force save with newest when there is a race condition
try:
await session.handle.remove(RECORD_TYPE, RECORD_TYPE)
except Exception:
except AskarError:
pass
await session.handle.insert(
RECORD_TYPE, RECORD_TYPE, value_json=list(self.dids)
Expand Down
42 changes: 21 additions & 21 deletions webvh/webvh/did/tests/test_operations_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"state": {
"@context": ["..."],
"id": "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:server.localhost%3A8000:prod:3",
"id": "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:id.test-suite.app:prod:3",
"verificationMethod": ["..."],
"authentication": ["..."],
"assertionMethod": ["..."],
Expand All @@ -38,7 +38,7 @@

initial_create_response = {
"state": {
"id": "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:server.localhost%3A8000:prod:3",
"id": "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:id.test-suite.app:prod:3",
}
}

Expand All @@ -48,14 +48,14 @@
return_value={
"didDocument": {
"@context": ["https://www.w3.org/ns/did/v1"],
"id": "did:web:server.localhost%3A8000:prod:1",
"id": "did:web:id.test-suite.app:prod:1",
},
"proofOptions": {
"type": "DataIntegrityProof",
"cryptosuite": "eddsa-jcs-2022",
"proofPurpose": "assertionMethod",
"expires": "2024-12-18T20:46:01+00:00",
"domain": "server.localhost%3A8000",
"domain": "id.test-suite.app",
"challenge": "fa0b6142-cd83-576b-a7a7-5cc4eb10e0ea",
},
}
Expand Down Expand Up @@ -84,7 +84,7 @@ async def asyncSetUp(self):
async with self.profile.session() as session:
await MultikeyManager(session).create(
alg="ed25519",
kid="webvh:localhost:8000@witnessKey",
kid="webvh:id.test-suite.app@witnessKey",
)

async def test_create_invalid(self):
Expand Down Expand Up @@ -112,7 +112,7 @@ async def test_create_invalid(self):
async def test_create_self_witness(self):
self.profile.settings.set_value(
"plugin_config",
{"did-webvh": {"server_url": "http://localhost:8000"}},
{"did-webvh": {"server_url": "http://id.test-suite.app"}},
)

resolver = mock.MagicMock(DIDResolver, autospec=True)
Expand Down Expand Up @@ -150,7 +150,7 @@ async def test_create_self_witness(self):
log_entry_response,
{
"state": {
"id": "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:server.localhost%3A8000:prod:4",
"id": "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:id.test-suite.app:prod:4",
}
},
]
Expand All @@ -161,7 +161,7 @@ async def test_create_self_witness(self):
async def test_create_self_witness_as_witness(self):
self.profile.settings.set_value(
"plugin_config",
{"did-webvh": {"server_url": "http://localhost:8000", "role": "witness"}},
{"did-webvh": {"server_url": "http://id.test-suite.app", "role": "witness"}},
)

resolver = mock.MagicMock(DIDResolver, autospec=True)
Expand Down Expand Up @@ -198,7 +198,7 @@ async def test_create_as_controller(self):
"plugin_config",
{
"did-webvh": {
"server_url": "http://localhost:8000",
"server_url": "http://id.test-suite.app",
"role": "controller",
}
},
Expand All @@ -218,7 +218,7 @@ async def test_create_as_controller(self):
# Has connection
async with self.profile.session() as session:
record = ConnRecord(
alias="webvh:localhost:8000@witness",
alias="webvh:id.test-suite.app@witness",
state="active",
)
await record.save(session)
Expand All @@ -227,7 +227,7 @@ async def test_create_as_controller(self):
options={"namespace": "test"}
)
await DidWebvhOperationsManager(self.profile).finish_create(
witnessed_document={"id": "did:web:server.localhost%3A8000:prod:1"},
witnessed_document={"id": "did:web:id.test-suite.app:prod:1"},
parameters={},
state=RegistrationState.PENDING.value,
authorized_key_info=None,
Expand All @@ -242,7 +242,7 @@ async def test_create_connection_error_with_server(self, _):
"plugin_config",
{
"did-webvh": {
"server_url": "http://localhost:8000",
"server_url": "http://id.test-suite.app",
"role": "controller",
}
},
Expand All @@ -258,7 +258,7 @@ async def test_create_bad_request(self):
"plugin_config",
{
"did-webvh": {
"server_url": "http://localhost:8000",
"server_url": "http://id.test-suite.app",
}
},
)
Expand All @@ -276,14 +276,14 @@ async def test_create_bad_request(self):
return_value={
"didDocument": {
"@context": ["https://www.w3.org/ns/did/v1"],
"id": "did:web:server.localhost%3A8000:prod:1",
"id": "did:web:id.test-suite.app:prod:1",
},
"proofOptions": {
"type": "DataIntegrityProof",
"cryptosuite": "eddsa-jcs-2022",
"proofPurpose": "assertionMethod",
"expires": "2024-12-18T20:46:01+00:00",
# "domain": "server.localhost%3A8000",
# "domain": "id.test-suite.app",
"challenge": "fa0b6142-cd83-576b-a7a7-5cc4eb10e0ea",
},
}
Expand All @@ -296,7 +296,7 @@ async def test_create_response_is_missing_required_value(self):
"plugin_config",
{
"did-webvh": {
"server_url": "http://localhost:8000",
"server_url": "http://id.test-suite.app",
"role": "witness",
}
},
Expand All @@ -317,11 +317,11 @@ async def test_create_response_is_missing_required_value(self):
# For first response
"didDocument": {
"@context": ["https://www.w3.org/ns/did/v1"],
"id": "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:server.localhost%3A8000:prod:3",
"id": "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:id.test-suite.app:prod:3",
},
# For second response
"state": {
"id": "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:server.localhost%3A8000:prod:3"
"id": "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:id.test-suite.app:prod:3"
},
}
)
Expand Down Expand Up @@ -349,7 +349,7 @@ async def test_finish_create(self):
),
),
)
test_did = "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:server.localhost%3A8000:prod:3"
test_did = "did:webvh:QmVSevWDZeaFYcTx2FaVaU91G9ABtyEW5vG3wzKTxN7cuS:id.test-suite.app:prod:3"

# No pending dids - attested
await DidWebvhOperationsManager(self.profile).finish_create(
Expand All @@ -376,7 +376,7 @@ async def test_finish_create(self):
await set_config(
self.profile,
{
"server_url": "http://localhost:8000",
"server_url": "http://id.test-suite.app",
"role": "controller",
},
)
Expand All @@ -390,7 +390,7 @@ async def test_finish_create(self):
await DidWebvhOperationsManager(self.profile).finish_create(
witnessed_document={
"id": test_did,
"proof": [{"domain": "server.localhost%3A8000"}],
"proof": [{"domain": "id.test-suite.app"}],
},
parameters={},
state=RegistrationState.ATTESTED.value,
Expand Down
Loading

0 comments on commit fd4a51b

Please sign in to comment.