Available repo: https://github.com/jitech21/JAPIT

Config file items overview
{
"authUrl": "http://localhost:12000/login"
"url": "http://localhost:12000",
"authentications": [
{
"request": {
"method": "POST",
"endPoint": "",
"requestDataParams": {
"param1": "value1",
"param2": "value2"
},
"headers": {
"Connection": "keep-alive",
"Content-Type": "application/x-www-form-urlencoded"
}
},
"response": {
"responseStatus": 200,
"nameTestSuite": "authenticationGetToken",
"timeoutForActionSec": 10,
"validationRules": "ResponseStatus",
"returnToken": "(access_token)"
}
}
],
"endPoints": [
{
"request": {
"method": "GET",
"endPoint": "/get",
"requestDataParams": {"test": "test"}
},
"response": {
"responseStatus": 200,
"nameTestSuite": "/get",
"timeoutForActionSec": 10,
"validationRules": "ResponseStatus~PreviousDataValidation~ParsableJson~GenReport"
}
}
]
}
authUrl
Add an address for setup secure communication for requests to the API
URL
Add an address which is apiTesterAPP uses for building complete path to the endpoint
authentications
This section should be entered if it is necessary to authenticate before the data from API call
Request
method
Values
- POST
- GET
endPoint
requestDataParams
An API endpoint is a point at which an API — the code that allows two software programs to communicate with each other — connects with the software program—APIs work by sending requests for information from a web application or web server and receiving a response.
If it is necessary add parameters for the endpoint.
for example:
"requestDataParams": {"user": "test", "password":"test"}
headers
If the request should contain additional settings for example
"headers": {
"Connection": "keep-alive",
"Content-Type": "application/x-www-form-urlencoded"
}
Response
responseStatus
This code base on this page: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
nameTestSuite
Name of endpoint should be unique in the config file.
timeoutForActionSec
Timeout for request / response handling
validationRules
the values splitter with ~
Values
Values | Result |
ResponseStatus | Validate the status of the response |
ParsableJson | Validate o whole response |
PreviousDataValidation | Validate previous data with actual response data (This condition works correctly after 2nd run of configuration. The first run of configuration setup the expect.) |
GenReport | Generate junit_xml |
ReturnData | serve the response to the console output |
For example:
"validationRules": "ResponseStatus~PreviousDataValidation~ParsableJson~GenReport"
endPoints
Contains a list of endpoint
skipped
If exists this param the API test case was disabled. Additional description is available as a string value.
"skipped":"This test case was skipped",
Request:
method
Values
- POST
- GET
endPoint
An API endpoint is a point at which an API — the code that allows two software programs to communicate with each other — connects with the software program—APIs work by sending requests for information from a web application or web server and receiving a response.
requestDataParams
If it is necessary add parameters for the endpoint.
for example:
"requestDataParams": {"status": "pending"}
headers
If the request should contain additional settings for example
"headers": {
"Connection": "keep-alive",
"Content-Type": "application/x-www-form-urlencoded"
}
Response
responseStatus
This code base on this page: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
nameTestSuite
Name of endpoint should be unique in the config file.
timeoutForActionSec
Timeout for request / response handling
validation rules
the values splitter with ~
Values
Values | Result |
ResponseStatus | Validate the status of the response |
ParsableJson | Validate o whole response |
PreviousDataValidation | Validate previous data with actual response data (This condition works correctly after 2nd run of configuration. The first run of configuration setup the expect.) |
GenReport | Generate junit_xml |
SkipValidationReturnData | Skip all validation rules and serve the response to the console output |
ResponseTimeSec | Validation response time (for ex. ResponseTimeSec=2.0 => 2sec) (number type: float) |
For example:
"validationRules": "ResponseStatus~PreviousDataValidation~ParsableJson~GenReport"
Run the script
parameters:
Required:
–ConfFile
Optional:
–AuthParams – If the user needs authorize via rest API use this options
--BuildNumber - Unique identification for any report file from this tester
python apiTester.py --ConfFile=demo/config.json
Or (This second way to run of script is secure becouse the params should be anonimize via CICD)
python apiTester.py --ConfFile=demo/config.json --AuthParams "{\"user\":\"test\", \"Password\": \"test\"}" --BuildNumber 126
How to create a relationship between requests?
This function normally using for confirmation for confirming if an item (via POST) was created in DB.
For activation, this function is necessary to create in config JSON add id („replaceData“: „$xx“).
for example:
{
"url": "https://petstore.swagger.io",
"endPoints": [
{
"request": {
"method": "POST",
"endPoint": "/v2/pet",
"requestDataParams": {
"id": 21,
"category": {
"id": 0,
"name": "test"
},
"name": "test21",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "test"
}
],
"status": "available"
},
"headers" : {
"accept": "application/json",
"Content-Type": "application/json"
}
},
"response": {
"responseStatus": 200,
"nameTestSuite": "CreatePet",
"timeoutForActionSec": 10,
"validationRules": "ResponseStatus~ResponseTimeSec=1~GenReport~ReturnData",
"replaceData": "$id"
}
},
{
"request": {
"method": "GET",
"endPoint": "/v2/pet/$id",
"requestDataParams": {},
"headers" : { }
},
"response": {
"responseStatus": 200,
"nameTestSuite": "FindPetById",
"timeoutForActionSec": 10,
"validationRules": "ResponseStatus~ResponseTimeSec=1~ParsableJson~GenReport"
}
}
]
}