UNPKG

@apica-io/url-xi

Version:

URL Check for integrations and API monitoring

313 lines (307 loc) 10.8 kB
{ "$schema": "https://files-apicasystem-com.s3-eu-west-1.amazonaws.com/schemas/url-xi-schema-v1-0.json", "name": "HTTP-Bin Test HTTP Methods", "flowControl": "Individual Tests" , "variables": [ { "key": "xmlIterations", "type": "number", "usage": "input", "value": 1, "description": "Number of iterations getting the xml request", "validation": "'value > 0'" }, { "key": "server", "type": "string", "usage": "info", "value": "" }, { "key": "homePageContent", "type": "string", "usage": "info", "value": "" }, { "key": "authenticated", "type": "string", "usage": "info", "value": "" }, { "key": "randomScript", "type": "string", "usage": "info", "value": "" }, { "key": "slideTitles", "type": "array", "usage": "", "value": "" }, { "key":"imageMinLength", "description": "Minimum length for the returned image", "type": "number", "usage": "input", "unit": "bytes", "value": 32768 } ], "baseURL": "https://httpbin.org", "config": {}, "steps": [ { "name": "Home page", "requests": [ { "name": "The home page", "config": { "method": "get", "url": "/" }, "notSaveData": true, "extractors": [ { "type": "header", "expression": "content-type", "variable": "homePageContent" }, { "type": "regexp", "expression": "<script\\s+src=\"(.+)\">\\s+<\/script>", "variable": "javaScripts", "array": true }, { "type": "regexp", "expression": "<script\\s+src=\"(.+)\">\\s+<\/script>", "variable": "randomScript" } ], "assertions": [ { "type": "javaScript", "value": "{{randomScript}}", "description": "JavaScript: JavaScript reference should have suffix .js", "expression": "value.endsWith('.js')", "failStep": true }, { "type": "regexp", "description": "Regexp: JavaScript reference should have suffix .js", "expression": "\\.js$", "value": "{{randomScript}}", "failStep": true } ] } ] }, { "name": "Get JavaScripts", "iterator": { "varName": "javaScript", "value": "{{javaScripts}}" }, "requests": [ { "config": { "method": "get", "url": "{{javaScript}}" }, "extractors": [], "notSaveData": true } ] }, { "name": "Image JPeg", "requests": [ { "config": { "method": "get", "url": "/image/jpeg", "headers": { "Accept": "text/html" } }, "extractors": [ { "type": "header", "expression": "content-type", "variable": "imageType" }, { "type": "header", "expression": "content-length", "variable": "imageLength" } ], "assertions": [ { "type": "value", "value": "{{imageType}}", "description": "Image content type should be jpeg", "expression": "image/jpeg", "failStep": true }, { "type": "javaScript", "value": "{{imageLength}}", "description": "Image length at least {{imageMinLength}} bytes", "expression": "value >= {{imageMinLength}}", "failStep": true } ], "notSaveData": true } ] }, { "name": "HTTP Methods", "iterator": { "varName": "method", "value": [ "get", "post", "patch", "put", "delete" ] }, "requests": [ { "name": "Method {{method}}", "config": { "method": "{{method}}", "url": "/{{method}}", "data": "{\"testdata\":true,\"timestamp\":{{$timestamp}}}" }, "extractors": [ { "type": "header", "expression": "server", "variable": "server" }, { "type": "jsonpath", "expression": "$.origin", "variable": "origin" } ], "assertions": [ { "type": "javaScript", "value": "{{origin}}", "description": "Returned origin should contain an IP address. Method={{method}}", "expression": "/^((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\\.(?!$)|$)){4}$/.test(value)", "failStep": true, "reportFailOnly": true } ] } ] }, { "name": "Auth tests", "requests": [ { "name":"Auth OK", "config": { "method": "get", "url": "/basic-auth/foo/bar", "auth": { "username": "foo", "password": "bar" } }, "extractors": [] }, { "name":"Auth Wrong password", "config": { "method": "get", "url": "/basic-auth/foo/error", "auth": { "username": "foo", "password": "bar" } }, "expectedStatus": 401 } ] }, { "name": "Auth tests failure", "ignoreDuration": true, "requests": [ { "config": { "method": "get", "url": "/basic-auth/foo/error", "auth": { "username": "foo", "password": "bar" } }, "extractors": [] } ] }, { "name": "XML Request", "iterator": { "value": "{{xmlIterations}}" }, "requests": [ { "name": "Get XML {{$lapIdx1}}", "config": { "method": "get", "url": "/xml", "headers": { "Accept": "application/xml" } }, "extractors": [ { "type": "xpath", "expression": "/slideshow/slide[1]/title/text()", "variable": "slideTitle" }, { "type": "xpath", "expression": "string(/slideshow/@title)", "variable": "slideShowTitle" }, { "type": "xpath", "expression": "/slideshow/slide[*]/title/text()", "variable": "slideTitles", "array": true } ], "assertions": [ { "type": "javaScript", "value": "{{slideTitles}}", "description": "Slide titles should contain an array with more than 1 elements", "expression": "Array.isArray(value) && value.length > 1", "failStep": true }, { "type": "value", "value": "{{slideShowTitle}}", "description": "Check the slide show title", "expression": "Sample Slide Show", "failStep": true } ] } ] } ] }