Skip to content

Commit

Permalink
Merge branch 'main' into mediator-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ianco authored Nov 9, 2022
2 parents 1168ef8 + f857f8c commit ab6c64e
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 2 deletions.
7 changes: 6 additions & 1 deletion aries_cloudagent/transport/inbound/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ async def inbound_message_handler(self, request: web.BaseRequest):
raise web.HTTPBadRequest()

if inbound.receipt.direct_response_requested:
response = await session.wait_response()
# Wait for the message to be processed. Only send a response if a response
# buffer is present.
await inbound.wait_processing_complete()
response = (
await session.wait_response() if session.response_buffer else None
)

# no more responses
session.can_respond = False
Expand Down
2 changes: 2 additions & 0 deletions aries_cloudagent/transport/inbound/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ def dispatch_complete(self, message: InboundMessage, completed: CompletedTask):
if session and session.accept_undelivered and not session.response_buffered:
self.process_undelivered(session)

message.dispatch_processing_complete()

def closed_session(self, session: InboundSession):
"""
Clean up a closed session.
Expand Down
10 changes: 10 additions & 0 deletions aries_cloudagent/transport/inbound/message.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Classes representing inbound messages."""

import asyncio
from typing import Union

from .receipt import MessageReceipt
Expand All @@ -23,3 +24,12 @@ def __init__(
self.receipt = receipt
self.session_id = session_id
self.transport_type = transport_type
self.processing_complete_event = asyncio.Event()

def dispatch_processing_complete(self):
"""Dispatch processing complete."""
self.processing_complete_event.set()

async def wait_processing_complete(self):
"""Wait for processing to complete."""
await self.processing_complete_event.wait()
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def receive_message(
message: InboundMessage,
can_respond: bool = False,
):
message.wait_processing_complete = async_mock.CoroutineMock()
self.message_results.append((message.payload, message.receipt, can_respond))
if self.result_event:
self.result_event.set()
Expand Down Expand Up @@ -119,13 +120,15 @@ async def test_send_message_outliers(self):
mock_session.return_value = async_mock.MagicMock(
receive=async_mock.CoroutineMock(
return_value=async_mock.MagicMock(
receipt=async_mock.MagicMock(direct_response_requested=True)
receipt=async_mock.MagicMock(direct_response_requested=True),
wait_processing_complete=async_mock.CoroutineMock(),
)
),
can_respond=True,
profile=InMemoryProfile.test_profile(),
clear_response=async_mock.MagicMock(),
wait_response=async_mock.CoroutineMock(return_value=b"Hello world"),
response_buffer="something",
)
async with self.client.post("/", data=test_message) as resp:
result = await resp.text()
Expand Down
30 changes: 30 additions & 0 deletions aries_cloudagent/transport/inbound/tests/test_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import asyncio

from asynctest import TestCase

from ..message import InboundMessage
from ..receipt import MessageReceipt


class TestInboundMessage(TestCase):
async def test_wait_response(self):
message = InboundMessage(
payload="test",
connection_id="conn_id",
receipt=MessageReceipt(),
session_id="session_id",
)
assert not message.processing_complete_event.is_set()
message.dispatch_processing_complete()
assert message.processing_complete_event.is_set()

message = InboundMessage(
payload="test",
connection_id="conn_id",
receipt=MessageReceipt(),
session_id="session_id",
)
assert not message.processing_complete_event.is_set()
task = message.wait_processing_complete()
message.dispatch_processing_complete()
await asyncio.wait_for(task, 1)
30 changes: 30 additions & 0 deletions docs/GettingStartedAriesDev/CredentialRevocation.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,3 +151,33 @@ further customize notification handling.
If the argument `--monitor-revocation-notification` is used on startup, a
webhook with the topic `revocation-notification` and a payload containing the
thread ID and comment is emitted to registered webhook urls.
## Manually Creating Revocation Registries
The process for creating revocation registries is completely automated - when you create a Credential Definition with revocation enabled, a revocation registry is automatically created (in fact 2 registries are created), and when a registry fills up, a new one is automatically created.
However the Aca-Py admin api supports endpoints to explicitely create a new revocation registry, if you desire.
There are several endpoints that must be called, and they must be called in this order:
1. Create revoc registry `POST /revocation/create-registry`
- you need to provide the credential definition id and the size of the registry
2. Fix the tails file URI `PATCH /revocation/registry/{rev_reg_id}`
- here you need to provide the full URI that will be written to the ledger, for example:
```
{
"tails_public_uri": "http://host.docker.internal:6543/VDKEEMMSRTEqK4m7iiq5ZL:4:VDKEEMMSRTEqK4m7iiq5ZL:3:CL:8:faber.agent.degree_schema:CL_ACCUM:3cb5c439-928c-483c-a9a8-629c307e6b2d"
}
```
3. Post the revoc def to the ledger `POST /revocation/registry/{rev_reg_id}/definition`
- if you are an author (i.e. have a DID with restricted ledger write access) then this transaction may need to go through an endorser
4. Write the tails file `PUT /revocation/registry/{rev_reg_id}/tails-file`
- the tails server will check that the registry definition is already written to the ledger

0 comments on commit ab6c64e

Please sign in to comment.