REST step definitions
Verne provides capabilities to test REST API’s via step definitions. The following is the current list of supported step definitions and error codes:
List of REST API codes
GET
- 200: OK
- 400: Bad request
- 401: Unauthorized
- 403:Forbidden
- 404:Not found
- 500:Internal server error
POST (CREATE)
- 201: Created
- 400: Bad request
- 401: Unauthorized
- 403:Forbidden
- 409:Conflict
- 500:Internal server error
PUT(UPDATE)
- 200: OK
- 201: Created
- 204: No content
- 400: Bad request
- 401: Unauthorized
- 403:Forbidden
- 500:Internal server error
DELETE
- 204: No content
- 400: Bad request
- 401: Unauthorized
- 403:Forbidden
- 500:Internal server error
List of REST API actions
I (POST|PUT) rest webservice template (S+) with uri (.*)
Sends POST(Create)/PUT(Update) request to specific URI with a template.
This step support special variables that can be accessible using ${rest.variable}. These variables can be accessed while executing any request to the server:
- rest.txnBusinessIdentifier – the business service transaction identifier – ${rest.txnBusinessIdentifier}
- rest.txnVersionIdentifier – the transaction version identifier – ${rest.txnVersionIdentifier}
- rest.txnIdentifier – the transaction identifier – ${rest.txnIdentifier}
- rest.txnUid – the transaction UID – ${rest.txnUid}
Example
And I POST rest webservice template /com/fostermoore/catalyst/catapult/cluster/professionals/tests/hercules/tests/rest/PostProfessional/request/HappyPathRequest.json with uri professional-api/v1/professional
Then I expect webservice status code 201
When I PUT rest webservice template /com/fostermoore/catalyst/catapult/cluster/professionals/tests/hercules/tests/rest/PutProfessionalName/request/HappyPathRequest.json with uri professional-api/v1/professional/${rest.txnBusinessIdentifier}/name
Then I expect webservice status code 200
I (POST|PUT) rest webservice with token (S+) and template (S+) with uri (.*)
Sends POST(Create)/PUT(Update) request to specific URI with a template using tocken settings.
This step support special variables that can be accessible using ${rest.variable}. These variables can be accessed while executing any request to the server:
- rest.txnBusinessIdentifier – the business service transaction identifier – ${rest.txnBusinessIdentifier}
- rest.txnVersionIdentifier – the transaction version identifier – ${rest.txnVersionIdentifier}
- rest.txnIdentifier – the transaction identifier – ${rest.txnIdentifier}
- rest.txnUid – the transaction UID – ${rest.txnUid}
Example
And I POST rest webservice with token asdklflsdgi45p24glg5w21212 and template /com/fostermoore/catalyst/catapult/cluster/professionals/tests/hercules/tests/rest/PostProfessional/request/HappyPathRequest.json with uri professional-api/v1/professional
Then I expect webservice status code 201
When I PUT rest webservice with token asdklflsdgi45p24glg5w21212 and template /com/fostermoore/catalyst/catapult/cluster/professionals/tests/hercules/tests/rest/PutProfessionalName/request/HappyPathRequest.json with uri professional-api/v1/professional/${rest.txnBusinessIdentifier}/name
Then I expect webservice status code 200
I (GET|DELETE) rest webservice with uri (.*)
Sends GET/DELETE request to specific URI with template.
This step support special variables that can be accessible using ${rest.variable}. These variables can be accessed while executing any request to the server:
- rest.txnBusinessIdentifier – the business service transaction identifier – ${rest.txnBusinessIdentifier}
- rest.txnVersionIdentifier – the transaction version identifier – ${rest.txnVersionIdentifier}
- rest.txnIdentifier – the transaction identifier – ${rest.txnIdentifier}
- rest.txnUid – the transaction UID – ${rest.txnUid}
Example
When I DELETE rest webservice with uri professional-api/v1/professional/${rest.txnBusinessIdentifier}/qualification/recordid
Then I expect webservice status code 200
And I validate rest webservice result against /com/fostermoore/catalyst/catapult/cluster/professionals/tests/hercules/tests/rest/DeleteQualificationRecord/response/HappyPathResponse.json
When I GET rest webservice with uri professional-api/v1/professionals?query=${rest.txnBusinessIdentifier}
Then I expect webservice status code 200
And I validate rest webservice result against com/fostermoore/catalyst/catapult/cluster/professionals/tests/hercules/tests/rest/GetProfessionals/response/HappyPathResponse.json
I (GET|DELETE) rest webservice with token (S+) with uri (.*)
Sends GET/DELETE request to specific URI with template using token settings.
This step support special variables that can be accessible using ${rest.variable}. These variables can be accessed while executing any request to the server:
- rest.txnBusinessIdentifier – the business service transaction identifier – ${rest.txnBusinessIdentifier}
- rest.txnVersionIdentifier – the transaction version identifier – ${rest.txnVersionIdentifier}
- rest.txnIdentifier – the transaction identifier – ${rest.txnIdentifier}
- rest.txnUid – the transaction UID – ${rest.txnUid}
Example
When I DELETE rest webservice with token asdklflsdgi45p24glg5w21212 with uri professional-api/v1/professional/${rest.txnBusinessIdentifier}/qualification/recordid
Then I expect webservice status code 200
And I validate rest webservice result against /com/fostermoore/catalyst/catapult/cluster/professionals/tests/hercules/tests/rest/DeleteQualificationRecord/response/HappyPathResponse.json
When I GET rest webservice with token asdklflsdgi45p24glg5w21212 with uri professional-api/v1/professionals?query=${rest.txnBusinessIdentifier}
Then I expect webservice status code 200
And I validate rest webservice result against com/fostermoore/catalyst/catapult/cluster/professionals/tests/hercules/tests/rest/GetProfessionals/response/HappyPathResponse.json
I expect webservice status code (.*)
Asserts that the web service response code to be specific value in the latest webservice response.
Example
Then I expect webservice status code 200
I validate rest webservice result against (.*)
Compares the schema produced for a rest service against a file.
This step support special macros inside of the json file to validate while is running on non strict mode:
- #IGNORE# – Will skip the validation of the value.
- #NONBLANK# – Only checks if there is value. Won’t validate if the value is expected.
- #UNORDERED# – Indicates that the list is not ordered. Only checks if all of the items are in the list but won’t check the order
Example
When I GET rest webservice with uri professional-api/v1/professionals?query=${rest.txnBusinessIdentifier}
Then I expect webservice status code 200
And I validate rest webservice result against com/fostermoore/catalyst/catapult/cluster/professionals/tests/hercules/tests/rest/GetProfessionals/response/HappyPathResponse.json
Inside the HappyPathResponse Json will look like:
{
"id": "#IGNORE#",
"identifier": "#IGNORE#",
"businessIdentifier": "PROF-1234567",
"fullName": "NONBLANK#",
"status": "registered",
"registrationDate": "#IGNORE#",
"residentialAddress": {
"fullAddress": "Residential Line 1 address test, Residential Line 2 address test, Residential Suburb test, Residential City test, Queensland, 8243, Australia"
}
I strictly validate rest webservice result against (.*)
Compares the schema produced for a rest service against a file using strict mode.
Strict mode means not only the value of each keys have to be the same, the order of the keys should also be the same
Example
When I GET rest webservice with uri professional-api/v1/professionals?query=${rest.txnBusinessIdentifier}
Then I expect webservice status code 200
And I strictly validate rest webservice result against com/fostermoore/catalyst/catapult/cluster/professionals/tests/hercules/tests/rest/GetProfessionals/response/HappyPathResponse.json

