diff --git a/tests/performance-tests/atala-performance-tests-k6/src/actors/Issuer.ts b/tests/performance-tests/atala-performance-tests-k6/src/actors/Issuer.ts index fa377774fb..d04a1f9624 100644 --- a/tests/performance-tests/atala-performance-tests-k6/src/actors/Issuer.ts +++ b/tests/performance-tests/atala-performance-tests-k6/src/actors/Issuer.ts @@ -82,7 +82,11 @@ export class Issuer extends Actor { createCredentialSchema() { this.schema = this.credentialsService.createCredentialSchema(this.did!); } - + + createCredentialDefinition() { + this.credentialsService.createCredentialDefinition(this.did!, this.schema!); + } + /** * Creates a credential offer for the holder. */ diff --git a/tests/performance-tests/atala-performance-tests-k6/src/common/Config.ts b/tests/performance-tests/atala-performance-tests-k6/src/common/Config.ts index 5adfab1e37..bf4d6e8994 100644 --- a/tests/performance-tests/atala-performance-tests-k6/src/common/Config.ts +++ b/tests/performance-tests/atala-performance-tests-k6/src/common/Config.ts @@ -20,7 +20,7 @@ export const ISSUER_AGENT_URL = __ENV.ISSUER_AGENT_URL || "http://localhost:8080 * API key for the Issuer agent. * If not provided, the default value is an empty string. */ -export const ISSUER_AGENT_API_KEY = __ENV.ISSUER_AGENT_API_KEY || ""; +export const ISSUER_AGENT_API_KEY = __ENV.ISSUER_AGENT_API_KEY || "default"; /** * URL for the Holder agent. @@ -32,7 +32,7 @@ export const HOLDER_AGENT_URL = __ENV.HOLDER_AGENT_URL || "http://localhost:8090 * API key for the Holder agent. * If not provided, the default value is an empty string. */ -export const HOLDER_AGENT_API_KEY = __ENV.HOLDER_AGENT_API_KEY || ""; +export const HOLDER_AGENT_API_KEY = __ENV.HOLDER_AGENT_API_KEY || "default"; /** * URL for the Verifier agent. @@ -44,4 +44,4 @@ export const VERIFIER_AGENT_URL = __ENV.VERIFIER_AGENT_URL || "http://localhost: * API key for the Verifier agent. * If not provided, the default value is an empty string. */ -export const VERIFIER_AGENT_API_KEY = __ENV.VERIFIER_AGENT_API_KEY || ""; +export const VERIFIER_AGENT_API_KEY = __ENV.VERIFIER_AGENT_API_KEY || "default"; diff --git a/tests/performance-tests/atala-performance-tests-k6/src/common/CredentialsService.ts b/tests/performance-tests/atala-performance-tests-k6/src/common/CredentialsService.ts index c55a37ca1d..129ae8f4fe 100644 --- a/tests/performance-tests/atala-performance-tests-k6/src/common/CredentialsService.ts +++ b/tests/performance-tests/atala-performance-tests-k6/src/common/CredentialsService.ts @@ -35,54 +35,42 @@ export class CredentialsService extends HttpService { return this.toJson(res) as unknown as IssueCredentialRecord; } - createCredentialSchema(issuingDid: string): CredentialSchemaResponse { + createCredentialDefinition(issuingDid: string, schema: CredentialSchemaResponse) { const payload = ` { "name": "${crypto.randomUUID()}}", + "description": "Birth certificate Anoncred Credential Definition", + "version": "1.0.0", + "tag": "Licence", + "author": "${issuingDid}", + "schemaId": "${ISSUER_AGENT_URL.replace("localhost", "host.docker.internal")}/schema-registry/schemas/${schema.guid}", + "signatureType": "CL", + "supportRevocation": false + } + `; + this.post("credential-definition-registry/definitions", payload); + } + + createCredentialSchema(issuingDid: string) { + const payload = ` + { + "name": "${crypto.randomUUID()}", "version": "1.0.0", "description": "Simple credential schema for the driving licence verifiable credential.", - "type": "https://w3c-ccg.github.io/vc-json-schemas/schema/2.0/schema.json", + "type": "AnoncredSchemaV1", "schema": { - "$id": "https://example.com/driving-license-1.0", - "$schema": "https://json-schema.org/draft/2020-12/schema", - "description": "Driving License", - "type": "object", - "properties": { - "emailAddress": { - "type": "string", - "format": "email" - }, - "givenName": { - "type": "string" - }, - "familyName": { - "type": "string" - }, - "dateOfIssuance": { - "type": "string" - }, - "drivingLicenseID": { - "type": "string" - }, - "drivingClass": { - "type": "integer" - } - }, - "required": [ - "emailAddress", - "familyName", - "dateOfIssuance", - "drivingLicenseID", - "drivingClass" - ], - "additionalProperties": false + "name": "${crypto.randomUUID()}", + "version": "1.0.0", + "attrNames": [ + "emailAddress", + "familyName" + ], + "issuerId": "${issuingDid}" }, + "author": "${issuingDid}", "tags": [ - "driving", - "licence", - "id" - ], - "author": "${issuingDid}" + "Licence" + ] } ` const res = this.post("schema-registry/schemas", payload); diff --git a/tests/performance-tests/atala-performance-tests-k6/src/tests/credentials/credential-definition-test.ts b/tests/performance-tests/atala-performance-tests-k6/src/tests/credentials/credential-definition-test.ts new file mode 100644 index 0000000000..883f5234c8 --- /dev/null +++ b/tests/performance-tests/atala-performance-tests-k6/src/tests/credentials/credential-definition-test.ts @@ -0,0 +1,41 @@ +import { group } from "k6"; +import { Options } from "k6/options"; +import { Issuer } from "../../actors"; +import { defaultOptions } from "../../scenarios/default"; +import merge from "ts-deepmerge"; +import { CredentialSchemaResponse } from "@input-output-hk/prism-typescript-client"; + +export const localOptions: Options = { + // Important to have this threshold to have a special line for this group in the report + thresholds: { + 'group_duration{group:::Issuer creates credential definition}': ['avg > 0'] + } +} +export let options: Options = merge(localOptions, defaultOptions) + +export const issuer = new Issuer(); + +export function setup() { + group("Issuer publishes DID", function () { + issuer.createUnpublishedDid(); + issuer.publishDid(); + }); + + group("Issuer creates credential schema", function () { + issuer.createCredentialSchema(); + }); + + return { + issuerDid: issuer.did, schema: issuer.schema + }; +} + +export default (data: { issuerDid: string, schema: CredentialSchemaResponse }) => { + // This is the only way to pass data from setup to default + issuer.did = data.issuerDid; + issuer.schema = data.schema; + + group("Issuer creates credential definition", function () { + issuer.createCredentialDefinition(); + }); +};