diff --git a/build.gradle b/build.gradle index 3c95fb520bc5fe75df2868fb130ea4aaf0541d4e..511fe3c720e937d29ae4dc1bb3c2d4eb0dcfea94 100644 --- a/build.gradle +++ b/build.gradle @@ -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 diff --git a/src/main/java/api/test/rest/RestSessionContainer.java b/src/main/java/api/test/rest/RestSessionContainer.java index 9adcb807630aeddc31614b22d94aff6bb22d6b20..a6d9a05cad010c16ebeddd58718dda59147fd6b6 100644 --- a/src/main/java/api/test/rest/RestSessionContainer.java +++ b/src/main/java/api/test/rest/RestSessionContainer.java @@ -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; + } } diff --git a/src/main/java/api/test/rest/pojo/credential/Credential.java b/src/main/java/api/test/rest/pojo/credential/Credential.java new file mode 100644 index 0000000000000000000000000000000000000000..c541c46e61f2da77b8005a272ed6674453699038 --- /dev/null +++ b/src/main/java/api/test/rest/pojo/credential/Credential.java @@ -0,0 +1,39 @@ + +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; + } + +} diff --git a/src/main/java/api/test/rest/pojo/credential/Data.java b/src/main/java/api/test/rest/pojo/credential/Data.java new file mode 100644 index 0000000000000000000000000000000000000000..c511727e5d3c3b9f362cb0edfca8ba2490467a5e --- /dev/null +++ b/src/main/java/api/test/rest/pojo/credential/Data.java @@ -0,0 +1,30 @@ + +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; + } + +} diff --git a/src/main/java/api/test/rest/pojo/credential/Record.java b/src/main/java/api/test/rest/pojo/credential/Record.java new file mode 100644 index 0000000000000000000000000000000000000000..806ad3c0645e52df57dc0aa684d6bce9b51e1c2f --- /dev/null +++ b/src/main/java/api/test/rest/pojo/credential/Record.java @@ -0,0 +1,109 @@ + +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; + } + +} diff --git a/src/test/java/api/test/rest/ocm/attestation/AttestationStepDefinitions.java b/src/test/java/api/test/rest/ocm/attestation/AttestationStepDefinitions.java index b8f568a18575ef72edbbcb0d8d8130fa811f4c63..b18ef769da77dbc859644d044058cc0b8b58f4be 100644 --- a/src/test/java/api/test/rest/ocm/attestation/AttestationStepDefinitions.java +++ b/src/test/java/api/test/rest/ocm/attestation/AttestationStepDefinitions.java @@ -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 diff --git a/src/test/resources/features/ocm/attestation/v1/credential-info/GET.feature b/src/test/resources/features/ocm/attestation/v1/credential-info/GET.feature new file mode 100644 index 0000000000000000000000000000000000000000..dcd4458b0d10c6297ad377c4abafe0157a50edbd --- /dev/null +++ b/src/test/resources/features/ocm/attestation/v1/credential-info/GET.feature @@ -0,0 +1,43 @@ +#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 diff --git a/src/test/resources/features/ocm/attestation/v1/credential/GET.feature b/src/test/resources/features/ocm/attestation/v1/credential/GET.feature index 56b871dbe0fafe578ca10dd426afd5b36003ac79..122e6cfc0178e1c67488092125ac913f077ed180 100644 --- a/src/test/resources/features/ocm/attestation/v1/credential/GET.feature +++ b/src/test/resources/features/ocm/attestation/v1/credential/GET.feature @@ -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 diff --git a/src/test/resources/features/ocm/attestation/v1/delete-credential/DELETE.feature b/src/test/resources/features/ocm/attestation/v1/delete-credential/DELETE.feature new file mode 100644 index 0000000000000000000000000000000000000000..a7581539e96e786f4202125cecf74febcb25955a --- /dev/null +++ b/src/test/resources/features/ocm/attestation/v1/delete-credential/DELETE.feature @@ -0,0 +1,31 @@ +#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}