Skip to content

Commit

Permalink
Merge pull request #1665 from hyperledger/fix/always-notify-if-notifi…
Browse files Browse the repository at this point in the history
…cation-record

fix: always notify if revocation notification record exists
  • Loading branch information
andrewwhitehead authored Mar 14, 2022
2 parents 535f14e + 1f8453c commit e77d087
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ async def on_revocation_published(profile: Profile, event: Event):
"""Handle issuer revoke event."""
LOGGER.debug("Sending notification of revocation to recipient: %s", event.payload)

should_notify = profile.settings.get("revocation.notify", False)
responder = profile.inject(BaseResponder)
crids = event.payload.get("crids") or []

Expand All @@ -46,10 +45,9 @@ async def on_revocation_published(profile: Profile, event: Event):

for record in records:
await record.delete_record(session)
if should_notify:
await responder.send(
record.to_message(), connection_id=record.connection_id
)
await responder.send(
record.to_message(), connection_id=record.connection_id
)

except StorageNotFoundError:
LOGGER.info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ async def test_on_revocation_published(profile: Profile, responder: MockResponde
event = Event(topic, {"rev_reg_id": "mock", "crids": ["mock"]})

assert isinstance(profile.settings, Settings)
profile.settings["revocation.notify"] = True

with mock.patch.object(test_module, "RevNotificationRecord", MockRec):
await test_module.on_revocation_published(profile, event)
Expand All @@ -60,32 +59,6 @@ async def test_on_revocation_published(profile: Profile, responder: MockResponde
assert responder.messages


@pytest.mark.asyncio
async def test_on_revocation_published_no_notify(
profile: Profile, responder: MockResponder
):
"""Test revocation published event handler."""
mock_rec = mock.MagicMock()
mock_rec.cred_rev_id = "mock"
mock_rec.delete_record = mock.CoroutineMock()

MockRec = mock.MagicMock()
MockRec.query_by_rev_reg_id = mock.CoroutineMock(return_value=[mock_rec])

topic = f"{REVOCATION_EVENT_PREFIX}{REVOCATION_PUBLISHED_EVENT}::mock"
event = Event(topic, {"rev_reg_id": "mock", "crids": ["mock"]})

assert isinstance(profile.settings, Settings)
profile.settings["revocation.notify"] = False

with mock.patch.object(test_module, "RevNotificationRecord", MockRec):
await test_module.on_revocation_published(profile, event)

MockRec.query_by_rev_reg_id.assert_called_once()
mock_rec.delete_record.assert_called_once()
assert not responder.messages


@pytest.mark.asyncio
async def test_on_revocation_published_x_not_found(
profile: Profile, responder: MockResponder
Expand Down

0 comments on commit e77d087

Please sign in to comment.