-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
from typing import Optional | ||
|
||
import pytest | ||
from assertpy import assert_that | ||
from fastapi import HTTPException | ||
from aries_cloudcontroller import AcaPyClient | ||
|
||
from app.routes.connections import router | ||
from app.services import acapy_wallet | ||
from app.tests.util.webhooks import get_wallet_id_from_async_client | ||
Check notice Code scanning / Pylintpython3 (reported by Codacy) Unused get_wallet_id_from_async_client imported from app.tests.util.webhooks Note test
Unused get_wallet_id_from_async_client imported from app.tests.util.webhooks
|
||
from shared import RichAsyncClient | ||
|
||
BASE_PATH = router.prefix | ||
|
||
|
||
@pytest.mark.anyio | ||
@pytest.mark.parametrize( | ||
"use_did,use_did_method,use_public_did", | ||
[ | ||
(None, None, False), | ||
("did:example:123", None, False), | ||
(None, "did:peer:4", False), | ||
(None, None, True), | ||
], | ||
) | ||
async def test_create_did_exchange_request( | ||
alice_member_client: RichAsyncClient, | ||
faber_acapy_client: AcaPyClient, | ||
use_did: Optional[str], | ||
use_did_method: Optional[str], | ||
use_public_did: bool, | ||
): | ||
faber_public_did = await acapy_wallet.get_public_did(controller=faber_acapy_client) | ||
|
||
request_data = { | ||
"their_public_did": faber_public_did.did, | ||
"use_did": use_did, | ||
"use_did_method": use_did_method, | ||
"use_public_did": use_public_did, | ||
} | ||
|
||
if use_public_did: # Alice doesn't have a public DID | ||
with pytest.raises(HTTPException) as exc_info: | ||
response = await alice_member_client.post( | ||
f"{BASE_PATH}/create-did-request", json=request_data | ||
) | ||
assert exc_info.value.status_code == 400 | ||
assert exc_info.value.detail == """{"detail":"No public DID configured."}""" | ||
else: | ||
response = await alice_member_client.post( | ||
f"{BASE_PATH}/create-did-request", json=request_data | ||
) | ||
assert response.status_code == 200 | ||
connection_record = response.json() | ||
assert_that(connection_record).contains("connection_id", "state") | ||
assert_that(connection_record["state"]).is_equal_to("request-sent") | ||
|
||
|
||
# @pytest.mark.anyio | ||
# async def test_accept_did_exchange_invitation( | ||
# alice_member_client: RichAsyncClient, | ||
# faber_client: RichAsyncClient, | ||
# tenant_admin_client: RichAsyncClient, | ||
# faber_acapy_client: AcaPyClient, | ||
# ): | ||
# faber_public_did = await acapy_wallet.get_public_did(controller=faber_acapy_client) | ||
|
||
# # Disable auto-accept invites for Faber | ||
# faber_wallet_id = await get_wallet_id_from_async_client(controller=faber_client) | ||
# await tenant_admin_client.put( | ||
# f"/tenants/{faber_wallet_id}", | ||
# json={"extra_settings": {"ACAPY_AUTO_ACCEPT_INVITES": False}}, | ||
# ) | ||
|
||
# # Create an invitation from Faber | ||
# invitation_response = await faber_acapy_client.connection.create_invitation() | ||
# invitation = invitation_response.invitation | ||
|
||
# # Alice accepts the invitation | ||
# response = await alice_member_client.post( | ||
# f"{BASE_PATH}/accept-invitation", | ||
# json={"invitation": invitation}, | ||
# ) | ||
# assert response.status_code == 200 | ||
# connection_record = response.json() | ||
# assert_that(connection_record).contains("connection_id", "state") | ||
# assert_that(connection_record["state"]).is_equal_to("request-sent") |