Skip to content
Snippets Groups Projects
Commit a65b0650 authored by Rosen Georgiev's avatar Rosen Georgiev
Browse files

added gitingore

parent 5702310d
No related branches found
No related tags found
1 merge request!17added tests to proof manager
Showing
with 647 additions and 7 deletions
......@@ -19,6 +19,7 @@ package api.test.rest;
import api.test.rest.pojo.connection.Connection;
import api.test.rest.pojo.credentialDef.CredentialDef;
import api.test.rest.pojo.presentationRequest.Presentation;
import api.test.rest.pojo.schema.Schema;
public class RestSessionContainer {
......@@ -26,7 +27,15 @@ public class RestSessionContainer {
private Schema currentSchema;
private CredentialDef currentCredentialDef;
private Connection currentConnection;
private Presentation currentPresentation;
public Presentation getCurrentPresentation() {
return currentPresentation;
}
public void setCurrentPresentation(Presentation currentPresentation) {
this.currentPresentation = currentPresentation;
}
public Connection getCurrentConnection() {
return currentConnection;
......
package api.test.rest.pojo.presentationRequest;
import com.google.gson.annotations.SerializedName;
public class Data {
@SerializedName("connectionId")
private String mConnectionId;
@SerializedName("createdDate")
private String mCreatedDate;
@SerializedName("credentialDefId")
private String mCredentialDefId;
@SerializedName("id")
private String mId;
@SerializedName("presentationId")
private String mPresentationId;
@SerializedName("presentationMessage")
private String mPresentationMessage;
@SerializedName("schemaId")
private String mSchemaId;
@SerializedName("status")
private String mStatus;
@SerializedName("theirDid")
private String mTheirDid;
@SerializedName("updatedDate")
private String mUpdatedDate;
public String getConnectionId() {
return mConnectionId;
}
public void setConnectionId(String connectionId) {
mConnectionId = connectionId;
}
public String getCreatedDate() {
return mCreatedDate;
}
public void setCreatedDate(String createdDate) {
mCreatedDate = createdDate;
}
public String getCredentialDefId() {
return mCredentialDefId;
}
public void setCredentialDefId(String credentialDefId) {
mCredentialDefId = credentialDefId;
}
public String getId() {
return mId;
}
public void setId(String id) {
mId = id;
}
public String getPresentationId() {
return mPresentationId;
}
public void setPresentationId(String presentationId) {
mPresentationId = presentationId;
}
public String getPresentationMessage() {
return mPresentationMessage;
}
public void setPresentationMessage(String presentationMessage) {
mPresentationMessage = presentationMessage;
}
public String getSchemaId() {
return mSchemaId;
}
public void setSchemaId(String schemaId) {
mSchemaId = schemaId;
}
public String getStatus() {
return mStatus;
}
public void setStatus(String status) {
mStatus = status;
}
public String getTheirDid() {
return mTheirDid;
}
public void setTheirDid(String theirDid) {
mTheirDid = theirDid;
}
public String getUpdatedDate() {
return mUpdatedDate;
}
public void setUpdatedDate(String updatedDate) {
mUpdatedDate = updatedDate;
}
}
package api.test.rest.pojo.presentationRequest;
import com.google.gson.annotations.SerializedName;
public class Presentation {
@SerializedName("data")
private Data mData;
@SerializedName("message")
private String mMessage;
@SerializedName("statusCode")
private Long mStatusCode;
public Data getData() {
return mData;
}
public void setData(Data data) {
mData = data;
}
public String getMessage() {
return mMessage;
}
public void setMessage(String message) {
mMessage = message;
}
public Long getStatusCode() {
return mStatusCode;
}
public void setStatusCode(Long statusCode) {
mStatusCode = statusCode;
}
}
{
"successful_creation": {
"schemaName":"",
"attributes":["fName","lName"],
"options": {
"type":"Aries1.0",
"credentialDefinationName":"Test"
}
}
}
\ No newline at end of file
{
"successful_creation": {
"comment": "Tested participant",
"attributes": [
{
"attribute_name": "fName",
"value": "1",
"condition": "true"
}
],
"schemaId": "",
"credentialDefId": "",
"connectionId": ""
}
}
\ No newline at end of file
......@@ -47,9 +47,7 @@
"updatedDate": {
"type": "string"
},
"expirationDate": {
"type": "string"
}
"expirationDate": { "type": ["null", "string"] }
},
"required": [
"id",
......
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"statusCode": {
"type": "integer"
},
"message": {
"type": "string"
},
"data": {
"type": "object",
"properties": {
"count": {
"type": "integer"
},
"records": {
"type": "array",
"items": [
{
"type": "object",
"properties": {
"id": {
"type": "string"
},
"presentationId": {
"type": "string"
},
"connectionId": {
"type": "string"
},
"credentialDefId": {
"type": "string"
},
"schemaId": {
"type": "string"
},
"theirDid": {
"type": "string"
},
"status": {
"type": "string"
},
"createdDate": {
"type": "string"
},
"updatedDate": {
"type": "string"
}
},
"required": [
"id",
"presentationId",
"connectionId",
"credentialDefId",
"schemaId",
"theirDid",
"status",
"createdDate",
"updatedDate"
]
}
]
}
},
"required": [
"count",
"records"
]
}
},
"required": [
"statusCode",
"message",
"data"
]
}
\ No newline at end of file
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"statusCode": {
"type": "integer"
},
"message": {
"type": "string"
},
"data": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"presentationId": {
"type": "string"
},
"connectionId": {
"type": "string"
},
"credentialDefId": {
"type": "string"
},
"schemaId": {
"type": "string"
},
"theirDid": {
"type": "string"
},
"status": {
"type": "string"
},
"createdDate": {
"type": "string"
},
"updatedDate": {
"type": "string"
},
"presentationMessage": {
"type": "string"
}
},
"required": [
"id",
"presentationId",
"connectionId",
"credentialDefId",
"schemaId",
"theirDid",
"status",
"createdDate",
"updatedDate",
"presentationMessage"
]
}
},
"required": [
"statusCode",
"message",
"data"
]
}
\ No newline at end of file
......@@ -19,14 +19,18 @@ package api.test.rest.ocm.proof;
import api.test.core.BaseStepDefinitions;
import api.test.rest.RestSessionContainer;
import core.DataContainer;
import core.Request;
import core.Response;
import core.RestClient;
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 core.*;
import cucumber.api.java.en.Given;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.HashMap;
public class ProofStepDefinitions extends BaseStepDefinitions {
private static final Logger logger = LogManager.getLogger(ProofStepDefinitions.class.getSimpleName());
RestSessionContainer restSessionContainer;
......@@ -48,4 +52,89 @@ public class ProofStepDefinitions extends BaseStepDefinitions {
addRequest(currentRequest);
addResponse(response);
}
@Given("^I send presentation request via OCM Api")
public void I_send_presentation_request_via_OCM_Api() {
currentRequest.setPath("/proof/v1/send-presentation-request");
Response response = RestClient.post(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@Given("^I send presentation request with the current data via OCM Api")
public void I_send_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));
I_send_presentation_request_via_OCM_Api();
}
@Given("^I get all proof presentations via OCM Api")
public void I_get_all_proof_presentations_via_OCM_Api() {
currentRequest.setPath("/proof/v1/find-proof-presentation");
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@Given("^I get all proof presentations with pageSize \\{(.*?)\\} and page \\{(.*?)\\} via OCM api")
public void I_get_all_proof_presentations_with_pageSize_and_page_via_OCM_api(String pageSize,String page) {
HashMap<String, String> queryParams = new HashMap<>();
queryParams.put("pageSize",pageSize);
queryParams.put("page",page);
currentRequest.setQueryParams(queryParams);
I_get_all_proof_presentations_via_OCM_Api();
}
@Given("^I get proof presentations with the current presentationId via OCM Api")
public void I_get_all_proof_presentations_with_the_current_presentationId_via_OCM_Api() {
I_get_proof_presentations_with_presentationId_via_OCM_Api(restSessionContainer.getCurrentPresentation().getData().getPresentationId());
}
@Given("^I get proof presentations with presentationId \\{(.*?)\\} via OCM Api")
public void I_get_proof_presentations_with_presentationId_via_OCM_Api(String presentationId) {
currentRequest.setPath("/proof/v1/find-by-presentation-id?presentationId="+ presentationId);
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@Given("^I send out of bound presentation request via OCM Api")
public void I_send_out_of_bound_presentation_request_via_OCM_Api() {
currentRequest.setPath("/proof/v1/send-out-of-band-presentation-request");
Response response = RestClient.post(currentRequest);
addRequest(currentRequest);
addResponse(response);
if (getLastResponse() != null && getLastResponse().getStatusCode() == 201) {
restSessionContainer.setCurrentPresentation(JsonUtils.getResourceFromResponse(getLastResponse(), Presentation.class));
}
}
@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));
I_send_out_of_bound_presentation_request_via_OCM_Api();
}
}
\ No newline at end of file
#Copyright (c) 2018 Vereign AG [https://www.vereign.com]
#
#This is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as
#published by the Free Software Foundation, either version 3 of the
#License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU Affero General Public License for more details.
#
#You should have received a copy of the GNU Affero General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#http://localhost/ocm/proof/v1/find-by-presentation-id?presentationId={{presentation-id}}
#Author: Rosen Georgiev rosen.georgiev@vereign.com
#NOTE: Cannot be fully tested, because it needs connection to be made with PCM.
@rest @all @ocm @proof
Feature: API - OCM - proof - v1 - find-by-presentation-id GET
This request is used to fetch proof presentation request information for the presentation id provided in query parameter.
It also provides state of the proof presentation request.
Background:
Given we are testing the OCM Api
@presentation @negative
Scenario: OCM - Proof - Get proof presentation with presentationId - Positive
Given I get proof presentations with presentationId {nonExistentId} via OCM Api
Then the field {statusCode} contains the value {404}
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
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
#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}
#Get the request via presentationid
And I clear the request body
Given I get proof presentations with the current presentationId via OCM Api
Then the field {statusCode} contains the value {200}
And the status code should be {200}
Then the field {message} contains the value {Proof presentation fetch successfully}
Then the field {$.data.state} contains the value {request-sent}
\ No newline at end of file
#Copyright (c) 2018 Vereign AG [https://www.vereign.com]
#
#This is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as
#published by the Free Software Foundation, either version 3 of the
#License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU Affero General Public License for more details.
#
#You should have received a copy of the GNU Affero General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#http://localhost/ocm/proof/v1/find-proof-presentation
#Author: Rosen Georgiev rosen.georgiev@vereign.com
@rest @all @ocm @proof
Feature: API - OCM - proof - v1 - find-proof-presentation GET
This request fetches the all the proof presentation requests for the participant.
The records can be filtered using provided query parameters.
Background:
Given we are testing the OCM Api
@proof
Scenario: OCM - Proof - Get all Proof Presentations - Positive
Given I get all proof presentations via OCM Api
Then the field {statusCode} contains the value {200}
And the status code should be {200}
Then the field {message} contains the value {Proof presentation fetch successfully}
And the response is valid according to the {Proof_GET_find_proof_presentation.json} REST schema
@proof
Scenario: OCM - Proof - Get all Proof Presentations with pagination - Positive
Given I get all proof presentations with pageSize {5} and page {0} via OCM api
Then the field {statusCode} contains the value {200}
And the status code should be {200}
Then the field {message} contains the value {Proof presentation fetch successfully}
And the response is valid according to the {Proof_GET_find_proof_presentation.json} REST schema
And the field {$.data.records} contains {5} elements
@proof @negative
Scenario: OCM - Proof - Try to get presentations with out of bounds pagination - Negative
Given I get all proof presentations with pageSize {9999} and page {999} via OCM api
Then the field {statusCode} contains the value {200}
And the status code should be {200}
Then the field {message} contains the value {Proof presentation fetch successfully}
And the response is valid according to the {Proof_GET_find_proof_presentation.json} REST schema
And the field {$.data.records} contains {0} elements
\ No newline at end of file
#Copyright (c) 2018 Vereign AG [https://www.vereign.com]
#
#This is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as
#published by the Free Software Foundation, either version 3 of the
#License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU Affero General Public License for more details.
#
#You should have received a copy of the GNU Affero General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#http://localhost/ocm/attestation/v1/send-out-of-band-presentation-request
#Author: Rosen Georgiev rosen.georgiev@vereign.com
@rest @all @ocm
Feature: API - OCM - proof - v1 - send-out-of-band-presentation-request POST
From a verifier to a prover, the out of band presentation request message describes values
that need to be revealed and predicates that need to be fulfilled.
The Out-of-band protocol is used when you wish to engage with another
agent and you don't have a DIDComm connection to use for the interaction.
NOTE: This request needs PCM to be able to be called
Background:
Given we are testing the OCM Api
@proof @bug-proof-25 @bug-proof-24 @bug-proof-23
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
#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.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
#Copyright (c) 2018 Vereign AG [https://www.vereign.com]
#
#This is free software: you can redistribute it and/or modify
#it under the terms of the GNU Affero General Public License as
#published by the Free Software Foundation, either version 3 of the
#License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU Affero General Public License for more details.
#
#You should have received a copy of the GNU Affero General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
#http://localhost/ocm/attestation/v1/send-presentation-request
#Author: Rosen Georgiev rosen.georgiev@vereign.com
@rest @all @ocm
Feature: API - OCM - proof - v1 - send-presentation-request POST
From a verifier to a prover, the presentation request message describes values
that need to be revealed and predicates that need to be fulfilled.
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
Background:
Given we are testing the OCM Api
@proof @wip
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
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 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}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment