diff --git a/postman_collections/apitest-postman/Add_a_new_product_to_the_store.csv b/postman_collections/apitest-postman/Add_a_new_product_to_the_store.csv new file mode 100644 index 00000000..6d4771d2 --- /dev/null +++ b/postman_collections/apitest-postman/Add_a_new_product_to_the_store.csv @@ -0,0 +1,3 @@ +name,id,description,price,statusCode,scenario +apple,10,description of the product,20,200,Successful operation +banana,23,random description,40,405,Invalid input \ No newline at end of file diff --git a/postman_collections/modified_postman_openapi.json b/postman_collections/modified_postman_openapi.json new file mode 100644 index 00000000..881ec66b --- /dev/null +++ b/postman_collections/modified_postman_openapi.json @@ -0,0 +1,182 @@ +{ + "item": [ + { + "id": "56542cf5-b67e-4563-880a-6020ba8f978a", + "name": "products", + "item": [ + null, + { + "id": "77fede59-09b2-4b08-a2d2-e104aabc9a3c", + "name": "Add a new product to the store", + "request": { + "name": "Add a new product to the store", + "description": { + "content": "Add a new product to the store", + "type": "text/plain" + }, + "url": { + "path": [ + "products" + ], + "host": [ + "{{baseUrl}}" + ], + "query": [], + "variable": [] + }, + "header": [ + { + "key": "Content-Type", + "value": "application/json" + }, + { + "key": "Accept", + "value": "application/json" + } + ], + "method": "POST", + "auth": null, + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"{{name}}\",\n \"id\": \"{{id}}\",\n \"description\": \"{{description}}\",\n \"price\": \"{{price}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + } + }, + "response": [ + { + "id": "41c14aa9-6b7a-4540-8676-3d0be9fec92b", + "name": "Successful operation", + "originalRequest": { + "url": { + "path": [ + "products" + ], + "host": [ + "{{baseUrl}}" + ], + "query": [], + "variable": [] + }, + "header": [ + { + "key": "Accept", + "value": "application/json" + } + ], + "method": "POST", + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"{{name}}\",\n \"id\": \"{{id}}\",\n \"description\": \"{{description}}\",\n \"price\": \"{{price}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + } + }, + "status": "OK", + "code": 200, + "header": [ + { + "key": "Content-Type", + "value": "application/json" + } + ], + "body": "{\n \"name\": \"apple\",\n \"id\": 10,\n \"description\": \"description of the product\",\n \"price\": 20\n}", + "cookie": [], + "_postman_previewlanguage": "json" + }, + { + "id": "086bf751-f0f3-4c87-b4f5-d9c2c2797110", + "name": "Invalid input", + "originalRequest": { + "url": { + "path": [ + "products" + ], + "host": [ + "{{baseUrl}}" + ], + "query": [], + "variable": [] + }, + "method": "POST", + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"{{name}}\",\n \"id\": \"{{id}}\",\n \"description\": \"{{description}}\",\n \"price\": \"{{price}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + } + }, + "status": "Method Not Allowed", + "code": 405, + "header": [ + { + "key": "Content-Type", + "value": "text/plain" + } + ], + "body": "", + "cookie": [], + "_postman_previewlanguage": "text" + } + ], + "event": [ + { + "listen": "test", + "script": { + "exec": [ + " \n// ********RoostGPT********\n/*\nTest generated by RoostGPT for test apitest-postman using AI Type Open AI and AI Model gpt-4\n\n\nTest generated for /products for http method type post in postman framework\n\n*/\n\n// ********RoostGPT********\n\nlet responseData;\nconst contentType = pm.response.headers.get('Content-Type');\nif(contentType === \"application/xml\"){\n responseData = xml2Json(responseBody);\n} else{\n responseData = pm.response.json();\n}\nif (pm.variables.get(\"statusCode\")) {\n // Compare the statusCode variable with the response code for assertion\n pm.expect(parseInt(pm.variables.get(\"statusCode\"))).to.be.equal(pm.response.code);\n}\n\n// let responseTime = 800\n// pm.expect(pm.response.responseTime).to.be.below(responseTime);\n\nif (pm.response.code == 200){\n pm.test(\"Successful operation\", function () {\n pm.expect(pm.response.status).to.be.eql(\"OK\");\n if(Array.isArray(responseData)) {\n pm.test('Response has the `id` field',function(){ \n if(pm.expect(responseData[0]).to.have.nested.property(`id`)){\n if(pm.expect(_.get(responseData[0], `id`, 200)).to.exist){\n pm.expect(typeof _.get(responseData[0], `id`, 200)).to.equal(\"number\");\n }\n }\n\n })\n } else {\n pm.test('Response has the `id` field',function(){\n if(pm.expect(responseData).to.have.nested.property(`id`)){\n if(pm.expect(_.get(responseData, `id`, 200)).to.exist){\n pm.expect(typeof _.get(responseData, `id`, 200)).to.equal(\"number\");\n }\n }\n\n })\n }\n\n if(Array.isArray(responseData)) {\n pm.test('Response has the `name` field',function(){\n if(pm.expect(responseData[0]).to.have.nested.property(`name`)){\n if(pm.expect(_.get(responseData[0], `name`, null)).to.exist){\n pm.expect(typeof _.get(responseData[0], `name`, null)).to.equal(\"string\");\n }\n }\n\n })\n } else {\n pm.test('Response has the `name` field',function(){\n if(pm.expect(pm.response.json()).to.have.nested.property(`name`)){\n if(pm.expect(_.get(pm.response.json(), `name`, null)).to.exist){\n pm.expect(typeof _.get(pm.response.json(), `name`, null)).to.equal(\"string\");\n }\n }\n\n })\n }\n\n if(Array.isArray(responseData)) {\n pm.test('Response has the `description` field',function(){\n if(pm.expect(responseData[0]).to.have.nested.property(`description`)){\n if(pm.expect(_.get(responseData[0], `description`, null)).to.exist){\n pm.expect(typeof _.get(responseData[0], `description`, null)).to.equal(\"string\");\n }\n }\n\n })\n } else {\n pm.test('Response has the `description` field',function(){\n if(pm.expect(pm.response.json()).to.have.nested.property(`description`)){\n if(pm.expect(_.get(pm.response.json(), `description`, null)).to.exist){\n pm.expect(typeof _.get(pm.response.json(), `description`, null)).to.equal(\"string\");\n }\n }\n\n })\n }\n\n if(Array.isArray(responseData)) {\n pm.test('Response has the `price` field',function(){ \n if(pm.expect(responseData[0]).to.have.nested.property(`price`)){\n if(pm.expect(_.get(responseData[0], `price`, 200)).to.exist){\n pm.expect(typeof _.get(responseData[0], `price`, 200)).to.equal(\"number\");\n }\n }\n\n })\n } else {\n pm.test('Response has the `price` field',function(){\n if(pm.expect(responseData).to.have.nested.property(`price`)){\n if(pm.expect(_.get(responseData, `price`, 200)).to.exist){\n pm.expect(typeof _.get(responseData, `price`, 200)).to.equal(\"number\");\n }\n }\n\n })\n }\n});\n}\n\nif (pm.response.code == 405){\n pm.test(\"Invalid input\", function () {\n pm.expect(pm.response.status).to.be.eql(\"Method Not Allowed\");});\n}\n" + ], + "type": "text/javascript" + } + } + ], + "protocolProfileBehavior": { + "disableBodyPruning": true + } + }, + { + "id": "2739daca-d924-4e22-bde8-ceae8d407dca", + "name": "{productId}", + "item": [ + null, + null, + null + ], + "event": [] + } + ], + "event": [] + } + ], + "event": [], + "variable": [ + { + "type": "string", + "value": "http://52.66.106.18:8080/api", + "key": "baseUrl" + }, + { + "type": "integer", + "value": 200, + "key": "statusCode" + } + ], + "info": { + "_postman_id": "452e9f43-4cb3-4892-b29f-91a0e2d670bc", + "name": "Swagger My-Products - OpenAPI 3.0", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "description": { + "content": "This page is for my products api spec", + "type": "text/plain" + } + } +} \ No newline at end of file