From 173a9a7b2b92d6161e1c3037bb066c48485c3778 Mon Sep 17 00:00:00 2001 From: rosengeorgiev <rosen.georgiev@vereign.com> Date: Mon, 19 Sep 2022 11:45:40 +0300 Subject: [PATCH] cleanup --- src/main/java/core/DataContainer.java | 5 +- .../json/ProofSendOOBPresentationRequest.json | 68 +++++++++++++++++-- .../json/ProofSendPresentationRequest.json | 12 ++-- .../rest/ocm/proof/ProofStepDefinitions.java | 48 +++++++++---- .../v1/find-by-presentation-id/GET.feature | 34 +++++----- .../POST.feature | 55 +++++++++------ .../v1/send-presentation-request/POST.feature | 8 ++- 7 files changed, 160 insertions(+), 70 deletions(-) diff --git a/src/main/java/core/DataContainer.java b/src/main/java/core/DataContainer.java index 6446108..582afec 100644 --- a/src/main/java/core/DataContainer.java +++ b/src/main/java/core/DataContainer.java @@ -20,10 +20,7 @@ package core; import java.util.HashMap; import java.util.Map; -/** - * The purpose of this class is to store data that needs to be passed between scenario steps. For RID is used only for - * scenarios steps that are from different packages. - */ + public class DataContainer { private Map<String, Object> objectMap; diff --git a/src/main/resources/REST/json/ProofSendOOBPresentationRequest.json b/src/main/resources/REST/json/ProofSendOOBPresentationRequest.json index dca17e3..824a04d 100644 --- a/src/main/resources/REST/json/ProofSendOOBPresentationRequest.json +++ b/src/main/resources/REST/json/ProofSendOOBPresentationRequest.json @@ -1,10 +1,66 @@ { "successful_creation": { - "schemaName":"", - "attributes":["fName","lName"], + "attributes": [ + { + "schemaId": "7KuDTpQh3GJ7Gp6kErpWvM:2:automation_testing_schema1-01:1.1.1663576062630", + "credentialDefId": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:493091:Automation_CredDef_001", + "attributeName": "lName", + "value": "", + "condition": "" + } + ], "options": { - "type":"Aries1.0", - "credentialDefinationName":"Test" - } + "type": "Aries1.0", + "credentialDefinationId": "Test" + }, + "connectionId": "53f412bc-3897-4990-b6ef-5b2f620db50e" + }, + "empty_schemaID": { + "attributes": [ + { + "schemaId": "", + "credentialDefId": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:493069:Automation_CredDef_001", + "attributeName": "lName", + "value": "", + "condition": "" + } + ], + "options": { + "type": "Aries1.0", + "credentialDefinationId": "Test" + }, + "connectionId": "60812bd1-9f87-4846-8ca7-340186df3d8f" + }, + "empty_credentialDefId": { + "attributes": [ + { + "schemaId": "7KuDTpQh3GJ7Gp6kErpWvM:2:automation_testing_schema1-01:1.1.1663576062630", + "credentialDefId": "", + "attributeName": "lName", + "value": "", + "condition": "" + } + ], + "options": { + "type": "Aries1.0", + "credentialDefinationId": "Test" + }, + "connectionId": "60812bd1-9f87-4846-8ca7-340186df3d8f" + }, + "empty_connectionId": { + "attributes": [ + { + "schemaId": "7KuDTpQh3GJ7Gp6kErpWvM:2:automation_testing_schema1-01:1.1.1663576062630", + "credentialDefId": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:493091:Automation_CredDef_001", + "attributeName": "lName", + "value": "", + "condition": "" + } + ], + "options": { + "type": "Aries1.0", + "credentialDefinationId": "Test" + }, + "connectionId": "" } -} \ No newline at end of file +} diff --git a/src/main/resources/REST/json/ProofSendPresentationRequest.json b/src/main/resources/REST/json/ProofSendPresentationRequest.json index 77a4f2b..e543a8d 100644 --- a/src/main/resources/REST/json/ProofSendPresentationRequest.json +++ b/src/main/resources/REST/json/ProofSendPresentationRequest.json @@ -3,13 +3,13 @@ "comment": "Tested participant", "attributes": [ { - "attribute_name": "fName", - "value": "1", - "condition": "true" + "schemaId": "testt", + "credentialDefId": "7KuDTpQh3GJ7Gp6kErpWvM:3:CL:367830:Enrollment_credDef-0107232", + "attributeName": "lName", + "value": "", + "condition": "" } ], - "schemaId": "", - "credentialDefId": "", - "connectionId": "" + "connectionId": "31b1c05b-8b0a-41b2-b819-58214d683040" } } \ No newline at end of file diff --git a/src/test/java/api/test/rest/ocm/proof/ProofStepDefinitions.java b/src/test/java/api/test/rest/ocm/proof/ProofStepDefinitions.java index 091ac90..0c1a12f 100644 --- a/src/test/java/api/test/rest/ocm/proof/ProofStepDefinitions.java +++ b/src/test/java/api/test/rest/ocm/proof/ProofStepDefinitions.java @@ -19,13 +19,12 @@ package api.test.rest.ocm.proof; import api.test.core.BaseStepDefinitions; import api.test.rest.RestSessionContainer; -import api.test.rest.pojo.credentialDef.CredentialDef; import api.test.rest.pojo.presentationRequest.Presentation; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; +import com.google.gson.*; +import com.jayway.jsonpath.JsonPath; import core.*; import cucumber.api.java.en.Given; +import net.minidev.json.writer.JsonReader; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -69,9 +68,19 @@ public class ProofStepDefinitions extends BaseStepDefinitions { // only try to load body as JsonObject if it is not null. JsonObject jsonObject = new JsonObject(); if (jsonElement != null) jsonObject = jsonElement.getAsJsonObject();; + jsonObject.addProperty("connectionId", restSessionContainer.getCurrentConnection().getData().getConnection().getId()); - jsonObject.addProperty("credentialDefId", restSessionContainer.getCurrentCredentialDef().getData().getCredDefId()); - jsonObject.addProperty("schemaId", restSessionContainer.getCurrentSchema().getData().getSchemaID()); + JsonObject newAttributes = new JsonObject(); + newAttributes.addProperty("schemaId",restSessionContainer.getCurrentSchema().getData().getSchemaID()); + newAttributes.addProperty("credentialDefId",restSessionContainer.getCurrentCredentialDef().getData().getCredDefId()); + newAttributes.addProperty("attributeName","lName"); + newAttributes.addProperty("value",""); + newAttributes.addProperty("condition",""); + JsonArray ja = new JsonArray(); + ja.add(newAttributes); + + jsonObject.add("attributes",ja); + currentRequest.setBody(gson.toJson(jsonObject)); I_send_presentation_request_via_OCM_Api(); @@ -125,16 +134,25 @@ public class ProofStepDefinitions extends BaseStepDefinitions { @Given("^I send out of bound presentation request with the current data via OCM Api") public void I_send_out_of_bound_presentation_request_with_the_current_data_via_OCM_Api() { -// Gson gson = new Gson(); -// JsonElement jsonElement = gson.fromJson(currentRequest.getBody(), JsonElement.class); -// // only try to load body as JsonObject if it is not null. -// JsonObject jsonObject = new JsonObject(); -// if (jsonElement != null) jsonObject = jsonElement.getAsJsonObject();; -// jsonObject.addProperty("connectionId", restSessionContainer.getCurrentConnection().getData().getConnection().getId()); -// jsonObject.addProperty("credentialDefId", restSessionContainer.getCurrentCredentialDef().getData().getCredDefId()); -// jsonObject.addProperty("schemaId", restSessionContainer.getCurrentSchema().getData().getSchemaID()); -// currentRequest.setBody(gson.toJson(jsonObject)); + Gson gson = new Gson(); + JsonElement jsonElement = gson.fromJson(currentRequest.getBody(), JsonElement.class); + // only try to load body as JsonObject if it is not null. + JsonObject jsonObject = new JsonObject(); + if (jsonElement != null) jsonObject = jsonElement.getAsJsonObject();; + + jsonObject.addProperty("connectionId", restSessionContainer.getCurrentConnection().getData().getConnection().getId()); + JsonObject newAttributes = new JsonObject(); + newAttributes.addProperty("schemaId",restSessionContainer.getCurrentSchema().getData().getSchemaID()); + newAttributes.addProperty("credentialDefId",restSessionContainer.getCurrentCredentialDef().getData().getCredDefId()); + newAttributes.addProperty("attributeName","lName"); + newAttributes.addProperty("value",""); + newAttributes.addProperty("condition",""); + JsonArray ja = new JsonArray(); + ja.add(newAttributes); + + jsonObject.add("attributes",ja); + currentRequest.setBody(gson.toJson(jsonObject)); I_send_out_of_bound_presentation_request_via_OCM_Api(); } } \ No newline at end of file diff --git a/src/test/resources/features/ocm/proof/v1/find-by-presentation-id/GET.feature b/src/test/resources/features/ocm/proof/v1/find-by-presentation-id/GET.feature index eee4e71..89a6c7a 100644 --- a/src/test/resources/features/ocm/proof/v1/find-by-presentation-id/GET.feature +++ b/src/test/resources/features/ocm/proof/v1/find-by-presentation-id/GET.feature @@ -35,24 +35,24 @@ Feature: API - OCM - proof - v1 - find-by-presentation-id GET And the status code should be {404} Then the field {message} contains the value {proof with proofRecordId "nonExistentId" not found.} - @proof @bug-proof-25 @bug-proof-24 @bug-proof-23 + @proof @bug-proof-25 @bug-proof-24 Scenario: OCM - Proof - Get OOB presentation request via presentationId - Positive -# #Create a new member process connection -# Given an administrator generates a QR code by creating a connection with alias {member} via OCM api -# Then the field {statusCode} contains the value {200} -# And the status code should be {201} -# #Creation of the schema -# And I clear the query parameters -# And I clear the request body -# Given I load the REST request {AttestationCreateSchemas.json} with profile {successful_creation} -# Then I create a new schema with random version via Attestation Manager in OCM api -# And the status code should be {201} -# #Creation of the Credential definition -# And I clear the request body -# Given I load the REST request {AttestationCreateCredentialDef.json} with profile {successful_creation} -# Then I create a new credential definition with the current schemaId via OCM Api -# And the status code should be {201} -# And I clear the request body + #Create a new member process connection + Given an administrator generates a QR code by creating a connection with alias {member} via OCM api + Then the field {statusCode} contains the value {200} + And the status code should be {201} + #Creation of the schema + And I clear the query parameters + And I clear the request body + Given I load the REST request {AttestationCreateSchemas.json} with profile {successful_creation} + Then I create a new schema with random version via Attestation Manager in OCM api + And the status code should be {201} + #Creation of the Credential definition + And I clear the request body + Given I load the REST request {AttestationCreateCredentialDef.json} with profile {successful_creation} + Then I create a new credential definition with the current schemaId via OCM Api + And the status code should be {201} + And I clear the request body #Send Out of Bound Presentation Request Given I load the REST request {ProofSendOOBPresentationRequest.json} with profile {successful_creation} Then I send out of bound presentation request with the current data via OCM Api diff --git a/src/test/resources/features/ocm/proof/v1/send-out-of-band-presentation-request/POST.feature b/src/test/resources/features/ocm/proof/v1/send-out-of-band-presentation-request/POST.feature index 58258e8..b4cae43 100644 --- a/src/test/resources/features/ocm/proof/v1/send-out-of-band-presentation-request/POST.feature +++ b/src/test/resources/features/ocm/proof/v1/send-out-of-band-presentation-request/POST.feature @@ -29,30 +29,47 @@ Feature: API - OCM - proof - v1 - send-out-of-band-presentation-request POST Background: Given we are testing the OCM Api - @proof @bug-proof-25 @bug-proof-24 @bug-proof-23 + @proof @bug-proof-25 @bug-proof-24 Scenario: OCM - Proof - Create out of bounds presentation - Positive -# #Create a new member process connection -# Given an administrator generates a QR code by creating a connection with alias {member} via OCM api -# Then the field {statusCode} contains the value {200} -# And the status code should be {201} -# #Creation of the schema -# And I clear the query parameters -# And I clear the request body -# Given I load the REST request {AttestationCreateSchemas.json} with profile {successful_creation} -# Then I create a new schema with random version via Attestation Manager in OCM api -# And the status code should be {201} -# #Creation of the Credential definition -# And I clear the request body -# Given I load the REST request {AttestationCreateCredentialDef.json} with profile {successful_creation} -# Then I create a new credential definition with the current schemaId via OCM Api -# And the status code should be {201} -# And I clear the request body + #Create a new member process connection + Given an administrator generates a QR code by creating a connection with alias {member} via OCM api + Then the field {statusCode} contains the value {200} + And the status code should be {201} + #Creation of the schema + And I clear the query parameters + And I clear the request body + Given I load the REST request {AttestationCreateSchemas.json} with profile {successful_creation} + Then I create a new schema with random version via Attestation Manager in OCM api + And the status code should be {201} + #Creation of the Credential definition + And I clear the request body + Given I load the REST request {AttestationCreateCredentialDef.json} with profile {successful_creation} + Then I create a new credential definition with the current schemaId via OCM Api + And the status code should be {201} + And I clear the request body #Send Out of Bound Presentation Request Given I load the REST request {ProofSendOOBPresentationRequest.json} with profile {successful_creation} Then I send out of bound presentation request with the current data via OCM Api And the status code should be {201} Then the field {statusCode} contains the value {201} Then the field {message} contains the value {Presentation request send successfully} - Then the field {$.data.credentialDefId} contains the value {Test} + Then the field {$.data.credentialDefId} contains the value {} + Then the field {$.data.status} contains the value {request-sent} + And the response is valid according to the {Proof_POST_OOB_presentation_request.json} REST schema + + @proof @bug-proof-25 @bug-proof-24 + Scenario Outline: OCM - Proof - Try to Create out of bounds presentation with <profile> - Negative + #Send Out of Bound Presentation Request + Given I load the REST request {ProofSendOOBPresentationRequest.json} with profile {<profile>} + Then I send out of bound presentation request via OCM Api + And the status code should be {201} + Then the field {statusCode} contains the value {201} + Then the field {message} contains the value {Presentation request send successfully} + Then the field {$.data.credentialDefId} contains the value {} Then the field {$.data.status} contains the value {request-sent} - And the response is valid according to the {Proof_POST_OOB_presentation_request.json} REST schema \ No newline at end of file + And the response is valid according to the {Proof_POST_OOB_presentation_request.json} REST schema + Examples: + | profile | + | empty_schemaID | + | empty_credentialDefId | + | empty_connectionId | \ No newline at end of file diff --git a/src/test/resources/features/ocm/proof/v1/send-presentation-request/POST.feature b/src/test/resources/features/ocm/proof/v1/send-presentation-request/POST.feature index b47bc3b..052c208 100644 --- a/src/test/resources/features/ocm/proof/v1/send-presentation-request/POST.feature +++ b/src/test/resources/features/ocm/proof/v1/send-presentation-request/POST.feature @@ -24,12 +24,12 @@ Feature: API - OCM - proof - v1 - send-presentation-request POST In Hyperledger Indy, this message is required, because it forces the Issuer to make a cryptographic commitment to the set of fields in the final credential and thus prevents Issuers from inserting spurious data. - NOTE: This request needs PCM to be able to be called + NOTE: This request needs PCM to be able to be properly tested Background: Given we are testing the OCM Api - @proof @wip + @proof Scenario: OCM - Proof - Try to Create offer of the currently created credential for untrusted connection - Negative #Create a new member process connection Given an administrator generates a QR code by creating a connection with alias {member} via OCM api @@ -50,5 +50,7 @@ Feature: API - OCM - proof - v1 - send-presentation-request POST #Send Presentation Request Given I load the REST request {ProofSendPresentationRequest.json} with profile {successful_creation} Then I send presentation request with the current data via OCM Api - And the status code should be {201} + And the status code should be {400} + Then the field {statusCode} contains the value {400} + Then the field {message} contains the value {Could not get schema or connection details. please try again.} -- GitLab