Skip to content

Commit

Permalink
Merge branch 'main' into fix-3379
Browse files Browse the repository at this point in the history
  • Loading branch information
ff137 committed Dec 11, 2024
2 parents 6bf8fc8 + a2a6dd2 commit 764e052
Show file tree
Hide file tree
Showing 24 changed files with 341 additions and 147 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/sonar-merge-main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Sonar Scan and Coverage
name: Sonar Scan and Coverage on merge to main
on:
push:
branches:
Expand All @@ -19,12 +19,8 @@ jobs:
python-version: "3.12"
os: "ubuntu-latest"
is_pr: "false"
- name: Adjust Test Coverage Source
run: |
# Need to change source in coverage report because it was generated from another context
sed -i 's/\/home\/runner\/work\/acapy\/acapy\//\/github\/workspace\//g' test-reports/coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
uses: SonarSource/sonarqube-scan-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand All @@ -33,4 +29,4 @@ jobs:
-Dsonar.python.coverage.reportPaths=test-reports/coverage.xml
-Dsonar.coverage.exclusions=**/tests/**,**/demo/**,**/docs/**,**/docker/**,**/scripts/**,**/scenarios/**
-Dsonar.cpd.exclusions=**/tests/**,**/demo/**,**/docs/**,**/docker/**,**/scripts/**,**/scenarios/**
-Dsonar.sources=./
-Dsonar.sources=./
6 changes: 3 additions & 3 deletions .github/workflows/sonar-pr.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Sonar Scan and Coverage
name: Sonar Scan and Coverage on PRs

on:
workflow_run:
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
# Need to change source in coverage report because it was generated from another context
sed -i 's/\/home\/runner\/work\/acapy\/acapy\//\/github\/workspace\//g' test-reports/coverage.xml
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
uses: SonarSource/sonarqube-scan-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand All @@ -71,4 +71,4 @@ jobs:
-Dsonar.coverage.exclusions=**/tests/**,**/demo/**,**/docs/**,**/docker/**,**/scripts/**,**/scenarios/**
-Dsonar.cpd.exclusions=**/tests/**,**/demo/**,**/docs/**,**/docker/**,**/scripts/**,**/scenarios/**
-Dsonar.python.coverage.reportPaths=test-reports/coverage.xml
-Dsonar.sources=./
-Dsonar.sources=./
2 changes: 1 addition & 1 deletion acapy_agent/anoncreds/models/presentation_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ class Meta:
},
),
},
name="AnoncredPresentationRequestNonRevokedSchema",
name="AnoncredsPresentationRequestNonRevokedSchema",
),
allow_none=True,
required=False,
Expand Down
2 changes: 1 addition & 1 deletion acapy_agent/askar/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def bind_providers(self):
VCHolder,
ClassProvider(
"acapy_agent.storage.vc_holder.askar.AskarVCHolder",
ref(self),
ClassProvider.Inject(Profile),
),
)
if (
Expand Down
8 changes: 4 additions & 4 deletions acapy_agent/protocols/issue_credential/v2_0/message_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,25 @@
# Format specifications
ATTACHMENT_FORMAT = {
CRED_20_PROPOSAL: {
V20CredFormat.Format.ANONCREDS.api: "anoncreds/cred-filter@v2.0",
V20CredFormat.Format.ANONCREDS.api: "anoncreds/credential-filter@v1.0",
V20CredFormat.Format.INDY.api: "hlindy/[email protected]",
V20CredFormat.Format.LD_PROOF.api: "aries/[email protected]",
V20CredFormat.Format.VC_DI.api: "didcomm/[email protected]",
},
CRED_20_OFFER: {
V20CredFormat.Format.ANONCREDS.api: "anoncreds/cred-abstract@v2.0",
V20CredFormat.Format.ANONCREDS.api: "anoncreds/credential-offer@v1.0",
V20CredFormat.Format.INDY.api: "hlindy/[email protected]",
V20CredFormat.Format.LD_PROOF.api: "aries/[email protected]",
V20CredFormat.Format.VC_DI.api: "didcomm/[email protected]",
},
CRED_20_REQUEST: {
V20CredFormat.Format.ANONCREDS.api: "anoncreds/cred-req@v2.0",
V20CredFormat.Format.ANONCREDS.api: "anoncreds/credential-request@v1.0",
V20CredFormat.Format.INDY.api: "hlindy/[email protected]",
V20CredFormat.Format.LD_PROOF.api: "aries/[email protected]",
V20CredFormat.Format.VC_DI.api: "didcomm/[email protected]",
},
CRED_20_ISSUE: {
V20CredFormat.Format.ANONCREDS.api: "anoncreds/cred@v2.0",
V20CredFormat.Format.ANONCREDS.api: "anoncreds/credential@v1.0",
V20CredFormat.Format.INDY.api: "hlindy/[email protected]",
V20CredFormat.Format.LD_PROOF.api: "aries/[email protected]",
V20CredFormat.Format.VC_DI.api: "didcomm/[email protected]",
Expand Down
25 changes: 20 additions & 5 deletions acapy_agent/protocols/issue_credential/v2_0/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from ....messaging.models.openapi import OpenAPISchema
from ....messaging.models.paginated_query import PaginatedQuerySchema, get_limit_offset
from ....messaging.valid import (
ANONCREDS_CRED_DEF_ID_EXAMPLE,
ANONCREDS_DID_EXAMPLE,
ANONCREDS_SCHEMA_ID_EXAMPLE,
INDY_CRED_DEF_ID_EXAMPLE,
Expand Down Expand Up @@ -137,13 +138,24 @@ class V20CredStoreRequestSchema(OpenAPISchema):
class V20CredFilterAnoncredsSchema(OpenAPISchema):
"""Anoncreds credential filtration criteria."""

cred_def_id = fields.Str(
schema_issuer_id = fields.Str(
required=False,
metadata={
"description": "Credential definition identifier",
"description": "Schema issuer ID",
"example": ANONCREDS_DID_EXAMPLE,
},
)
schema_name = fields.Str(
required=False,
metadata={"description": "Schema name", "example": "preferences"},
)
schema_version = fields.Str(
required=False,
metadata={
"description": "Schema version",
"example": MAJOR_MINOR_VERSION_EXAMPLE,
},
)
schema_id = fields.Str(
required=False,
metadata={
Expand All @@ -154,13 +166,16 @@ class V20CredFilterAnoncredsSchema(OpenAPISchema):
issuer_id = fields.Str(
required=False,
metadata={
"description": "Credential issuer DID",
"description": "Credential issuer ID",
"example": ANONCREDS_DID_EXAMPLE,
},
)
epoch = fields.Str(
cred_def_id = fields.Str(
required=False,
metadata={"description": "Credential epoch time", "example": "2021-08-24"},
metadata={
"description": "Credential definition identifier",
"example": ANONCREDS_CRED_DEF_ID_EXAMPLE,
},
)


Expand Down
23 changes: 23 additions & 0 deletions acapy_agent/protocols/issue_credential/v2_0/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,29 @@ async def test_validate_cred_filter_schema(self):
with self.assertRaises(test_module.ValidationError):
schema.validate_fields({"veres-one": {"no": "support"}})

async def test_validate_cred_filter_anoncreds_schema(self):
schema = test_module.V20CredFilterSchema()
schema.validate_fields({"anoncreds": {"issuer_id": TEST_DID}})
schema.validate_fields(
{"anoncreds": {"issuer_id": TEST_DID, "schema_version": "1.0"}}
)
schema.validate_fields(
{
"anoncreds": {"issuer_id": TEST_DID},
}
)
schema.validate_fields(
{
"anoncreds": {},
}
)
with self.assertRaises(test_module.ValidationError):
schema.validate_fields({})
with self.assertRaises(test_module.ValidationError):
schema.validate_fields(["hopeless", "stop"])
with self.assertRaises(test_module.ValidationError):
schema.validate_fields({"veres-one": {"no": "support"}})

async def test_validate_create_schema(self):
schema = test_module.V20IssueCredSchemaCore()
schema.validate(
Expand Down
6 changes: 3 additions & 3 deletions acapy_agent/protocols/present_proof/v2_0/message_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@
# Format specifications
ATTACHMENT_FORMAT = {
PRES_20_PROPOSAL: {
V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof-req@v2.0",
V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof-proposal@v1.0",
V20PresFormat.Format.INDY.api: "hlindy/[email protected]",
V20PresFormat.Format.DIF.api: "dif/presentation-exchange/[email protected]",
},
PRES_20_REQUEST: {
V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof-req@v2.0",
V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof-request@v1.0",
V20PresFormat.Format.INDY.api: "hlindy/[email protected]",
V20PresFormat.Format.DIF.api: "dif/presentation-exchange/[email protected]",
},
PRES_20: {
V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof@v2.0",
V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof@v1.0",
V20PresFormat.Format.INDY.api: "hlindy/[email protected]",
V20PresFormat.Format.DIF.api: "dif/presentation-exchange/[email protected]",
},
Expand Down
11 changes: 9 additions & 2 deletions acapy_agent/vc/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ async def list_credentials_route(request: web.BaseRequest):
holder = context.inject(VCHolder)
try:
search = holder.search_credentials()
records = [record.serialize()["cred_value"] for record in await search.fetch()]
records = {
"results": [
record.serialize()["cred_value"] for record in await search.fetch()
]
}
return web.json_response(records, status=200)
except (StorageError, StorageNotFoundError) as err:
return web.json_response({"message": err.roll_up}, status=400)
Expand Down Expand Up @@ -133,6 +137,9 @@ async def verify_credential_route(request: web.BaseRequest):


@docs(tags=["vc-api"], summary="Store a credential")
@request_schema(web_schemas.StoreCredentialRequest())
@response_schema(web_schemas.StoreCredentialResponse(), 200, description="")
@tenant_authentication
async def store_credential_route(request: web.BaseRequest):
"""Request handler for storing a credential.
Expand All @@ -153,7 +160,7 @@ async def store_credential_route(request: web.BaseRequest):
options = LDProofVCOptions.deserialize(options)

await manager.verify_credential(vc)
await manager.store_credential(vc, options, cred_id)
await manager.store_credential(vc, cred_id)

return web.json_response({"credentialId": cred_id}, status=200)

Expand Down
5 changes: 3 additions & 2 deletions acapy_agent/vc/vc_ld/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,8 @@ async def issue(
async def store_credential(
self,
vc: VerifiableCredential,
options: LDProofVCOptions,
cred_id: Optional[str] = None,
) -> VerifiableCredential:
) -> VCRecord:
"""Store a verifiable credential."""

# Saving expanded type as a cred_tag
Expand Down Expand Up @@ -437,6 +436,8 @@ async def store_credential(

await vc_holder.store_credential(vc_record)

return vc_record

async def verify_credential(
self, vc: VerifiableCredential
) -> DocumentVerificationResult:
Expand Down
14 changes: 13 additions & 1 deletion acapy_agent/vc/vc_ld/models/web_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class ListCredentialsResponse(OpenAPISchema):
"""Response schema for listing credentials."""

results = [fields.Nested(VerifiableCredentialSchema)]
results = fields.List(fields.Nested(VerifiableCredentialSchema))


class FetchCredentialResponse(OpenAPISchema):
Expand Down Expand Up @@ -47,6 +47,18 @@ class VerifyCredentialResponse(OpenAPISchema):
results = fields.Nested(PresentationVerificationResultSchema)


class StoreCredentialRequest(OpenAPISchema):
"""Request schema for verifying an LDP VP."""

verifiableCredential = fields.Nested(VerifiableCredentialSchema)


class StoreCredentialResponse(OpenAPISchema):
"""Request schema for verifying an LDP VP."""

credentialId = fields.Str()


class ProvePresentationRequest(OpenAPISchema):
"""Request schema for proving a presentation."""

Expand Down
2 changes: 1 addition & 1 deletion acapy_agent/vc/vc_ld/tests/test_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ async def test_store(
self.vc.issuer = did.did
self.options.proof_type = Ed25519Signature2018.signature_type
cred = await self.manager.issue(self.vc, self.options)
await self.manager.store_credential(cred, self.options, TEST_UUID)
await self.manager.store_credential(cred, TEST_UUID)
async with self.profile.session() as session:
holder = session.inject(VCHolder)
record = await holder.retrieve_credential_by_id(record_id=TEST_UUID)
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM python:${python_version}-slim-bullseye AS build

WORKDIR /src

ADD . .
COPY . .

RUN pip install --no-cache-dir poetry
RUN poetry build
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.bdd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ FROM faber-alice-demo
RUN pip3 install --no-cache-dir -r demo/requirements.behave.txt

WORKDIR ./demo
ADD demo/multi_ledger_config_bdd.yml ./demo/multi_ledger_config.yml
COPY demo/multi_ledger_config_bdd.yml ./demo/multi_ledger_config.yml
RUN chmod a+w .
ENTRYPOINT ["behave"]
14 changes: 7 additions & 7 deletions docker/Dockerfile.demo
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ RUN mkdir -p bin && curl -L -o bin/jq \
https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 && \
chmod ug+x bin/jq

# Add and install Aries Agent code
# Copy and install Aries Agent code
RUN pip install --no-cache-dir poetry

ADD README.md pyproject.toml poetry.lock ./
COPY README.md pyproject.toml poetry.lock ./

ARG all_extras=0
RUN if ! [ -z ${all_extras} ]; then poetry install --no-root --no-directory --all-extras; else poetry install --no-root --no-directory -E "didcommv2"; fi

ADD acapy_agent ./acapy_agent
ADD scripts ./scripts
COPY acapy_agent ./acapy_agent
COPY scripts ./scripts

RUN pip3 install --no-cache-dir -e .

RUN mkdir demo && chown -R aries:aries demo && chmod -R ug+rw demo

# Add and install demo code
ADD demo/requirements.txt ./demo/requirements.txt
# Copy and install demo code
COPY demo/requirements.txt ./demo/requirements.txt
RUN pip3 install --no-cache-dir -r demo/requirements.txt

ADD demo ./demo
COPY demo ./demo

ENTRYPOINT ["bash", "-c", "demo/ngrok-wait.sh \"$@\"", "--"]
4 changes: 2 additions & 2 deletions docker/Dockerfile.run
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ RUN apt-get update && apt-get install -y curl && apt-get clean
RUN pip install --no-cache-dir poetry

RUN mkdir -p acapy_agent && touch acapy_agent/__init__.py
ADD pyproject.toml poetry.lock README.md ./
COPY pyproject.toml poetry.lock README.md ./
RUN mkdir -p log && chmod -R ug+rw log

ARG all_extras=0
RUN if ! [ -z ${all_extras} ]; then poetry install --all-extras; else poetry install -E "didcommv2"; fi

ADD . .
COPY . .

ENTRYPOINT ["/bin/bash", "-c", "poetry run aca-py \"$@\"", "--"]
4 changes: 2 additions & 2 deletions docker/Dockerfile.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ WORKDIR /usr/src/app

RUN pip install --no-cache-dir poetry

ADD ./README.md pyproject.toml ./poetry.lock ./
COPY ./README.md pyproject.toml ./poetry.lock ./
RUN mkdir acapy_agent && touch acapy_agent/__init__.py

ARG all_extras=0
RUN if ! [ -z ${all_extras} ]; then poetry install --no-directory --all-extras --with=dev; else poetry install --no-directory -E "didcommv2" --with=dev; fi

ADD . .
COPY . .

ENTRYPOINT ["/bin/bash", "-c", "poetry run pytest \"$@\"", "--"]
2 changes: 1 addition & 1 deletion mkdocs-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

mkdocs-material==9.5.47
mkdocs-material==9.5.48
mike==2.1.3
4 changes: 2 additions & 2 deletions open-api/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -7763,7 +7763,7 @@
},
"type" : "object"
},
"AnoncredPresentationRequestNonRevoked" : {
"AnoncredsPresentationRequestNonRevoked" : {
"properties" : {
"from" : {
"description" : "Earliest time of interest in non-revocation interval",
Expand Down Expand Up @@ -7895,7 +7895,7 @@
"type" : "string"
},
"non_revoked" : {
"$ref" : "#/components/schemas/AnoncredPresentationRequestNonRevoked"
"$ref" : "#/components/schemas/AnoncredsPresentationRequestNonRevoked"
},
"nonce" : {
"description" : "Nonce",
Expand Down
Loading

0 comments on commit 764e052

Please sign in to comment.