Skip to content

Commit

Permalink
🧪 Configure xdist group for session fixtures (#1312)
Browse files Browse the repository at this point in the history
* 🧪 Configure xdist group for session fixtures

* 🎨 Deduplicate

* 🎨

* 🎨 Deduplicate with pytestmark

* ✅ Fix test

* 🎨 Fix pytest marking

* 🎨 Linting

* 🧪 Update pytest mark for trust registry e2e tests

* 🔊 Add more context to log

* ⚡ Split issuer tests across more xdist groups

* ⚡ Adding missing xdist markers

* ⚡ Tweak xdist groups

* ⚡ Add new xdist group for test_tenants issuers

* ⚡ Optimize xdist groups

* 🎨 Deduplicate

* 🎨 Rearrange log body
  • Loading branch information
ff137 authored Feb 5, 2025
1 parent f8e2bf2 commit 7089586
Show file tree
Hide file tree
Showing 30 changed files with 131 additions and 195 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"pyproject",
"pypy",
"pytest",
"pytestmark",
"PYTHONPATH",
"pyyaml",
"redoc",
Expand Down
8 changes: 6 additions & 2 deletions app/services/onboarding/issuer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ async def onboard_issuer(
endorser_controller (AcaPyClient): authenticated ACA-Py client for endorser
issuer_label (str): alias for the issuer
"""
bound_logger = logger.bind(body={"issuer_wallet_id": issuer_wallet_id})
bound_logger = logger.bind(
body={"issuer_label": issuer_label, "issuer_wallet_id": issuer_wallet_id}
)
bound_logger.debug("Onboarding issuer")

try:
Expand Down Expand Up @@ -92,7 +94,9 @@ async def onboard_issuer_no_public_did(
Returns:
issuer_did (DID): The issuer's DID after completing the onboarding process
"""
bound_logger = logger.bind(body={"issuer_wallet_id": issuer_wallet_id})
bound_logger = logger.bind(
body={"issuer_label": issuer_label, "issuer_wallet_id": issuer_wallet_id}
)
bound_logger.debug("Onboarding issuer that has no public DID")

try:
Expand Down
73 changes: 11 additions & 62 deletions app/tests/e2e/issuer/ld_proof/test_ld_proof_did_key_bbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,76 +2,27 @@
from copy import deepcopy

import pytest
from aries_cloudcontroller import (
AcaPyClient,
Credential,
LDProofVCDetail,
LDProofVCOptions,
)
from aries_cloudcontroller import AcaPyClient
from assertpy import assert_that
from fastapi import HTTPException

from app.models.issuer import SendCredential
from app.routes.connections import router as conn_router
from app.routes.issuer import router as issuer_router
from app.routes.oob import router as oob_router
from app.tests.util.connections import FaberAliceConnect
from app.tests.util.webhooks import assert_both_webhooks_received, check_webhook_state
from shared import RichAsyncClient

from .util import create_credential

# Apply the marker to all tests in this module
pytestmark = pytest.mark.xdist_group(name="issuer_test_group_3")

CREDENTIALS_BASE_PATH = issuer_router.prefix
OOB_BASE_PATH = oob_router.prefix
CONNECTIONS_BASE_PATH = conn_router.prefix


credential_ = SendCredential(
type="ld_proof",
connection_id="",
ld_credential_detail=LDProofVCDetail(
credential=Credential(
context=[
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
type=["VerifiableCredential", "UniversityDegreeCredential"],
credentialSubject={
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science and Arts",
},
"college": "Faber College",
},
issuanceDate="2021-04-12",
issuer="",
),
options=LDProofVCOptions(proofType="BbsBlsSignature2020"),
),
).model_dump(by_alias=True, exclude_unset=True)

# This is the json of the below credential
# {
# "type": "ld_proof",
# "connection_id": "",
# "ld_credential_detail": {
# "credential": {
# "@context": [
# "https://www.w3.org/2018/credentials/v1",
# "https://www.w3.org/2018/credentials/examples/v1",
# ],
# "type": ["VerifiableCredential", "UniversityDegreeCredential"],
# "credentialSubject": {
# "degree": {
# "type": "BachelorDegree",
# "name": "Bachelor of Science and Arts",
# },
# "college": "Faber College",
# },
# "issuanceDate": "2021-04-12",
# "issuer": "",
# },
# "options": "",
# },
# }
credential_ = create_credential("BbsBlsSignature2020")


@pytest.mark.anyio
Expand All @@ -96,13 +47,12 @@ async def test_send_jsonld_key_bbs(
)

data = response.json()
assert_that(data).contains("credential_exchange_id")
assert_that(data).has_state("offer-sent")
cred_ex_id = data["credential_exchange_id"]

try:
thread_id = data["thread_id"]
assert_that(data).contains("credential_exchange_id")
assert_that(data).has_state("offer-sent")

assert await check_webhook_state(
client=alice_member_client,
topic="credentials",
Expand Down Expand Up @@ -194,12 +144,11 @@ async def test_send_jsonld_bbs_oob(
)

data = response.json()
assert_that(data).contains("credential_exchange_id")
assert_that(data).has_state("offer-sent")
cred_ex_id = data["credential_exchange_id"]

try:
assert_that(data).contains("credential_exchange_id")
assert_that(data).has_state("offer-sent")

assert await check_webhook_state(
client=alice_member_client,
topic="credentials",
Expand Down
65 changes: 9 additions & 56 deletions app/tests/e2e/issuer/ld_proof/test_ld_proof_did_key_ed25519.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,70 +2,26 @@
from copy import deepcopy

import pytest
from aries_cloudcontroller import Credential, LDProofVCDetail, LDProofVCOptions
from assertpy import assert_that
from fastapi import HTTPException

from app.models.issuer import SendCredential
from app.routes.connections import router as conn_router
from app.routes.issuer import router as issuer_router
from app.routes.oob import router as oob_router
from app.tests.util.connections import FaberAliceConnect
from app.tests.util.webhooks import assert_both_webhooks_received, check_webhook_state
from shared import RichAsyncClient

from .util import create_credential

# Apply the marker to all tests in this module
pytestmark = pytest.mark.xdist_group(name="issuer_test_group_4")

CREDENTIALS_BASE_PATH = issuer_router.prefix
OOB_BASE_PATH = oob_router.prefix
CONNECTIONS_BASE_PATH = conn_router.prefix

credential_ = SendCredential(
type="ld_proof",
connection_id="",
ld_credential_detail=LDProofVCDetail(
credential=Credential(
context=[
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
type=["VerifiableCredential", "UniversityDegreeCredential"],
credentialSubject={
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science and Arts",
},
"college": "Faber College",
},
issuanceDate="2021-04-12",
issuer="",
),
options=LDProofVCOptions(proofType="Ed25519Signature2018"),
),
).model_dump(by_alias=True, exclude_unset=True)

# This is the json of the above credential
# {
# "type": "ld_proof",
# "connection_id": "",
# "ld_credential_detail": {
# "credential": {
# "@context": [
# "https://www.w3.org/2018/credentials/v1",
# "https://www.w3.org/2018/credentials/examples/v1",
# ],
# "type": ["VerifiableCredential", "UniversityDegreeCredential"],
# "credentialSubject": {
# "degree": {
# "type": "BachelorDegree",
# "name": "Bachelor of Science and Arts",
# },
# "college": "Faber College",
# },
# "issuanceDate": "2021-04-12",
# "issuer": "",
# },
# "options": "",
# },
# }
credential_ = create_credential("Ed25519Signature2018")


@pytest.mark.anyio
Expand All @@ -92,13 +48,11 @@ async def test_send_jsonld_key_ed25519(
)

data = response.json()
assert_that(data).has_state("offer-sent")
cred_ex_id = data["credential_exchange_id"]

try:
thread_id = data["thread_id"]
assert_that(data).contains("credential_exchange_id")
assert_that(data).has_state("offer-sent")

assert await check_webhook_state(
client=alice_member_client,
topic="credentials",
Expand Down Expand Up @@ -192,12 +146,11 @@ async def test_send_jsonld_oob(
)

data = response.json()
assert_that(data).contains("credential_exchange_id")
assert_that(data).has_state("offer-sent")
cred_ex_id = data["credential_exchange_id"]

try:
assert_that(data).contains("credential_exchange_id")
assert_that(data).has_state("offer-sent")

assert await check_webhook_state(
client=alice_member_client,
topic="credentials",
Expand Down
74 changes: 12 additions & 62 deletions app/tests/e2e/issuer/ld_proof/test_ld_proof_did_sov.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,74 +2,26 @@
from copy import deepcopy

import pytest
from aries_cloudcontroller import (
AcaPyClient,
Credential,
LDProofVCDetail,
LDProofVCOptions,
)
from aries_cloudcontroller import AcaPyClient
from assertpy import assert_that

from app.models.issuer import SendCredential
from app.routes.issuer import router as issuer_router
from app.routes.oob import router as oob_router
from app.routes.wallet.dids import router as wallet_router
from app.tests.util.connections import FaberAliceConnect
from app.tests.util.webhooks import assert_both_webhooks_received, check_webhook_state
from shared import RichAsyncClient

from .util import create_credential

# Apply the marker to all tests in this module
pytestmark = pytest.mark.xdist_group(name="issuer_test_group_3")

CREDENTIALS_BASE_PATH = issuer_router.prefix
OOB_BASE_PATH = oob_router.prefix
WALLET = wallet_router.prefix

credential_ = SendCredential(
type="ld_proof",
connection_id="",
ld_credential_detail=LDProofVCDetail(
credential=Credential(
context=[
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
type=["VerifiableCredential", "UniversityDegreeCredential"],
credentialSubject={
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science and Arts",
},
"college": "Faber College",
},
issuanceDate="2021-04-12",
issuer="",
),
options=LDProofVCOptions(proofType="Ed25519Signature2018"),
),
).model_dump(by_alias=True, exclude_unset=True)

# This is the json of the above credential
# {
# "type": "ld_proof",
# "connection_id": "",
# "ld_credential_detail": {
# "credential": {
# "@context": [
# "https://www.w3.org/2018/credentials/v1",
# "https://www.w3.org/2018/credentials/examples/v1",
# ],
# "type": ["VerifiableCredential", "UniversityDegreeCredential"],
# "credentialSubject": {
# "degree": {
# "type": "BachelorDegree",
# "name": "Bachelor of Science and Arts",
# },
# "college": "Faber College",
# },
# "issuanceDate": "2021-04-12",
# "issuer": "",
# },
# "options": "",
# },
# }
credential_ = create_credential("Ed25519Signature2018")


@pytest.mark.anyio
Expand Down Expand Up @@ -98,13 +50,12 @@ async def test_send_jsonld_credential_sov(
)

data = response.json()
assert_that(data).contains("credential_exchange_id")
assert_that(data).has_state("offer-sent")
cred_ex_id = data["credential_exchange_id"]

try:
thread_id = data["thread_id"]
assert_that(data).contains("credential_exchange_id")
assert_that(data).has_state("offer-sent")

assert await check_webhook_state(
client=alice_member_client,
topic="credentials",
Expand Down Expand Up @@ -162,13 +113,12 @@ async def test_send_jsonld_oob_sov(
)

data = response.json()
assert_that(data).contains("credential_exchange_id")
assert_that(data).has_state("offer-sent")
cred_ex_id = data["credential_exchange_id"]
thread_id = data["thread_id"]

try:
assert_that(data).contains("credential_exchange_id")
assert_that(data).has_state("offer-sent")

thread_id = data["thread_id"]
invitation_response = await faber_client.post(
OOB_BASE_PATH + "/create-invitation",
json={
Expand Down
29 changes: 29 additions & 0 deletions app/tests/e2e/issuer/ld_proof/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from aries_cloudcontroller import Credential, LDProofVCDetail, LDProofVCOptions

from app.models.issuer import SendCredential


def create_credential(proof_type: str) -> dict:
return SendCredential(
type="ld_proof",
connection_id="",
ld_credential_detail=LDProofVCDetail(
credential=Credential(
context=[
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
],
type=["VerifiableCredential", "UniversityDegreeCredential"],
credentialSubject={
"degree": {
"type": "BachelorDegree",
"name": "Bachelor of Science and Arts",
},
"college": "Faber College",
},
issuanceDate="2021-04-12",
issuer="",
),
options=LDProofVCOptions(proofType=proof_type),
),
).model_dump(by_alias=True, exclude_unset=True)
Loading

0 comments on commit 7089586

Please sign in to comment.