Skip to content

Commit 7217343

Browse files
authored
feat: Remove issuance v1 protocols (#3923)
* feat: Remove issuance v1 protocols Signed-off-by: jamshale <jamiehalebc@gmail.com> * fix: formatting Signed-off-by: jamshale <jamiehalebc@gmail.com> * chore: remove issuance v1 unit tests Signed-off-by: jamshale <jamiehalebc@gmail.com> * chore: remove v1 oob attachment unit test Signed-off-by: jamshale <jamiehalebc@gmail.com> * feat: unit tests for revocation event Signed-off-by: jamshale <jamiehalebc@gmail.com> * chore: Remove v1 issuance scenario test Signed-off-by: jamshale <jamiehalebc@gmail.com> * fix: Small copilot fixes Signed-off-by: jamshale <jamiehalebc@gmail.com> * Add v1 message type back to oob processor Signed-off-by: jamshale <jamiehalebc@gmail.com> * fix: small format issue Signed-off-by: jamshale <jamiehalebc@gmail.com> * Remove some old v1 code from the demo agent Signed-off-by: jamshale <jamiehalebc@gmail.com> --------- Signed-off-by: jamshale <jamiehalebc@gmail.com>
1 parent fb3742e commit 7217343

File tree

65 files changed

+168
-10135
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+168
-10135
lines changed

acapy_agent/anoncreds/revocation/manager.py

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@
22

33
import logging
44
from collections.abc import Mapping, Sequence
5-
from typing import TYPE_CHECKING, Optional, Tuple, Type
5+
from typing import TYPE_CHECKING, Optional, Tuple
66

77
from ...core.error import BaseError
88
from ...core.profile import Profile
9-
from ...protocols.issue_credential.v1_0.models.credential_exchange import (
10-
V10CredentialExchange,
11-
)
12-
from ...protocols.issue_credential.v2_0.models.cred_ex_record import V20CredExRecord
139
from ...protocols.revocation_notification.v1_0.models.rev_notification_record import (
1410
RevNotificationRecord,
1511
)
@@ -368,62 +364,3 @@ async def set_cred_revoked_state(
368364
updated_cred_rev_ids.append(cred_rev_id)
369365

370366
await txn.commit()
371-
372-
# Check if any requested cred rev ids were not found
373-
missing_cred_rev_ids = [
374-
_id for _id in cred_rev_ids if _id not in updated_cred_rev_ids
375-
]
376-
if missing_cred_rev_ids:
377-
self._logger.warning(
378-
"IssuerCredRevRecord not found for cred_rev_id=%s. Could not revoke.",
379-
missing_cred_rev_ids,
380-
)
381-
382-
# Map cred_ex_version to the record type
383-
_cred_ex_version_map: dict[str, Type[V10CredentialExchange | V20CredExRecord]] = {
384-
IssuerCredRevRecord.VERSION_1: V10CredentialExchange,
385-
IssuerCredRevRecord.VERSION_2: V20CredExRecord,
386-
}
387-
388-
# Update CredEx records for each credential revocation record
389-
for cred_rev_record in cred_rev_records:
390-
async with self._profile.transaction() as txn:
391-
cred_ex_id = cred_rev_record.cred_ex_id
392-
cred_ex_version = cred_rev_record.cred_ex_version
393-
known_record_type = _cred_ex_version_map.get(cred_ex_version)
394-
395-
# If we know the record type, use it, otherwise try both V1 and V2
396-
record_type_to_use = (
397-
[known_record_type]
398-
if known_record_type
399-
else [V10CredentialExchange, V20CredExRecord]
400-
)
401-
402-
for record_type in record_type_to_use:
403-
try:
404-
cred_ex_record = await record_type.retrieve_by_id(
405-
txn, cred_ex_id, for_update=True
406-
)
407-
408-
# Update cred ex record state to indicate revoked
409-
cred_ex_record.state = record_type.STATE_CREDENTIAL_REVOKED
410-
await cred_ex_record.save(txn, reason="revoke credential")
411-
412-
self._logger.debug(
413-
"Updated %s state to REVOKED for cred_ex_id=%s",
414-
record_type.__name__,
415-
cred_ex_id,
416-
)
417-
await txn.commit()
418-
break # Record found, no need to check other record type
419-
except StorageNotFoundError:
420-
# Credential Exchange records may have been deleted, which is fine
421-
self._logger.debug(
422-
"%s not found for cred_ex_id=%s / cred_rev_id=%s.%s",
423-
record_type.__name__,
424-
cred_ex_id,
425-
cred_rev_record.cred_rev_id,
426-
" Checking next record type."
427-
if not known_record_type
428-
else "",
429-
)

acapy_agent/anoncreds/revocation/tests/test_manager.py

Lines changed: 5 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33

44
import pytest
55

6-
from ....protocols.issue_credential.v1_0.models.credential_exchange import (
7-
V10CredentialExchange,
8-
)
96
from ....protocols.issue_credential.v2_0.models.cred_ex_record import V20CredExRecord
10-
from ....revocation.models.issuer_cred_rev_record import IssuerCredRevRecord
117
from ....tests import mock
128
from ....utils.testing import create_test_profile
139
from ...issuer import AnonCredsIssuer
@@ -108,27 +104,6 @@ async def test_revoke_cred_by_cxid_not_found(self):
108104
with self.assertRaises(RevocationManagerError):
109105
await self.manager.revoke_credential_by_cred_ex_id(CRED_EX_ID)
110106

111-
@pytest.mark.skip(reason="AnonCreds-break")
112-
async def test_revoke_credential_no_rev_reg_rec(self):
113-
V10CredentialExchange(
114-
credential_exchange_id="dummy-cxid",
115-
credential_definition_id=CRED_DEF_ID,
116-
role=V10CredentialExchange.ROLE_ISSUER,
117-
revocation_id=CRED_REV_ID,
118-
revoc_reg_id=REV_REG_ID,
119-
)
120-
121-
with mock.patch.object(test_module, "IndyRevocation", autospec=True) as revoc:
122-
revoc.return_value.get_issuer_rev_reg_record = mock.CoroutineMock(
123-
return_value=None
124-
)
125-
126-
issuer = mock.MagicMock(AnonCredsIssuer, autospec=True)
127-
self.profile.context.injector.bind_instance(AnonCredsIssuer, issuer)
128-
129-
with self.assertRaises(RevocationManagerError):
130-
await self.manager.revoke_credential(REV_REG_ID, CRED_REV_ID)
131-
132107
@pytest.mark.skip(reason="AnonCreds-break")
133108
async def test_revoke_credential_pend(self):
134109
mock_issuer_rev_reg_record = mock.MagicMock(mark_pending=mock.AsyncMock())
@@ -417,89 +392,19 @@ async def test_clear_pending_1_rev_reg_some(self):
417392
async def test_retrieve_records(self):
418393
session = await self.profile.session()
419394
for index in range(2):
420-
exchange_record = V10CredentialExchange(
395+
exchange_record = V20CredExRecord(
421396
connection_id=str(index),
422397
thread_id=str(1000 + index),
423-
initiator=V10CredentialExchange.INITIATOR_SELF,
424-
role=V10CredentialExchange.ROLE_ISSUER,
398+
initiator=V20CredExRecord.INITIATOR_SELF,
399+
role=V20CredExRecord.ROLE_ISSUER,
400+
state=V20CredExRecord.STATE_ISSUED,
425401
)
426402
await exchange_record.save(session)
427403

428404
for _ in range(2): # second pass gets from cache
429405
for index in range(2):
430-
ret_ex = await V10CredentialExchange.retrieve_by_connection_and_thread(
406+
ret_ex = await V20CredExRecord.retrieve_by_conn_and_thread(
431407
session, str(index), str(1000 + index)
432408
)
433409
assert ret_ex.connection_id == str(index)
434410
assert ret_ex.thread_id == str(1000 + index)
435-
436-
async def test_set_revoked_state_v1(self):
437-
async with self.profile.session() as session:
438-
exchange_record = V10CredentialExchange(
439-
connection_id="mark-revoked-cid",
440-
thread_id="mark-revoked-tid",
441-
initiator=V10CredentialExchange.INITIATOR_SELF,
442-
revoc_reg_id=REV_REG_ID,
443-
revocation_id=CRED_REV_ID,
444-
role=V10CredentialExchange.ROLE_ISSUER,
445-
state=V10CredentialExchange.STATE_ISSUED,
446-
)
447-
await exchange_record.save(session)
448-
449-
crev_record = IssuerCredRevRecord(
450-
cred_ex_id=exchange_record.credential_exchange_id,
451-
cred_def_id=CRED_DEF_ID,
452-
rev_reg_id=REV_REG_ID,
453-
cred_rev_id=CRED_REV_ID,
454-
state=IssuerCredRevRecord.STATE_ISSUED,
455-
)
456-
await crev_record.save(session)
457-
458-
await self.manager.set_cred_revoked_state(REV_REG_ID, [CRED_REV_ID])
459-
460-
async with self.profile.session() as session:
461-
check_exchange_record = await V10CredentialExchange.retrieve_by_id(
462-
session, exchange_record.credential_exchange_id
463-
)
464-
assert (
465-
check_exchange_record.state
466-
== V10CredentialExchange.STATE_CREDENTIAL_REVOKED
467-
)
468-
469-
check_crev_record = await IssuerCredRevRecord.retrieve_by_id(
470-
session, crev_record.record_id
471-
)
472-
assert check_crev_record.state == IssuerCredRevRecord.STATE_REVOKED
473-
474-
async def test_set_revoked_state_v2(self):
475-
async with self.profile.session() as session:
476-
exchange_record = V20CredExRecord(
477-
connection_id="mark-revoked-cid",
478-
thread_id="mark-revoked-tid",
479-
initiator=V20CredExRecord.INITIATOR_SELF,
480-
role=V20CredExRecord.ROLE_ISSUER,
481-
state=V20CredExRecord.STATE_ISSUED,
482-
)
483-
await exchange_record.save(session)
484-
485-
crev_record = IssuerCredRevRecord(
486-
cred_ex_id=exchange_record.cred_ex_id,
487-
cred_def_id=CRED_DEF_ID,
488-
rev_reg_id=REV_REG_ID,
489-
cred_rev_id=CRED_REV_ID,
490-
state=IssuerCredRevRecord.STATE_ISSUED,
491-
)
492-
await crev_record.save(session)
493-
494-
await self.manager.set_cred_revoked_state(REV_REG_ID, [CRED_REV_ID])
495-
496-
async with self.profile.session() as session:
497-
check_exchange_record = await V20CredExRecord.retrieve_by_id(
498-
session, exchange_record.cred_ex_id
499-
)
500-
assert check_exchange_record.state == V20CredExRecord.STATE_CREDENTIAL_REVOKED
501-
502-
check_crev_record = await IssuerCredRevRecord.retrieve_by_id(
503-
session, crev_record.record_id
504-
)
505-
assert check_crev_record.state == IssuerCredRevRecord.STATE_REVOKED

acapy_agent/core/oob_processor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from ..messaging.decorators.service_decorator import ServiceDecorator
1111
from ..messaging.request_context import RequestContext
1212
from ..protocols.didcomm_prefix import DIDCommPrefix
13-
from ..protocols.issue_credential.v1_0.message_types import CREDENTIAL_OFFER
1413
from ..protocols.issue_credential.v2_0.message_types import CRED_20_OFFER
1514
from ..protocols.out_of_band.v1_0.models.oob_record import OobRecord
1615
from ..protocols.present_proof.v1_0.message_types import PRESENTATION_REQUEST
@@ -301,10 +300,10 @@ async def handle_message(
301300
):
302301
"""Message handler for inbound messages."""
303302
supported_types = [
304-
CREDENTIAL_OFFER,
305303
CRED_20_OFFER,
306304
PRESENTATION_REQUEST,
307305
PRES_20_REQUEST,
306+
"issue-credential/1.0/offer-credential",
308307
]
309308

310309
supported_messages = [

acapy_agent/core/tests/test_goal_code_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from unittest import IsolatedAsyncioTestCase
22

3-
from ...protocols.issue_credential.v1_0.message_types import CONTROLLERS
3+
from ...protocols.issue_credential.v2_0.message_types import CONTROLLERS
44
from ..goal_code_registry import GoalCodeRegistry
55

66

acapy_agent/core/tests/test_oob_processor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ async def test_handle_message_connection(self):
680680
self.profile,
681681
[
682682
{
683-
"@type": "issue-credential/1.0/offer-credential",
683+
"@type": "issue-credential/2.0/offer-credential",
684684
"@id": "4a580490-a9d8-44f5-a3f6-14e0b8a219b0",
685685
}
686686
],
@@ -706,7 +706,7 @@ async def test_handle_message_connectionless(self):
706706
self.profile,
707707
[
708708
{
709-
"@type": "issue-credential/1.0/offer-credential",
709+
"@type": "issue-credential/2.0/offer-credential",
710710
"@id": "4a580490-a9d8-44f5-a3f6-14e0b8a219b0",
711711
}
712712
],
@@ -735,7 +735,7 @@ async def test_handle_message_unsupported_message_type(self):
735735
self.profile, [{"@type": "unsupported"}], mock.MagicMock()
736736
)
737737
assert (
738-
"None of the oob attached messages supported. Supported message types are issue-credential/1.0/offer-credential, issue-credential/2.0/offer-credential, present-proof/1.0/request-presentation, present-proof/2.0/request-presentation"
738+
"None of the oob attached messages supported. Supported message types are issue-credential/2.0/offer-credential, present-proof/1.0/request-presentation, present-proof/2.0/request-presentation"
739739
in err.exception.message
740740
)
741741

acapy_agent/protocols/discovery/v2_0/handlers/tests/test_queries_handler.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,12 @@
55
from ......core.protocol_registry import ProtocolRegistry
66
from ......messaging.request_context import RequestContext
77
from ......messaging.responder import MockResponder
8-
from ......protocols.issue_credential.v1_0.controller import (
8+
from ......protocols.issue_credential.v2_0.controller import (
99
ISSUE_VC,
1010
PARTICIPATE_VC_INTERACTION,
1111
)
12-
from ......protocols.issue_credential.v1_0.message_types import (
13-
CONTROLLERS as issue_cred_v1_controller,
14-
)
15-
from ......protocols.present_proof.v1_0.message_types import (
16-
CONTROLLERS as pres_proof_v1_controller,
12+
from ......protocols.issue_credential.v2_0.message_types import (
13+
CONTROLLERS as pres_proof_v2_controller,
1714
)
1815
from ......tests import mock
1916
from ......utils.testing import create_test_profile
@@ -32,7 +29,7 @@ async def request_context():
3229
protocol_registry = ProtocolRegistry()
3330
goal_code_registry = GoalCodeRegistry()
3431
protocol_registry.register_message_types({TEST_MESSAGE_TYPE: object()})
35-
goal_code_registry.register_controllers(issue_cred_v1_controller)
32+
goal_code_registry.register_controllers(pres_proof_v2_controller)
3633
profile = ctx.profile
3734
profile.context.injector.bind_instance(ProtocolRegistry, protocol_registry)
3835
profile.context.injector.bind_instance(GoalCodeRegistry, goal_code_registry)
@@ -93,7 +90,7 @@ async def test_queries_protocol_goal_code_all_disclose_list_settings(
9390
protocol_registry.register_message_types({"doc/proto-b/1.0/message": object()})
9491
profile.context.injector.bind_instance(ProtocolRegistry, protocol_registry)
9592
goal_code_registry = profile.inject(GoalCodeRegistry)
96-
goal_code_registry.register_controllers(pres_proof_v1_controller)
93+
goal_code_registry.register_controllers(pres_proof_v2_controller)
9794
profile.context.injector.bind_instance(GoalCodeRegistry, goal_code_registry)
9895
profile.settings["disclose_protocol_list"] = [TEST_MESSAGE_FAMILY]
9996
profile.settings["disclose_goal_code_list"] = [

acapy_agent/protocols/endorse_transaction/v1_0/tests/test_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from .....wallet.base import BaseWallet
1818
from .....wallet.did_method import SOV, DIDMethods
1919
from .....wallet.key_type import ED25519, KeyTypes
20-
from ....issue_credential.v1_0.tests import REV_REG_ID
20+
from ....issue_credential.v2_0.tests import REV_REG_ID
2121
from ..manager import TransactionManager, TransactionManagerError
2222
from ..models.transaction_record import TransactionRecord
2323
from ..transaction_jobs import TransactionJob

acapy_agent/protocols/issue_credential/definition.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
"""Version definitions for this protocol."""
22

33
versions = [
4-
{
5-
"major_version": 1,
6-
"minimum_minor_version": 0,
7-
"current_minor_version": 0,
8-
"path": "v1_0",
9-
},
104
{
115
"major_version": 2,
126
"minimum_minor_version": 0,

acapy_agent/protocols/issue_credential/v1_0/__init__.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)