diff --git a/src/main/java/api/test/rest/RestSessionContainer.java b/src/main/java/api/test/rest/RestSessionContainer.java index 2ee38ebe4f7bdc4d68b4e8067d8c70abc50f019e..6c980081b2c18ddeb0633bcf3860bebdfaabfa55 100644 --- a/src/main/java/api/test/rest/RestSessionContainer.java +++ b/src/main/java/api/test/rest/RestSessionContainer.java @@ -17,11 +17,32 @@ 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.credentialDef.CredentialDef; import api.test.rest.pojo.schema.Schema; public class RestSessionContainer { private Schema currentSchema; + private CredentialDef currentCredentialDef; + private Connection currentConnection; + + + public Connection getCurrentConnection() { + return currentConnection; + } + + public void setCurrentConnection(Connection currentConnection) { + this.currentConnection = currentConnection; + } + + public CredentialDef getCurrentCredentialDef() { + return currentCredentialDef; + } + + public void setCurrentCredentialDef(CredentialDef currentCredentialDef) { + this.currentCredentialDef = currentCredentialDef; + } public Schema getCurrentSchema() { return currentSchema; diff --git a/src/main/java/api/test/rest/pojo/connection/Authentication.java b/src/main/java/api/test/rest/pojo/connection/Authentication.java new file mode 100644 index 0000000000000000000000000000000000000000..5812db88a50ca0f1169e9e52adbf71dc6261dfe1 --- /dev/null +++ b/src/main/java/api/test/rest/pojo/connection/Authentication.java @@ -0,0 +1,31 @@ + +package api.test.rest.pojo.connection; + + +import com.google.gson.annotations.Expose; + + +public class Authentication { + + @Expose + private String publicKey; + @Expose + private String type; + + public String getPublicKey() { + return publicKey; + } + + public void setPublicKey(String publicKey) { + this.publicKey = publicKey; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} diff --git a/src/main/java/api/test/rest/pojo/connection/Connection.java b/src/main/java/api/test/rest/pojo/connection/Connection.java new file mode 100644 index 0000000000000000000000000000000000000000..d30c5f3507268c42599483c9e4621af1850719c9 --- /dev/null +++ b/src/main/java/api/test/rest/pojo/connection/Connection.java @@ -0,0 +1,161 @@ + +package api.test.rest.pojo.connection; + + +import com.google.gson.annotations.Expose; + + +public class Connection { + + @Expose + private api.test.rest.pojo.connection._tags _tags; + @Expose + private String alias; + @Expose + private String createdAt; + @Expose + private Data data; + @Expose + private String did; + @Expose + private DidDoc didDoc; + @Expose + private String id; + @Expose + private Invitation invitation; + @Expose + private String message; + @Expose + private Metadata metadata; + @Expose + private Boolean multiUseInvitation; + @Expose + private String role; + @Expose + private String state; + @Expose + private Long statusCode; + @Expose + private String verkey; + + public api.test.rest.pojo.connection._tags get_tags() { + return _tags; + } + + public void set_tags(api.test.rest.pojo.connection._tags _tags) { + this._tags = _tags; + } + + public String getAlias() { + return alias; + } + + public void setAlias(String alias) { + this.alias = alias; + } + + public String getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(String createdAt) { + this.createdAt = createdAt; + } + + public Data getData() { + return data; + } + + public void setData(Data data) { + this.data = data; + } + + public String getDid() { + return did; + } + + public void setDid(String did) { + this.did = did; + } + + public DidDoc getDidDoc() { + return didDoc; + } + + public void setDidDoc(DidDoc didDoc) { + this.didDoc = didDoc; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Invitation getInvitation() { + return invitation; + } + + public void setInvitation(Invitation invitation) { + this.invitation = invitation; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Metadata getMetadata() { + return metadata; + } + + public void setMetadata(Metadata metadata) { + this.metadata = metadata; + } + + public Boolean getMultiUseInvitation() { + return multiUseInvitation; + } + + public void setMultiUseInvitation(Boolean multiUseInvitation) { + this.multiUseInvitation = multiUseInvitation; + } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public Long getStatusCode() { + return statusCode; + } + + public void setStatusCode(Long statusCode) { + this.statusCode = statusCode; + } + + public String getVerkey() { + return verkey; + } + + public void setVerkey(String verkey) { + this.verkey = verkey; + } + +} diff --git a/src/main/java/api/test/rest/pojo/connection/Data.java b/src/main/java/api/test/rest/pojo/connection/Data.java new file mode 100644 index 0000000000000000000000000000000000000000..35f5bc038b9af8736cbb6ddf66d6061c2c24ed54 --- /dev/null +++ b/src/main/java/api/test/rest/pojo/connection/Data.java @@ -0,0 +1,41 @@ + +package api.test.rest.pojo.connection; + + +import com.google.gson.annotations.Expose; + + +public class Data { + + @Expose + private Connection connection; + @Expose + private Invitation invitation; + @Expose + private String invitationUrl; + + public Connection getConnection() { + return connection; + } + + public void setConnection(Connection connection) { + this.connection = connection; + } + + public Invitation getInvitation() { + return invitation; + } + + public void setInvitation(Invitation invitation) { + this.invitation = invitation; + } + + public String getInvitationUrl() { + return invitationUrl; + } + + public void setInvitationUrl(String invitationUrl) { + this.invitationUrl = invitationUrl; + } + +} diff --git a/src/main/java/api/test/rest/pojo/connection/DidDoc.java b/src/main/java/api/test/rest/pojo/connection/DidDoc.java new file mode 100644 index 0000000000000000000000000000000000000000..fbebe69bf3dfce4ccbfcd6f1e7cff578fe086d7b --- /dev/null +++ b/src/main/java/api/test/rest/pojo/connection/DidDoc.java @@ -0,0 +1,61 @@ + +package api.test.rest.pojo.connection; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class DidDoc { + + @Expose + private List<Authentication> authentication; + @SerializedName("@context") + private String context; + @Expose + private String id; + @Expose + private List<PublicKey> publicKey; + @Expose + private List<Service> service; + + public List<Authentication> getAuthentication() { + return authentication; + } + + public void setAuthentication(List<Authentication> authentication) { + this.authentication = authentication; + } + + public String getContext() { + return context; + } + + public void setContext(String context) { + this.context = context; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public List<PublicKey> getPublicKey() { + return publicKey; + } + + public void setPublicKey(List<PublicKey> publicKey) { + this.publicKey = publicKey; + } + + public List<Service> getService() { + return service; + } + + public void setService(List<Service> service) { + this.service = service; + } + +} diff --git a/src/main/java/api/test/rest/pojo/connection/Invitation.java b/src/main/java/api/test/rest/pojo/connection/Invitation.java new file mode 100644 index 0000000000000000000000000000000000000000..62120a99920332c1b063b0bfa4cfdd9776443f4d --- /dev/null +++ b/src/main/java/api/test/rest/pojo/connection/Invitation.java @@ -0,0 +1,71 @@ + +package api.test.rest.pojo.connection; + +import java.util.List; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +public class Invitation { + + @SerializedName("@id") + private String id; + @Expose + private String label; + @Expose + private List<String> recipientKeys; + @Expose + private List<Object> routingKeys; + @Expose + private String serviceEndpoint; + @SerializedName("@type") + private String type; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public List<String> getRecipientKeys() { + return recipientKeys; + } + + public void setRecipientKeys(List<String> recipientKeys) { + this.recipientKeys = recipientKeys; + } + + public List<Object> getRoutingKeys() { + return routingKeys; + } + + public void setRoutingKeys(List<Object> routingKeys) { + this.routingKeys = routingKeys; + } + + public String getServiceEndpoint() { + return serviceEndpoint; + } + + public void setServiceEndpoint(String serviceEndpoint) { + this.serviceEndpoint = serviceEndpoint; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} diff --git a/src/main/java/api/test/rest/pojo/connection/Metadata.java b/src/main/java/api/test/rest/pojo/connection/Metadata.java new file mode 100644 index 0000000000000000000000000000000000000000..cc5b7cd98843e55707e05d9fbdf5afd2fd5c681f --- /dev/null +++ b/src/main/java/api/test/rest/pojo/connection/Metadata.java @@ -0,0 +1,8 @@ + +package api.test.rest.pojo.connection; + + +public class Metadata { + + +} diff --git a/src/main/java/api/test/rest/pojo/connection/PublicKey.java b/src/main/java/api/test/rest/pojo/connection/PublicKey.java new file mode 100644 index 0000000000000000000000000000000000000000..c1e42b1a6904aeb5599d15391817906ca42aec51 --- /dev/null +++ b/src/main/java/api/test/rest/pojo/connection/PublicKey.java @@ -0,0 +1,49 @@ + +package api.test.rest.pojo.connection; + +import com.google.gson.annotations.Expose; + +public class PublicKey { + + @Expose + private String controller; + @Expose + private String id; + @Expose + private String publicKeyBase58; + @Expose + private String type; + + public String getController() { + return controller; + } + + public void setController(String controller) { + this.controller = controller; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPublicKeyBase58() { + return publicKeyBase58; + } + + public void setPublicKeyBase58(String publicKeyBase58) { + this.publicKeyBase58 = publicKeyBase58; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} diff --git a/src/main/java/api/test/rest/pojo/connection/Service.java b/src/main/java/api/test/rest/pojo/connection/Service.java new file mode 100644 index 0000000000000000000000000000000000000000..bf07ba13cb27560ac318cb1b89126f636e3587e7 --- /dev/null +++ b/src/main/java/api/test/rest/pojo/connection/Service.java @@ -0,0 +1,71 @@ + +package api.test.rest.pojo.connection; + +import java.util.List; +import com.google.gson.annotations.Expose; + + +public class Service { + + @Expose + private String id; + @Expose + private Long priority; + @Expose + private List<String> recipientKeys; + @Expose + private List<Object> routingKeys; + @Expose + private String serviceEndpoint; + @Expose + private String type; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Long getPriority() { + return priority; + } + + public void setPriority(Long priority) { + this.priority = priority; + } + + public List<String> getRecipientKeys() { + return recipientKeys; + } + + public void setRecipientKeys(List<String> recipientKeys) { + this.recipientKeys = recipientKeys; + } + + public List<Object> getRoutingKeys() { + return routingKeys; + } + + public void setRoutingKeys(List<Object> routingKeys) { + this.routingKeys = routingKeys; + } + + public String getServiceEndpoint() { + return serviceEndpoint; + } + + public void setServiceEndpoint(String serviceEndpoint) { + this.serviceEndpoint = serviceEndpoint; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + +} diff --git a/src/main/java/api/test/rest/pojo/connection/_tags.java b/src/main/java/api/test/rest/pojo/connection/_tags.java new file mode 100644 index 0000000000000000000000000000000000000000..cbc92644d9a7ba7fb22b55af612767771cfa3b64 --- /dev/null +++ b/src/main/java/api/test/rest/pojo/connection/_tags.java @@ -0,0 +1,8 @@ + +package api.test.rest.pojo.connection; + + +public class _tags { + + +} diff --git a/src/main/java/api/test/rest/pojo/credentialDef/CredentialDef.java b/src/main/java/api/test/rest/pojo/credentialDef/CredentialDef.java new file mode 100644 index 0000000000000000000000000000000000000000..d9f5b177cbd2a06800574191d8ec5e9833101e0f --- /dev/null +++ b/src/main/java/api/test/rest/pojo/credentialDef/CredentialDef.java @@ -0,0 +1,40 @@ + +package api.test.rest.pojo.credentialDef; + +import com.google.gson.annotations.Expose; + +@SuppressWarnings("unused") +public class CredentialDef { + + @Expose + private Data data; + @Expose + private String message; + @Expose + private Long statusCode; + + public Data getData() { + return data; + } + + public void setData(Data data) { + this.data = data; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public Long getStatusCode() { + return statusCode; + } + + public void setStatusCode(Long statusCode) { + this.statusCode = statusCode; + } + +} diff --git a/src/main/java/api/test/rest/pojo/credentialDef/Data.java b/src/main/java/api/test/rest/pojo/credentialDef/Data.java new file mode 100644 index 0000000000000000000000000000000000000000..9c7a233eed41c8b4348907848948762e29028965 --- /dev/null +++ b/src/main/java/api/test/rest/pojo/credentialDef/Data.java @@ -0,0 +1,120 @@ + +package api.test.rest.pojo.credentialDef; + +import com.google.gson.annotations.Expose; + + +public class Data { + + @Expose + private String createdBy; + @Expose + private String createdDate; + @Expose + private String credDefId; + @Expose + private String expiryHours; + @Expose + private String id; + @Expose + private Boolean isAutoIssue; + @Expose + private Boolean isRevokable; + @Expose + private String name; + @Expose + private String schemaID; + @Expose + private String updatedBy; + @Expose + private String updatedDate; + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public String getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(String createdDate) { + this.createdDate = createdDate; + } + + public String getCredDefId() { + return credDefId; + } + + public void setCredDefId(String credDefId) { + this.credDefId = credDefId; + } + + public String getExpiryHours() { + return expiryHours; + } + + public void setExpiryHours(String expiryHours) { + this.expiryHours = expiryHours; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Boolean getIsAutoIssue() { + return isAutoIssue; + } + + public void setIsAutoIssue(Boolean isAutoIssue) { + this.isAutoIssue = isAutoIssue; + } + + public Boolean getIsRevokable() { + return isRevokable; + } + + public void setIsRevokable(Boolean isRevokable) { + this.isRevokable = isRevokable; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSchemaID() { + return schemaID; + } + + public void setSchemaID(String schemaID) { + this.schemaID = schemaID; + } + + public String getUpdatedBy() { + return updatedBy; + } + + public void setUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + } + + public String getUpdatedDate() { + return updatedDate; + } + + public void setUpdatedDate(String updatedDate) { + this.updatedDate = updatedDate; + } + +} diff --git a/src/main/resources/REST/json/AttestationCreateCredentialDef.json b/src/main/resources/REST/json/AttestationCreateCredentialDef.json new file mode 100644 index 0000000000000000000000000000000000000000..fe002aae3e3e849bff21b700accffb826efa0312 --- /dev/null +++ b/src/main/resources/REST/json/AttestationCreateCredentialDef.json @@ -0,0 +1,10 @@ +{ + "successful_creation": { + "name": "Automation_CredDef_001", + "isRevokable": false, + "isAutoIssue": false, + "schemaID": "123456", + "createdBy": "acceptsAnyString", + "expiryHours": "24" + } +} \ No newline at end of file diff --git a/src/main/resources/REST/json/AttestationCreateOfferDef.json b/src/main/resources/REST/json/AttestationCreateOfferDef.json new file mode 100644 index 0000000000000000000000000000000000000000..f8235341179c0262db4176f5b03fec9c923e57c5 --- /dev/null +++ b/src/main/resources/REST/json/AttestationCreateOfferDef.json @@ -0,0 +1,20 @@ +{ + "successful_creation": { + "comment": "Created", + "attributes": [ + { + "name": "fName", + "value": "test_fname_3" + }, + { + "name": "lName", + "value": "test_lname_3" + }, + { + "name": "gender", + "value": "test_gender_3" + } + ], + "autoAcceptCredential": "never" + } +} \ No newline at end of file diff --git a/src/main/resources/REST/schemas/Attestation_POST_credentialDef.json b/src/main/resources/REST/schemas/Attestation_POST_credentialDef.json new file mode 100644 index 0000000000000000000000000000000000000000..097bc3c21a00b5bdf8fa705d72a40eec15537b9b --- /dev/null +++ b/src/main/resources/REST/schemas/Attestation_POST_credentialDef.json @@ -0,0 +1,68 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "statusCode": { + "type": "integer" + }, + "message": { + "type": "string" + }, + "data": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "schemaID": { + "type": "string" + }, + "name": { + "type": "string" + }, + "credDefId": { + "type": "string" + }, + "isAutoIssue": { + "type": "boolean" + }, + "isRevokable": { + "type": "boolean" + }, + "expiryHours": { + "type": "string" + }, + "createdBy": { + "type": "string" + }, + "createdDate": { + "type": "string" + }, + "updatedBy": { + "type": "string" + }, + "updatedDate": { + "type": "string" + } + }, + "required": [ + "id", + "schemaID", + "name", + "credDefId", + "isAutoIssue", + "isRevokable", + "expiryHours", + "createdBy", + "createdDate", + "updatedBy", + "updatedDate" + ] + } + }, + "required": [ + "statusCode", + "message", + "data" + ] +} \ No newline at end of file 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 04126af0df41777cfebbdaeea0d2bcaa809cd2e5..b5dd3c3a2a29dd080164d0c620649e5065eee8d1 100644 --- a/src/test/java/api/test/rest/ocm/attestation/AttestationStepDefinitions.java +++ b/src/test/java/api/test/rest/ocm/attestation/AttestationStepDefinitions.java @@ -19,6 +19,7 @@ package api.test.rest.ocm.attestation; import api.test.core.BaseStepDefinitions; import api.test.rest.RestSessionContainer; +import api.test.rest.pojo.credentialDef.CredentialDef; import api.test.rest.pojo.schema.Schema; import com.google.gson.Gson; import com.google.gson.JsonElement; @@ -122,4 +123,68 @@ public class AttestationStepDefinitions extends BaseStepDefinitions { public void I_get_the_current_Schema_via_OCM_api() { I_get_schema_with_schemaID_via_OCM_Api(restSessionContainer.getCurrentSchema().getData().getSchemaID()); } + + @Then("^I create a new credential definition via OCM Api") + public void I_create_a_new_credential_definition_OCM_Api() { + currentRequest.setPath("/attestation/v1/credentialDef"); + + Response response = RestClient.post(currentRequest); + addRequest(currentRequest); + addResponse(response); + + if (getLastResponse() != null && getLastResponse().getStatusCode() == 201) { + restSessionContainer.setCurrentCredentialDef(JsonUtils.getResourceFromResponse(getLastResponse(), CredentialDef.class)); + } + } + + @Then("^I create a new credential definition with the current schemaId via OCM Api") + public void I_create_a_new_credential_definition_with_the_current_schemaId_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("schemaID", restSessionContainer.getCurrentSchema().getData().getSchemaID()); + currentRequest.setBody(gson.toJson(jsonObject)); + + + I_create_a_new_credential_definition_OCM_Api(); + } + + @Given("^I create an offer credential with connectionId \\{(.*?)\\} via OCM Api") + public void I_create_an_offer_credential_with_connectionId_via_OCM_Api(String connectionId) { + 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", connectionId); + jsonObject.addProperty("credentialDefinitionId", restSessionContainer.getCurrentCredentialDef().getData().getCredDefId()); + currentRequest.setBody(gson.toJson(jsonObject)); + + I_create_an_offer_credential_via_OCM_Api(); + } + + @Given("^I create an offer credential via OCM Api") + public void I_create_an_offer_credential_via_OCM_Api() { + currentRequest.setPath("/attestation/v1/create-offer-credential/"); + + Response response = RestClient.post(currentRequest); + addRequest(currentRequest); + addResponse(response); + } + + @Given("^I create an offer credential for the current Connection and Schema via OCM Api") + public void I_create_an_offer_credential_for_the_current_Connection_and_SchemaVia_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("credentialDefinitionId", restSessionContainer.getCurrentCredentialDef().getData().getCredDefId()); + currentRequest.setBody(gson.toJson(jsonObject)); + + I_create_an_offer_credential_via_OCM_Api(); + } } \ No newline at end of file diff --git a/src/test/java/api/test/rest/ocm/connection/ConnectionStepDefinitions.java b/src/test/java/api/test/rest/ocm/connection/ConnectionStepDefinitions.java index 8965f36fe5479d1442b8d2c943c94b7c079fd52b..90d7e934d33e353f12ab12f04b07887b4effe428 100644 --- a/src/test/java/api/test/rest/ocm/connection/ConnectionStepDefinitions.java +++ b/src/test/java/api/test/rest/ocm/connection/ConnectionStepDefinitions.java @@ -19,6 +19,8 @@ package api.test.rest.ocm.connection; import api.test.core.BaseStepDefinitions; import api.test.rest.RestSessionContainer; +import api.test.rest.pojo.connection.Connection; +import api.test.rest.pojo.credentialDef.CredentialDef; import com.github.fge.jackson.JsonLoader; import com.google.gson.*; import com.jayway.jsonpath.Configuration; @@ -71,6 +73,10 @@ public class ConnectionStepDefinitions extends BaseStepDefinitions { Response response = RestClient.post(currentRequest); addRequest(currentRequest); addResponse(response); + + if (getLastResponse() != null && getLastResponse().getStatusCode() == 201) { + restSessionContainer.setCurrentConnection(JsonUtils.getResourceFromResponse(getLastResponse(), Connection.class)); + } } @Given("^we call the health check for connection manager via OCM api") diff --git a/src/test/resources/features/ocm/attestation/v1/create-offer-credential/POST.feature b/src/test/resources/features/ocm/attestation/v1/create-offer-credential/POST.feature new file mode 100644 index 0000000000000000000000000000000000000000..0a4998f5a430fd86321a456a57afc0a0e9cf308d --- /dev/null +++ b/src/test/resources/features/ocm/attestation/v1/create-offer-credential/POST.feature @@ -0,0 +1,80 @@ +#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/create-offer-credential +#Author: Rosen Georgiev rosen.georgiev@vereign.com + +@rest @all @ocm @attestation +Feature: API - OCM - attestation - v1 - create-offer-credential POST + A message sent by the Issuer to the potential Holder, describing the credential they intend to offer. + + 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. + + + Background: + Given we are testing the OCM Api + + @cred @negative + Scenario: OCM - Attestation - 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} + #Create offer credential + And I clear the request body + Given I load the REST request {AttestationCreateOfferDef.json} with profile {successful_creation} + Given I create an offer credential for the current Connection and Schema via OCM Api + And the status code should be {400} + Then the field {statusCode} contains the value {400} + Then the field {message} contains the value {Connection is not trusted} + + @cred @negative + Scenario Outline: OCM - Attestation - Try to Create offer of the currently created credential with invalid connectionid <connId> - 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 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} + #Create offer credential + And I clear the request body + Given I load the REST request {AttestationCreateOfferDef.json} with profile {successful_creation} + Given I create an offer credential with connectionId {<connId>} via OCM Api + And the status code should be {400} + Then the field {statusCode} contains the value {<status>} + Then the field {message} contains the value {<msg>} + Examples: + | connId | status | msg | + | | 400 | offer credentials required following attributes ( connectionId, credentialDefinitionId, attributes, autoAcceptCredential) | \ No newline at end of file diff --git a/src/test/resources/features/ocm/attestation/v1/credentialDef/POST.feature b/src/test/resources/features/ocm/attestation/v1/credentialDef/POST.feature new file mode 100644 index 0000000000000000000000000000000000000000..61a7e198bdbeaf25dc87e42950081197164ce4b8 --- /dev/null +++ b/src/test/resources/features/ocm/attestation/v1/credentialDef/POST.feature @@ -0,0 +1,47 @@ +#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/credentialDef +#Author: Rosen Georgiev rosen.georgiev@vereign.com + +@rest @all @ocm @attestation +Feature: API - OCM - attestation - v1 - credentialDef POST + It is used to create the Credential Definition. + A credential definition is a particular issuer's template based on an existing schema to issue credentials from. + + + Background: + Given we are testing the OCM Api + + @cred + Scenario: OCM - Attestation - Creation of credential definition based on a newly created schema - Positive + #Creation of the schema + 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 + Then the field {statusCode} contains the value {201} + 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 the response is valid according to the {Attestation_POST_credentialDef.json} REST schema + And the field {message} contains the value {Credential definition created successfully} + And the field {statusCode} contains the value {201} + And the field {$.data.name} contains the value {Automation_CredDef_001} + And the field {$.data.isAutoIssue} contains the value {false} + And the field {$.data.isRevokable} contains the value {false} + And the field {$.data.expiryHours} contains the value {24} + And the field {$.data.name} contains the value {Automation_CredDef_001} \ No newline at end of file diff --git a/src/test/resources/features/ocm/attestation/v1/schemas/GET.feature b/src/test/resources/features/ocm/attestation/v1/schemas/GET.feature index 79a956222081f68a1e26b18762b733313856f0c6..aec20ebca391ed6e933cabafd1b3423108dc156f 100644 --- a/src/test/resources/features/ocm/attestation/v1/schemas/GET.feature +++ b/src/test/resources/features/ocm/attestation/v1/schemas/GET.feature @@ -47,5 +47,4 @@ Feature: API - OCM - attestation - v1 - schemas GET And the status code should be {200} And the response is valid according to the {Attestation_GET_schemas.json} REST schema And the field {message} contains the value {Schemas fetch successfully} - And the field {$..count} contains the value {1} And the field {$.data.records} contains {1} elements \ No newline at end of file