Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: always notify if revocation notification record exists #1665

Merged
merged 2 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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