Skip to content

Commit 7232d2e

Browse files
authored
🧪 Migrate e2e tests from indy to anoncreds (#1443)
* 🎨 Remove empty dif_presentation_spec from examples * 🧪 Migrate test from indy to anoncreds * 🧪 Migrate more tests from indy to anoncreds * 🎨 Add missing type: anoncreds
1 parent 8957cde commit 7232d2e

File tree

9 files changed

+91
-84
lines changed

9 files changed

+91
-84
lines changed

app/tests/e2e/issuer/test_save_exchange_record.py

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,27 @@
1717

1818
@pytest.mark.anyio
1919
@pytest.mark.parametrize("save_exchange_record", [None, False, True])
20-
@pytest.mark.xdist_group(name="issuer_test_group_3")
20+
@pytest.mark.xdist_group(name="issuer_test_group")
2121
async def test_issue_credential_with_save_exchange_record(
22-
faber_indy_client: RichAsyncClient,
23-
indy_credential_definition_id: str,
24-
faber_indy_and_alice_connection: FaberAliceConnect,
22+
faber_anoncreds_client: RichAsyncClient,
23+
anoncreds_credential_definition_id: str,
24+
faber_anoncreds_and_alice_connection: FaberAliceConnect,
2525
alice_member_client: RichAsyncClient,
2626
save_exchange_record: Optional[bool],
2727
) -> CredentialExchange:
2828
credential = {
29-
"connection_id": faber_indy_and_alice_connection.faber_connection_id,
30-
"indy_credential_detail": {
31-
"credential_definition_id": indy_credential_definition_id,
29+
"type": "anoncreds",
30+
"connection_id": faber_anoncreds_and_alice_connection.faber_connection_id,
31+
"anoncreds_credential_detail": {
32+
"credential_definition_id": anoncreds_credential_definition_id,
3233
"attributes": sample_credential_attributes,
3334
},
3435
"save_exchange_record": save_exchange_record,
3536
}
3637

3738
# create and send credential offer- issuer
3839
faber_send_response = (
39-
await faber_indy_client.post(
40+
await faber_anoncreds_client.post(
4041
CREDENTIALS_BASE_PATH,
4142
json=credential,
4243
)
@@ -84,7 +85,7 @@ async def test_issue_credential_with_save_exchange_record(
8485
if save_exchange_record:
8586
# get exchange records from faber side:
8687
faber_cred_ex_record = (
87-
await faber_indy_client.get(
88+
await faber_anoncreds_client.get(
8889
f"{CREDENTIALS_BASE_PATH}/{faber_credential_exchange_id}"
8990
)
9091
).json()
@@ -97,42 +98,43 @@ async def test_issue_credential_with_save_exchange_record(
9798
else:
9899
# If save_exchange_record was not set, credential should not exist
99100
with pytest.raises(HTTPException) as exc:
100-
await faber_indy_client.get(
101+
await faber_anoncreds_client.get(
101102
f"{CREDENTIALS_BASE_PATH}/{faber_credential_exchange_id}"
102103
)
103104
assert exc.value.status_code == 404
104105

105106
finally:
106107
# Clean up
107108
if save_exchange_record:
108-
await faber_indy_client.delete(
109+
await faber_anoncreds_client.delete(
109110
f"{CREDENTIALS_BASE_PATH}/{faber_credential_exchange_id}"
110111
)
111112

112113

113114
@pytest.mark.anyio
114115
@pytest.mark.parametrize("save_exchange_record", [None, False, True])
115-
@pytest.mark.xdist_group(name="issuer_test_group_4")
116+
@pytest.mark.xdist_group(name="issuer_test_group")
116117
async def test_request_credential_with_save_exchange_record(
117-
faber_indy_client: RichAsyncClient,
118-
indy_credential_definition_id: str,
119-
faber_indy_and_alice_connection: FaberAliceConnect,
118+
faber_anoncreds_client: RichAsyncClient,
119+
anoncreds_credential_definition_id: str,
120+
faber_anoncreds_and_alice_connection: FaberAliceConnect,
120121
alice_member_client: RichAsyncClient,
121122
save_exchange_record: bool,
122123
):
123124
# This test asserts that the holder can control `save_exchange_records` behaviour
124125
credential = {
125-
"connection_id": faber_indy_and_alice_connection.faber_connection_id,
126-
"indy_credential_detail": {
127-
"credential_definition_id": indy_credential_definition_id,
126+
"type": "anoncreds",
127+
"connection_id": faber_anoncreds_and_alice_connection.faber_connection_id,
128+
"anoncreds_credential_detail": {
129+
"credential_definition_id": anoncreds_credential_definition_id,
128130
"attributes": {"speed": "20", "name": "Alice", "age": "44"},
129131
},
130132
"save_exchange_record": True, # so we can safely delete faber cred ex record in finally block
131133
}
132134

133135
# Create and send credential offer - issuer
134136
faber_send_response = (
135-
await faber_indy_client.post(
137+
await faber_anoncreds_client.post(
136138
CREDENTIALS_BASE_PATH,
137139
json=credential,
138140
)
@@ -201,17 +203,17 @@ async def test_request_credential_with_save_exchange_record(
201203
await alice_member_client.delete(
202204
f"{CREDENTIALS_BASE_PATH}/{alice_credential_exchange_id}"
203205
)
204-
await faber_indy_client.delete(
206+
await faber_anoncreds_client.delete(
205207
f"{CREDENTIALS_BASE_PATH}/{faber_credential_exchange_id}"
206208
)
207209

208210

209211
@pytest.mark.anyio
210-
@pytest.mark.xdist_group(name="issuer_test_group_3")
212+
@pytest.mark.xdist_group(name="issuer_test_group")
211213
async def test_get_cred_exchange_records(
212-
faber_indy_client: RichAsyncClient,
213-
indy_credential_definition_id: str,
214-
faber_indy_and_alice_connection: FaberAliceConnect,
214+
faber_anoncreds_client: RichAsyncClient,
215+
anoncreds_credential_definition_id: str,
216+
faber_anoncreds_and_alice_connection: FaberAliceConnect,
215217
alice_member_client: RichAsyncClient,
216218
):
217219
# Fetch existing records so we can filter to exclude them. Necessary to cater for long running / regression tests
@@ -220,18 +222,19 @@ async def test_get_cred_exchange_records(
220222
).json()
221223

222224
credential = {
223-
"connection_id": faber_indy_and_alice_connection.faber_connection_id,
224-
"indy_credential_detail": {
225-
"credential_definition_id": indy_credential_definition_id,
225+
"type": "anoncreds",
226+
"connection_id": faber_anoncreds_and_alice_connection.faber_connection_id,
227+
"anoncreds_credential_detail": {
228+
"credential_definition_id": anoncreds_credential_definition_id,
226229
"attributes": {"speed": "20", "name": "Alice", "age": "44"},
227230
},
228231
"save_exchange_record": True,
229232
}
230233

231-
faber_send_response_1 = await faber_indy_client.post(
234+
faber_send_response_1 = await faber_anoncreds_client.post(
232235
CREDENTIALS_BASE_PATH, json=credential
233236
)
234-
faber_send_response_2 = await faber_indy_client.post(
237+
faber_send_response_2 = await faber_anoncreds_client.post(
235238
CREDENTIALS_BASE_PATH, json=credential
236239
)
237240

@@ -283,10 +286,10 @@ async def test_get_cred_exchange_records(
283286
)
284287

285288
await asyncio.sleep(1) # short sleep to allow records to update
286-
faber_records = (await faber_indy_client.get(CREDENTIALS_BASE_PATH)).json()
289+
faber_records = (await faber_anoncreds_client.get(CREDENTIALS_BASE_PATH)).json()
287290

288291
faber_cred_ex_response = (
289-
await faber_indy_client.get(CREDENTIALS_BASE_PATH + "?state=done")
292+
await faber_anoncreds_client.get(CREDENTIALS_BASE_PATH + "?state=done")
290293
).json()
291294
filtered_cred_ex_records = [
292295
record
@@ -296,7 +299,7 @@ async def test_get_cred_exchange_records(
296299
assert len(filtered_cred_ex_records) == 2
297300

298301
faber_cred_ex_response = (
299-
await faber_indy_client.get(CREDENTIALS_BASE_PATH + "?role=issuer")
302+
await faber_anoncreds_client.get(CREDENTIALS_BASE_PATH + "?role=issuer")
300303
).json()
301304
filtered_cred_ex_records = [
302305
record
@@ -306,14 +309,14 @@ async def test_get_cred_exchange_records(
306309
assert len(filtered_cred_ex_records) == 2
307310

308311
faber_cred_ex_response = (
309-
await faber_indy_client.get(
312+
await faber_anoncreds_client.get(
310313
f"{CREDENTIALS_BASE_PATH}?thread_id={faber_records[0]['thread_id']}"
311314
)
312315
).json()
313316
assert len(faber_cred_ex_response) == 1
314317

315318
with pytest.raises(HTTPException) as exc:
316-
await faber_indy_client.get(
319+
await faber_anoncreds_client.get(
317320
f"{CREDENTIALS_BASE_PATH}?connection_id=123&thread_id=123&role=asf&state=asd"
318321
)
319322
assert exc.value.status_code == 422

app/tests/e2e/test_did_exchange.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
@pytest.mark.xdist_group(name="issuer_test_group")
3232
async def test_create_did_exchange_request(
3333
alice_member_client: RichAsyncClient,
34-
faber_indy_client: RichAsyncClient,
34+
faber_anoncreds_client: RichAsyncClient,
3535
alice_acapy_client: AcaPyClient,
36-
faber_indy_acapy_client: AcaPyClient,
36+
faber_anoncreds_acapy_client: AcaPyClient,
3737
use_did: Optional[str],
3838
use_did_method: Optional[str],
3939
use_public_did: bool,
4040
):
4141
faber_public_did = await acapy_wallet.get_public_did(
42-
controller=faber_indy_acapy_client
42+
controller=faber_anoncreds_acapy_client
4343
)
4444

4545
request_data = {"their_public_did": qualified_did_sov(faber_public_did.did)}
@@ -96,7 +96,7 @@ async def test_create_did_exchange_request(
9696
)
9797
# Faber now has a complete connection too
9898
assert await check_webhook_state(
99-
faber_indy_client,
99+
faber_anoncreds_client,
100100
topic="connections",
101101
state="completed",
102102
filter_map={"their_did": alice_did},
@@ -118,20 +118,20 @@ async def test_create_did_exchange_request(
118118
@pytest.mark.xdist_group(name="issuer_test_group")
119119
async def test_accept_did_exchange_invitation(
120120
alice_member_client: RichAsyncClient,
121-
faber_indy_client: RichAsyncClient,
121+
faber_anoncreds_client: RichAsyncClient,
122122
tenant_admin_client: RichAsyncClient,
123-
faber_indy_acapy_client: AcaPyClient,
123+
faber_anoncreds_acapy_client: AcaPyClient,
124124
use_public_did: bool,
125125
):
126126
# First disable auto-accept invites for Faber
127-
faber_wallet_id = get_wallet_id_from_async_client(client=faber_indy_client)
127+
faber_wallet_id = get_wallet_id_from_async_client(client=faber_anoncreds_client)
128128
await tenant_admin_client.put(
129129
f"{TENANTS_BASE_PATH}/{faber_wallet_id}",
130130
json={"extra_settings": {"ACAPY_AUTO_ACCEPT_REQUESTS": False}},
131131
)
132132

133133
faber_public_did = await acapy_wallet.get_public_did(
134-
controller=faber_indy_acapy_client
134+
controller=faber_anoncreds_acapy_client
135135
)
136136

137137
request_data = {"their_public_did": qualified_did_sov(faber_public_did.did)}
@@ -146,7 +146,7 @@ async def test_accept_did_exchange_invitation(
146146

147147
try:
148148
faber_connection_request_received_event = await check_webhook_state(
149-
faber_indy_client,
149+
faber_anoncreds_client,
150150
topic="connections",
151151
state="request-received",
152152
filter_map={"their_did": alice_did},
@@ -159,7 +159,7 @@ async def test_accept_did_exchange_invitation(
159159
"use_public_did": use_public_did,
160160
}
161161

162-
faber_accept_request_response = await faber_indy_client.post(
162+
faber_accept_request_response = await faber_anoncreds_client.post(
163163
f"{CONNECTIONS_BASE_PATH}/did-exchange/accept-request", params=accept_params
164164
)
165165
assert faber_accept_request_response.status_code == 200
@@ -176,7 +176,7 @@ async def test_accept_did_exchange_invitation(
176176

177177
# And Faber's connection is complete
178178
assert await check_webhook_state(
179-
faber_indy_client,
179+
faber_anoncreds_client,
180180
topic="connections",
181181
state="completed",
182182
filter_map={"connection_id": faber_connection_id},

app/tests/e2e/test_did_rotate.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
async def test_rotate_did(
2020
alice_member_client: RichAsyncClient,
2121
alice_acapy_client: AcaPyClient,
22-
faber_indy_acapy_client: AcaPyClient,
22+
faber_anoncreds_acapy_client: AcaPyClient,
2323
did_method: str,
2424
):
2525
# First, create did-exchange connections between Alice and Faber:
2626
faber_public_did = await acapy_wallet.get_public_did(
27-
controller=faber_indy_acapy_client
27+
controller=faber_anoncreds_acapy_client
2828
)
2929

3030
request_data = {"their_public_did": qualified_did_sov(faber_public_did.did)}
@@ -60,12 +60,12 @@ async def test_rotate_did(
6060
@pytest.mark.xdist_group(name="issuer_test_group")
6161
async def test_hangup_did_rotation(
6262
alice_member_client: RichAsyncClient,
63-
faber_indy_client: RichAsyncClient,
64-
faber_indy_acapy_client: AcaPyClient,
63+
faber_anoncreds_client: RichAsyncClient,
64+
faber_anoncreds_acapy_client: AcaPyClient,
6565
):
6666
# First, create did-exchange connections between Alice and Faber:
6767
faber_public_did = await acapy_wallet.get_public_did(
68-
controller=faber_indy_acapy_client
68+
controller=faber_anoncreds_acapy_client
6969
)
7070

7171
request_data = {"their_public_did": qualified_did_sov(faber_public_did.did)}
@@ -84,7 +84,7 @@ async def test_hangup_did_rotation(
8484
)
8585

8686
faber_event = await check_webhook_state(
87-
faber_indy_client,
87+
faber_anoncreds_client,
8888
topic="connections",
8989
state="completed",
9090
filter_map={"their_did": alice_did},
@@ -105,7 +105,7 @@ async def test_hangup_did_rotation(
105105
filter_map={"connection_id": alice_connection_id},
106106
)
107107
assert await check_webhook_state(
108-
faber_indy_client,
108+
faber_anoncreds_client,
109109
topic="connections",
110110
state="deleted",
111111
filter_map={"connection_id": faber_connection_id},
@@ -117,5 +117,7 @@ async def test_hangup_did_rotation(
117117
assert exc_info.value.status_code == 404
118118

119119
with pytest.raises(HTTPException) as exc_info:
120-
await faber_indy_client.get(f"{CONNECTIONS_BASE_PATH}/{faber_connection_id}")
120+
await faber_anoncreds_client.get(
121+
f"{CONNECTIONS_BASE_PATH}/{faber_connection_id}"
122+
)
121123
assert exc_info.value.status_code == 404

0 commit comments

Comments
 (0)