Commit b6b23ae4 authored by Siebers, Michael's avatar Siebers, Michael
Browse files

test robustness of irrelevant/file

parent 373a94a2
......@@ -450,7 +450,13 @@ system_test:bg robust against non-item payload:
extends: .system_test:run_with_data
variables:
TEST_NAME: robust_bg_non_item_payload
system_test:irrelevant robust against non-path payload:
extends: .system_test:run_with_data
variables:
TEST_NAME: robust_irrelevant@file_non_path_payload
# If no FORCE_... variable is set to "yes", no pipeline is created for merge
# requests targetting a non-default branch. Thus, the MR cannot be merged. This
# dummy job remedies the missing pipeline.
......
[
{"request_body": "plain text"},
{"request_body": "\"a string\""},
{"request_body": "true"},
{"request_body": "false"},
{"request_body": "null"},
{"request_body": 1},
{"request_body": -1},
{"request_body": 1.2345},
{"request_body": 1234567891011121314151617181920},
{"request_body": "123456789101112131415161718192021222324252627282930"},
{"request_body": "[1,2,3]"},
{"request_body": "{}"},
{"request_body": "{\"abs_path\":65}"},
{"request_body": "{\"abs_path\":23.48}"},
{"request_body": "{\"abs_path\":[]}"},
{"request_body": "{\"abs_path\":[1,2,3]}"},
{"request_body": "{\"abs_path\":{}}"},
{"request_body": "{\"abs_path\":{\"content\":\"a_file\"}}"},
{"request_body": "{\"abs_path\":\"a_file\",\"another_key\":6}"}
]
{
"info": {
"_postman_id": "0f7be408-8ec8-480b-8bca-c2ab883c68f8",
"name": "Robustness irrelevant/file Non-Path Payload",
"description": "This collection tests whether the [Reasoning WebAPI for Dare2Del](https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator) (Version 1.0.0) handles POST requests to irrelevant/file` with semantically wrong payload gracefully. These should all result in 4xx responses. The response body should be an error response with the same code. The response message is not checked.\n\nThe collection is to be run with the data file `robust_irrelevant@file_non_path_payload-data.json`.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Querry Irrelevance",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(pm.variables.get(\"test_prefix\") + \"Bad Request\", function () {",
" pm.expect(pm.response.code).to.eql(400);",
"});",
"",
"pm.test(pm.variables.get(\"test_prefix\") + \"Valid error response body\", function() {",
" pm.response.to.be.withBody;",
" pm.response.to.be.json;",
"",
" var Ajv = require('ajv');",
" ajv = new Ajv();",
" const validate = ajv.compile(JSON.parse(pm.variables.get(\"response-schema:error\")));",
"",
" const jsonData = pm.response.json();",
" pm.expect(validate(jsonData)).to.be.true;",
" pm.expect(jsonData.code).to.eql(400);",
"});"
],
"type": "text/javascript"
}
},
{
"listen": "prerequest",
"script": {
"exec": [
"if(! pm.collectionVariables.get(\"response-schema:error\")) {",
" var code_ok = false;",
" const schema_url = \"http://\" + pm.environment.get(\"SERVER\") + pm.environment.get(\"SCHEMA_PATH\") ",
" + \"/response-error-schema.json\";",
" pm.sendRequest(schema_url, function(err, response){",
" pm.test(\"Load error response schema: Status code is 200\", function () {",
" pm.expect(err).to.not.be.ok;",
" console.log(response);",
" pm.expect(response.code).to.eql(200);",
" code_ok = true;",
" });",
"",
"",
" pm.test(\"Load error response schema: Response is JSON object\", function() {",
" const jsonData = response.json();",
" pm.expect(jsonData).is.an(\"object\");",
"",
" if(code_ok)",
" pm.collectionVariables.set(\"response-schema:error\", JSON.stringify(jsonData));",
" });",
" });",
"}",
"",
"pm.variables.set(\"test_prefix\", pm.info.requestName + \"[\" + (pm.info.iteration + 1).toString() + '/' ",
" + pm.info.iterationCount.toString() + ']: ');"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"connection": true
}
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{{request_body}}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://{{SERVER}}/irrelevant/file",
"protocol": "http",
"host": [
"{{SERVER}}"
],
"path": [
"irrelevant",
"file"
]
}
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "request_body",
"value": ""
},
{
"key": "response-schema:error",
"value": ""
}
]
}
\ No newline at end of file
[
{"endpoint": "bg/add"},
{"endpoint": "bg/remove"}
{"endpoint": "bg/remove"},
{"endpoint": "irrelevant/file"}
]
......@@ -29,5 +29,13 @@
{"endpoint": "bg/clear", "forbidden_method": "DELETE"},
{"endpoint": "bg/clear", "forbidden_method": "OPTIONS"},
{"endpoint": "bg/clear", "forbidden_method": "TRACE"},
{"endpoint": "bg/clear", "forbidden_method": "PATCH"}
{"endpoint": "bg/clear", "forbidden_method": "PATCH"},
{"endpoint": "irrelevant/file", "forbidden_method": "GET"},
{"endpoint": "irrelevant/file", "forbidden_method": "HEAD"},
{"endpoint": "irrelevant/file", "forbidden_method": "PUT"},
{"endpoint": "irrelevant/file", "forbidden_method": "DELETE"},
{"endpoint": "irrelevant/file", "forbidden_method": "OPTIONS"},
{"endpoint": "irrelevant/file", "forbidden_method": "TRACE"},
{"endpoint": "irrelevant/file", "forbidden_method": "PATCH"}
]
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment