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 tails upload for anoncreds multitenancy #3346

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
9 changes: 8 additions & 1 deletion acapy_agent/anoncreds/revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
from ..core.error import BaseError
from ..core.event_bus import Event, EventBus
from ..core.profile import Profile, ProfileSession
from ..multitenant.base import BaseMultitenantManager
from ..tails.anoncreds_tails_server import AnonCredsTailsServer
from ..tails.base import BaseTailsServer
from .error_messages import ANONCREDS_PROFILE_REQUIRED_MSG
from .events import RevListFinishedEvent, RevRegDefFinishedEvent
Expand Down Expand Up @@ -694,7 +696,12 @@ def get_local_tails_path(self, rev_reg_def: RevRegDef) -> str:

async def upload_tails_file(self, rev_reg_def: RevRegDef):
"""Upload the local tails file to the tails server."""
tails_server = self.profile.inject_or(BaseTailsServer)
multitenant_mgr = self.profile.inject_or(BaseMultitenantManager)
if multitenant_mgr:
tails_server = AnonCredsTailsServer()
else:
tails_server = self.profile.inject_or(BaseTailsServer)

if not tails_server:
raise AnonCredsRevocationError("Tails server not configured")
if not Path(self.get_local_tails_path(rev_reg_def)).is_file():
Expand Down
39 changes: 29 additions & 10 deletions acapy_agent/anoncreds/tests/test_revocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"accum_key": {"z": "1 0BB...386"},
},
tails_hash="58NNWYnVxVFzAfUztwGSNBL4551XNq6nXk56pCiKJxxt",
tails_location="http://tails-server.com",
tails_location="https://tails-server.com",
),
issuer_id="CsQY9MGeD3CQP4EyuVFo5m",
type="CL_ACCUM",
Expand Down Expand Up @@ -836,21 +836,40 @@ def test_generate_public_tails_uri(self):

async def test_upload_tails_file(self):
self.profile.inject_or = mock.Mock(
return_value=mock.MagicMock(
upload_tails_file=mock.CoroutineMock(
side_effect=[
(True, "http://tails-server.com"),
(None, "http://tails-server.com"),
(True, "not-http://tails-server.com"),
]
)
)
side_effect=[
None,
mock.MagicMock(
upload_tails_file=mock.CoroutineMock(
return_value=(True, "https://tails-server.com")
)
),
]
)
# valid
await self.revocation.upload_tails_file(rev_reg_def)
# upload fails
self.profile.inject_or = mock.Mock(
side_effect=[
None,
mock.MagicMock(
upload_tails_file=mock.CoroutineMock(
return_value=(None, "https://tails-server.com"),
)
),
]
)
with self.assertRaises(test_module.AnonCredsRevocationError):
await self.revocation.upload_tails_file(rev_reg_def)
self.profile.inject_or = mock.Mock(
side_effect=[
None,
mock.MagicMock(
upload_tails_file=mock.CoroutineMock(
return_value=(True, "not-http://tails-server.com"),
)
),
]
)
# tails location does not match
with self.assertRaises(test_module.AnonCredsRevocationError):
await self.revocation.upload_tails_file(rev_reg_def)
Expand Down
Loading