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

Merge branch 'getCredentialByFilters' into 'main'

added tests for get credentils with filters

See merge request !21
parents 87b21441 bb02e47c
No related branches found
No related tags found
1 merge request!21added tests for get credentils with filters
Pipeline #59823 failed with stage
in 33 seconds
......@@ -41,6 +41,21 @@ if (project.hasProperty("baseUrl")) {
baseUrl = project.property("baseUrl")
}
def projectLocation
if (project.hasProperty("projectLocation")) {
projectLocation = project.property("projectLocation")
}
def isHeadless
if(project.hasProperty("isHeadless")){
isHeadless = project.property("isHeadless")
}
def deviceType
if(project.hasProperty("deviceType")){
deviceType = project.property("deviceType")
}
tasks.withType(Test) {
systemProperties = System.getProperties()
......@@ -55,6 +70,9 @@ task regressionSuite(type: Test) {
}
systemProperty "file.encoding", "utf-8"
systemProperty "baseUrl", "${baseUrl}"
systemProperty "isHeadless", "${isHeadless}"
systemProperty "deviceType", "${deviceType}"
systemProperty "projectLocation", "${projectLocation}"
systemProperties System.getProperties()
......@@ -85,4 +103,8 @@ dependencies {
implementation group: 'net.sourceforge.tess4j', name: 'tess4j', version: '4.4.1'
implementation 'io.github.prashant-ramcharan:courgette-jvm:3.+'
implementation group: 'org.seleniumhq.selenium', name: 'selenium-server', version: '+'
implementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '+'
implementation group: 'io.appium', name: 'java-client', version: '+'
}
\ No newline at end of file
......@@ -18,6 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package api.test.rest;
import api.test.rest.pojo.connection.Connection;
import api.test.rest.pojo.credential.Credential;
import api.test.rest.pojo.credentialDef.CredentialDef;
import api.test.rest.pojo.presentationRequest.Presentation;
import api.test.rest.pojo.schema.Schema;
......@@ -29,6 +30,10 @@ public class RestSessionContainer {
private Connection currentConnection;
private Presentation currentPresentation;
private Record currentCredential;
private Credential currentCredentialData;
public Presentation getCurrentPresentation() {
return currentPresentation;
}
......@@ -60,5 +65,21 @@ public class RestSessionContainer {
public void setCurrentSchema(Schema currentSchema) {
this.currentSchema = currentSchema;
}
public Record getCurrentCredential() {
return currentCredential;
}
public void setCurrentCredential(Record currentCredential) {
this.currentCredential = currentCredential;
}
public Credential getCurrentCredentialData() {
return currentCredentialData;
}
public void setCurrentCredentialData(Credential currentCredentialData) {
this.currentCredentialData = currentCredentialData;
}
}
package api.test.rest.pojo.credential;
import com.google.gson.annotations.SerializedName;
public class Credential {
@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;
}
}
package api.test.rest.pojo.credential;
import java.util.List;
import com.google.gson.annotations.SerializedName;
public class Data {
@SerializedName("count")
private Long mCount;
@SerializedName("records")
private List<Record> mRecords;
public Long getCount() {
return mCount;
}
public void setCount(Long count) {
mCount = count;
}
public List<Record> getRecords() {
return mRecords;
}
public void setRecords(List<Record> records) {
mRecords = records;
}
}
package api.test.rest.pojo.credential;
import com.google.gson.annotations.SerializedName;
public class Record {
@SerializedName("connectionId")
private String mConnectionId;
@SerializedName("createdDate")
private String mCreatedDate;
@SerializedName("credDefId")
private String mCredDefId;
@SerializedName("credentialId")
private String mCredentialId;
@SerializedName("expirationDate")
private Object mExpirationDate;
@SerializedName("id")
private String mId;
@SerializedName("principalDid")
private String mPrincipalDid;
@SerializedName("state")
private String mState;
@SerializedName("threadId")
private String mThreadId;
@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 getCredDefId() {
return mCredDefId;
}
public void setCredDefId(String credDefId) {
mCredDefId = credDefId;
}
public String getCredentialId() {
return mCredentialId;
}
public void setCredentialId(String credentialId) {
mCredentialId = credentialId;
}
public Object getExpirationDate() {
return mExpirationDate;
}
public void setExpirationDate(Object expirationDate) {
mExpirationDate = expirationDate;
}
public String getId() {
return mId;
}
public void setId(String id) {
mId = id;
}
public String getPrincipalDid() {
return mPrincipalDid;
}
public void setPrincipalDid(String principalDid) {
mPrincipalDid = principalDid;
}
public String getState() {
return mState;
}
public void setState(String state) {
mState = state;
}
public String getThreadId() {
return mThreadId;
}
public void setThreadId(String threadId) {
mThreadId = threadId;
}
public String getUpdatedDate() {
return mUpdatedDate;
}
public void setUpdatedDate(String updatedDate) {
mUpdatedDate = updatedDate;
}
}
......@@ -19,15 +19,12 @@ package api.test.rest.ocm.attestation;
import api.test.core.BaseStepDefinitions;
import api.test.rest.RestSessionContainer;
import api.test.rest.pojo.credential.Credential;
import api.test.rest.pojo.credentialDef.CredentialDef;
import api.test.rest.pojo.schema.Schema;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.Option;
import com.jayway.jsonpath.ReadContext;
import core.*;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
......@@ -35,7 +32,6 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.HashMap;
import static org.junit.Assert.assertEquals;
......@@ -223,6 +219,10 @@ public class AttestationStepDefinitions extends BaseStepDefinitions {
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
if (getLastResponse() != null && getLastResponse().getStatusCode() == 200) {
restSessionContainer.setCurrentCredentialData(JsonUtils.getResourceFromResponse(getLastResponse(), Credential.class));
}
}
@Given("^I get all credentials with pageSize \\{(.*?)\\} and page \\{(.*?)\\} via OCM api")
......@@ -252,4 +252,66 @@ public class AttestationStepDefinitions extends BaseStepDefinitions {
addRequest(currentRequest);
addResponse(response);
}
@Given("^I get specific credential with filter \\{(.*?)\\} and value \\{(.*?)\\} via OCM api")
public void I_get_specific_credential_with_filter_and_value_via_OCM_api(String filter,String value) {
currentRequest.setPath("/attestation/v1/credential?"+filter+"=" + value);
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@Given("^I get the current credential with filter (threadId|principalDid|connectionId|credDefId|state|createdDateStart|expirationDateEnd) via OCM api")
public void I_get_the_current_credential_with_filter_via_OCM_api(String choice) {
String result = null;
switch (choice) {
case "threadId":
result = restSessionContainer.getCurrentCredentialData().getData().getRecords().get(0).getThreadId();
break;
case "principalDid":
result = restSessionContainer.getCurrentCredentialData().getData().getRecords().get(0).getPrincipalDid();
break;
case "connectionId":
result = restSessionContainer.getCurrentCredentialData().getData().getRecords().get(0).getConnectionId();
break;
case "credDefId":
result = restSessionContainer.getCurrentCredentialData().getData().getRecords().get(0).getCredDefId();
break;
case "state":
result = restSessionContainer.getCurrentCredentialData().getData().getRecords().get(0).getState();
break;
case "createdDateStart":
result = restSessionContainer.getCurrentCredentialData().getData().getRecords().get(0).getCreatedDate();
break;
case "expirationDateEnd":
result = restSessionContainer.getCurrentCredentialData().getData().getRecords().get(0).getExpirationDate().toString();
break;
}
I_get_specific_credential_with_filter_and_value_via_OCM_api(choice,result);
}
@Given("^I get credential-info with credentialId \\{(.*?)\\} via OCM api")
public void I_get_credential_info_with_credentialId_via_OCM_api(String credentialId) {
currentRequest.setPath("/attestation/v1/credential-info/" + credentialId);
Response response = RestClient.get(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
@Given("^I get the current credential-info via OCM api")
public void I_get_the_current_credential_info_via_OCM_api() {
String credentialId = restSessionContainer.getCurrentCredentialData().getData().getRecords().get(0).getCredentialId();
I_get_credential_info_with_credentialId_via_OCM_api(credentialId);
}
@Given("^I delete credential with credentialId \\{(.*?)\\} via OCM api")
public void I_delete_credential_with_credentialId_via_OCM_api(String credentialId) {
currentRequest.setPath("/attestation/v1/delete-credential/" + credentialId);
Response response = RestClient.delete(currentRequest);
addRequest(currentRequest);
addResponse(response);
}
}
\ 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/credential-info/:credentialId
#Author: Rosen Georgiev rosen.georgiev@vereign.com
@rest @all @ocm @attestation
Feature: API - OCM - attestation - v1 - credential-info - :credentialId GET
This request fetches the issued verifiable credential-info.
Background:
Given we are testing the OCM Api
@credential-info
Scenario: OCM - Attestation - Get Credential-info - Positive
#Get all credentials to get a specific credentialId to fetch the additional information of it
Given I get all credentials via OCM Api
And the status code should be {200}
Then I clear the query parameters
And I get the current credential-info via OCM api
And the status code should be {200}
And the field {statusCode} contains the value {200}
And the field {message} contains the value {Agent responded}
#should be fixed in the future error handling refactoring
@credential-info @negative
Scenario: OCM - Attestation - Try to Get Credential-info for nonexisting credentialId - Negative
And I get credential-info with credentialId {nonExisting} via OCM api
And the status code should be {500}
And the field {statusCode} contains the value {500}
And the field {message} contains the value {Request failed with status code 404}
\ No newline at end of file
......@@ -48,4 +48,40 @@ Feature: API - OCM - attestation - v1 - credential GET
And the field {statusCode} contains the value {200}
And the field {message} contains the value {Credential fetch successfully}
And the response is valid according to the {Attestation_GET_credential.json} REST schema
And the field {$.data.records} contains {5} elements
\ No newline at end of file
And the field {$.data.records} contains {5} elements
@cred @negative
Scenario Outline: OCM - Attestation - Try to Get a credential with filter <filter> and value <value> - Negative
Then I get specific credential with filter {<filter>} and value {<value>} via OCM api
And the status code should be {<code>}
And the field {message} contains the value {<msg>}
And the field {statusCode} contains the value {<statusCode>}
Examples:
| filter | value | code | msg | statusCode |
| credDefId | 8y8oycXjnQCRT2t3mRuzbP:3:CL:41034:test5.0 | 404 | No Data found | 404 |
| state | credential | 404 | No Data found | 404 |
| createdDateStart | 2029-03-28T12:09:56.739Z | 404 | No Data found | 404 |
| createdDateEnd | 2020-03-28T12:09:56.739Z | 404 | No Data found | 404 |
| expirationDateStart | 2029-03-28T12:09:56.739Z | 404 | No Data found | 404 |
| expirationDateEnd | 2020-03-28T12:09:56.739Z | 404 | No Data found | 404 |
| connectionId | 2ewqeadasdadasda | 404 | No Data found | 404 |
| principalDid | 2ewqeadasdadasda | 404 | No Data found | 404 |
| threadId | 2ewqeadasdadasda | 404 | No Data found | 404 |
@cred
Scenario Outline: OCM - Attestation - Get a credential with filter <filter> - Positive
#Get all credentials to choose 1 and get its data to be able to filter after that
Given I get all credentials with pageSize {20} and page {0} via OCM api
And the status code should be {200}
Then I clear the query parameters
Then I get the current credential with filter <filter> via OCM api
And the status code should be {200}
And the field {message} contains the value {Credential fetch successfully}
Examples:
| filter |
| credDefId |
| threadId |
| principalDid |
| connectionId |
| state |
| createdDateStart |
\ 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/delete-credential/:credentialId
#Author: Rosen Georgiev rosen.georgiev@vereign.com
@rest @all @ocm @attestation
Feature: API - OCM - attestation - v1 - delete-credential- :credentialId DELETE
This request deletes credential
Background:
Given we are testing the OCM Api
@delete-credential @negative
Scenario: OCM - Attestation - Try to Delete Credential with invalid id - Negative
Given I delete credential with credentialId {343585a2-ced4-44ff-9567-974313d2175d} via OCM api
And the status code should be {500}
And the field {statusCode} contains the value {500}
And the field {message} contains the value {Request failed with status code 404}
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