diff --git a/.github/workflows/api-test.yaml b/.github/workflows/api-test.yaml index ec19e84a..a50bc282 100644 --- a/.github/workflows/api-test.yaml +++ b/.github/workflows/api-test.yaml @@ -17,4 +17,5 @@ jobs: run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }} - name: Run API tests run: | - postman collection run "${{ github.workspace }}/tests/Api/postman/collections/Smoke Test.json" -e "33082135-163b2749-45b5-4967-a48d-ddea0aab6395" \ No newline at end of file + postman collection run "${{ github.workspace }}/tests/Api/postman/collections/Smoke Test.json" -e "33082135-163b2749-45b5-4967-a48d-ddea0aab6395" + postman collection run "${{ github.workspace }}/tests/Api/postman/collections/Integration Test.json" -e "33082135-163b2749-45b5-4967-a48d-ddea0aab6395" \ No newline at end of file diff --git a/.postman/api_614422ec-04dc-4af7-a04b-568299c4871a b/.postman/api_614422ec-04dc-4af7-a04b-568299c4871a index 9c92d0c3..92d16c80 100644 --- a/.postman/api_614422ec-04dc-4af7-a04b-568299c4871a +++ b/.postman/api_614422ec-04dc-4af7-a04b-568299c4871a @@ -9,6 +9,7 @@ id = 614422ec-04dc-4af7-a04b-568299c4871a [config.relations.collections] rootDirectory = tests/Api/postman/collections +files[] = {"id":"33082135-fe531156-be22-456f-be76-a6ed43442543","path":"Integration Test.json","metaData":{}} files[] = {"id":"33082135-3f329ef0-ba60-4afa-9ebe-8da64e0d7a86","path":"Smoke Test.json","metaData":{}} [config.relations.collections.metaData] diff --git a/tests/Api/postman/collections/Integration Test.json b/tests/Api/postman/collections/Integration Test.json new file mode 100644 index 00000000..246c1f9f --- /dev/null +++ b/tests/Api/postman/collections/Integration Test.json @@ -0,0 +1,490 @@ +{ + "info": { + "_postman_id": "fe531156-be22-456f-be76-a6ed43442543", + "name": "Integration Test", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_uid": "33082135-fe531156-be22-456f-be76-a6ed43442543" + }, + "item": [ + { + "name": "Clone User", + "item": [ + { + "name": "Setup", + "item": [ + { + "name": "Login", + "event": [ + { + "listen": "test", + "script": { + "id": "21d1e0da-45c0-4c5e-9cb7-840d4741ab61", + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "861c7863-3094-477c-bd96-92ba25d483ab", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"username\": \"{{admin_user}}\",\n \"password\": \"{{admin_password}}\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{host}}/login", + "host": [ + "{{host}}" + ], + "path": [ + "login" + ] + } + }, + "response": [] + }, + { + "name": "Add User", + "event": [ + { + "listen": "test", + "script": { + "id": "f9ab0aa5-0d98-4ab2-85ef-4358f01f7e84", + "exec": [ + "let jsonData = JSON.parse(responseBody);", + "postman.setEnvironmentVariable(\"user_id\", jsonData.id);" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "cc56cde9-1970-45a6-bba9-f1cc64a1f9af", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\n \"parentId\": 0,\n \"name\": \"api_test_user\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{host}}/user/", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "" + ] + } + }, + "response": [] + } + ], + "id": "617943f3-1cdf-4b33-943b-f45317826eb2" + }, + { + "name": "Test", + "item": [ + { + "name": "Clone non exiting User", + "event": [ + { + "listen": "test", + "script": { + "id": "2438500b-ea86-49ec-be08-ecd88c5a08f7", + "exec": [ + "pm.test(\"Status code is 404 User Not Found\", function () {", + " pm.response.to.have.status(404);", + "});", + "", + "pm.test(\"Check Response message\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.message).to.eql(\"User with ID: 10000 not found\");", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "2de156c9-998e-49e3-8700-801055da248f", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"cloned_user\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{host}}/user/clone/10000", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "clone", + "10000" + ] + } + }, + "response": [] + }, + { + "name": "Clone with non unique name", + "event": [ + { + "listen": "test", + "script": { + "id": "2438500b-ea86-49ec-be08-ecd88c5a08f7", + "exec": [ + "pm.test(\"Status code is 500 Could not save user\", function () {", + " pm.response.to.have.status(500);", + "});", + "", + "pm.test(\"Check Response message\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.message).to.contains(\"Could not save user\")", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "e9e87a04-92d6-4de6-8e72-e03d2c357a2f", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"api_test_user\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{host}}/user/clone/{{user_id}}", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "clone", + "{{user_id}}" + ] + } + }, + "response": [] + }, + { + "name": "Clone with invalid name", + "event": [ + { + "listen": "test", + "script": { + "id": "2438500b-ea86-49ec-be08-ecd88c5a08f7", + "exec": [ + "pm.test(\"Status code is 500 Could not save user\", function () {", + " pm.response.to.have.status(500);", + "});", + "", + "pm.test(\"Could not save user: Invalid name for user/role\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.message).to.contains(\"Could not save user: Invalid name for user/role\")", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "0f7ab465-923b-4b22-a27f-27b126063674", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Invalid Name\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{host}}/user/clone/{{user_id}}", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "clone", + "{{user_id}}" + ] + } + }, + "response": [] + }, + { + "name": "Clone User 200", + "event": [ + { + "listen": "test", + "script": { + "id": "2438500b-ea86-49ec-be08-ecd88c5a08f7", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Check Cloned Name\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.name).to.contains(\"Cloned_User\")", + "});", + "", + "pm.test(\"Check Cloned Type\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.type).to.contains(\"user\")", + "});", + "", + "let jsonData = pm.response.json();;", + "postman.setEnvironmentVariable(\"cloned_user_id\", jsonData.id);" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "3da01394-c19b-450c-b020-f05e1ce9b849", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"name\": \"Cloned_User\"\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{host}}/user/clone/{{user_id}}", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "clone", + "{{user_id}}" + ] + } + }, + "response": [] + } + ], + "id": "d319c3ac-b70a-467c-98ac-15d0c08c6b6a" + }, + { + "name": "Teardown", + "item": [ + { + "name": "Delete User", + "id": "2e36535c-fca2-4365-b32e-228a6f53776b", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{host}}/user/{{user_id}}", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "{{user_id}}" + ] + } + }, + "response": [] + }, + { + "name": "Delete Cloned User", + "id": "e33d8ee8-dc5f-42f0-8f1e-b860779c12c2", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{host}}/user/{{cloned_user_id}}", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "{{cloned_user_id}}" + ] + } + }, + "response": [] + }, + { + "name": "Logout", + "event": [ + { + "listen": "test", + "script": { + "id": "7b7efcc4-6aee-49dc-b529-8ead9198d4b2", + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "id": "a12f76e8-8f10-4d40-8f8e-9b952bdcb96d", + "exec": [ + "pm.environment.unset(\"user_id\");", + "pm.environment.unset(\"cloned_user_id\");" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "c5f51700-fd3d-4a73-9582-a6bdf72b4f6b", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{host}}/logout", + "host": [ + "{{host}}" + ], + "path": [ + "logout" + ] + } + }, + "response": [] + } + ], + "id": "9984e988-2676-47b7-b228-1e9222752547" + } + ], + "id": "ce54e92d-49b1-4017-b9cd-3ca1db7a136a" + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "id": "dd76b7a5-cfbe-4a98-a9e8-e8cb73c895ca", + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "id": "bcc50a01-64a0-4613-9105-aa982c2d1092", + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + } + ], + "variable": [ + { + "id": "a8d9565f-9179-4b4e-b6f6-8316946081d0", + "key": "admin_user", + "value": "admin", + "type": "string" + }, + { + "id": "3bed6e66-022b-4e47-b3ac-f41173d38ed7", + "key": "admin_password", + "value": "admin", + "type": "string" + } + ] +} \ No newline at end of file diff --git a/tests/Api/postman/collections/Smoke Test.json b/tests/Api/postman/collections/Smoke Test.json index 3216f968..c6617faa 100644 --- a/tests/Api/postman/collections/Smoke Test.json +++ b/tests/Api/postman/collections/Smoke Test.json @@ -7,13 +7,13 @@ }, "item": [ { - "name": "1.Auth", + "name": "Auth", "item": [ { - "name": "1.Login", + "name": "Login", "item": [ { - "name": "1.Login 200", + "name": "Login 200", "event": [ { "listen": "test", @@ -58,7 +58,7 @@ "response": [] }, { - "name": "2.Login 401", + "name": "Login 401", "event": [ { "listen": "test", @@ -103,7 +103,7 @@ "response": [] }, { - "name": "3.Unsupported Method GET", + "name": "Unsupported Method GET", "event": [ { "listen": "test", @@ -148,7 +148,7 @@ "response": [] }, { - "name": "4.Unsupported Method PUT", + "name": "Unsupported Method PUT", "event": [ { "listen": "test", @@ -191,17 +191,582 @@ } }, "response": [] + }, + { + "name": "Unsupported Methode DELETE", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "c8a0482f-67e4-4373-9021-8cd3f6515e6e", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{host}}/login", + "host": [ + "{{host}}" + ], + "path": [ + "login" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode PATCH", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "cba22568-683e-45e2-b298-1adc97ac946d", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "PATCH", + "header": [], + "url": { + "raw": "{{host}}/login", + "host": [ + "{{host}}" + ], + "path": [ + "login" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode HEAD", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "0994a455-9233-42ba-bc2a-c3d9a02e9a29", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "HEAD", + "header": [], + "url": { + "raw": "{{host}}/login", + "host": [ + "{{host}}" + ], + "path": [ + "login" + ] + } + }, + "response": [] } ], "id": "b2b21ffc-0b8a-4150-889c-114466c76002" }, { - "name": "2.Logout", - "item": [], + "name": "Logout", + "item": [ + { + "name": "Logout 200", + "event": [ + { + "listen": "test", + "script": { + "id": "7b7efcc4-6aee-49dc-b529-8ead9198d4b2", + "exec": [ + "pm.test(\"Status is 200\", function(){", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "89178c9a-0d81-4058-baaf-3c6dce5377c7", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{host}}/logout", + "host": [ + "{{host}}" + ], + "path": [ + "logout" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode GET", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "381920e2-ec43-4e3c-ae7c-76e928277572", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/logout", + "host": [ + "{{host}}" + ], + "path": [ + "logout" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode DELETE", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "f7fb929c-89d5-4015-b0ee-18c27b5e1b8f", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{host}}/logout", + "host": [ + "{{host}}" + ], + "path": [ + "logout" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode PUT", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "af7dbd89-5b1a-4b60-a5d8-cc71bcb683a9", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "PUT", + "header": [], + "url": { + "raw": "{{host}}/logout", + "host": [ + "{{host}}" + ], + "path": [ + "logout" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode PATCH", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "ec805d83-5bf3-4cc9-ad59-172e5f8641c5", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "PATCH", + "header": [], + "url": { + "raw": "{{host}}/logout", + "host": [ + "{{host}}" + ], + "path": [ + "logout" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode HEAD", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "59e731b1-7af7-4ef3-9ee6-6017dc153227", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "HEAD", + "header": [], + "url": { + "raw": "{{host}}/logout", + "host": [ + "{{host}}" + ], + "path": [ + "logout" + ] + } + }, + "response": [] + } + ], "id": "ec8b2502-f190-48c9-8e4f-b4983f0fa666" } ], "id": "8d225a95-e77a-4d28-8e9c-71eb8a2e7546" + }, + { + "name": "User Management", + "item": [ + { + "name": "Clone User", + "item": [ + { + "name": "Unauthorized", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 401\", function(){", + " pm.response.to.have.status(401);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "ff3cdbc3-60f6-4163-ba87-9b879013c541", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{host}}/user/clone/1", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "clone", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode GET", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "e02b14b4-b9bb-4c02-8fba-ac8e1eacc093", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{host}}/user/clone/1", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "clone", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode DELETE", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "b8434448-fbf0-470b-9601-7cb18eb9de00", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "DELETE", + "header": [], + "url": { + "raw": "{{host}}/user/clone/1", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "clone", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode PUT", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "1d6e43dd-c828-409e-9076-b67729c9acee", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "PUT", + "header": [], + "url": { + "raw": "{{host}}/user/clone/1", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "clone", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode PATCH", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "9c62639d-e2cd-4190-a430-959323c13bbd", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "PATCH", + "header": [], + "url": { + "raw": "{{host}}/user/clone/1", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "clone", + "1" + ] + } + }, + "response": [] + }, + { + "name": "Unsupported Methode HEAD", + "event": [ + { + "listen": "test", + "script": { + "id": "98a60326-98a2-4fd7-9208-1f236550e4c7", + "exec": [ + "pm.test(\"Status is 405\", function(){", + " pm.response.to.have.status(405);", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "id": "1a4428a5-feb1-4015-b29d-bbf7ae63246e", + "protocolProfileBehavior": { + "disableBodyPruning": true + }, + "request": { + "method": "HEAD", + "header": [], + "url": { + "raw": "{{host}}/user/clone/1", + "host": [ + "{{host}}" + ], + "path": [ + "user", + "clone", + "1" + ] + } + }, + "response": [] + } + ], + "id": "685bdcfe-b31a-4ac3-85fe-0b121d084641" + } + ], + "id": "d436780f-c384-46a5-be91-bede6b2b06f4" } ], "event": [