From 1a8d8ba5c02fc7fb0f7b6a094fd09d87495058c3 Mon Sep 17 00:00:00 2001 From: macacia Date: Tue, 22 Oct 2024 16:31:13 +0200 Subject: [PATCH] chore: P4ADEV-1277-postman-test-activity (#99) --- postman/p4pa-auth-E2E.postman_collection.json | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/postman/p4pa-auth-E2E.postman_collection.json b/postman/p4pa-auth-E2E.postman_collection.json index d695964a..bf4ddb3e 100644 --- a/postman/p4pa-auth-E2E.postman_collection.json +++ b/postman/p4pa-auth-E2E.postman_collection.json @@ -689,6 +689,9 @@ " pm.expect(jsonResponse).to.have.property(\"clientName\").to.eq(\"testClient\");\r", " pm.expect(jsonResponse).to.have.property(\"organizationIpaCode\").to.eq(\"IPA_TEST\");\r", " pm.expect(jsonResponse).to.have.property(\"clientSecret\");\r", + "\r", + " pm.environment.set(\"clientId\", jsonResponse.clientId)\r", + " pm.environment.set(\"clientSecret\", jsonResponse.clientSecret)\r", " } else {\r", " // Se il record esiste, ritorna un errore di chiave duplicata\r", " pm.response.to.have.status(500);\r", @@ -997,6 +1000,77 @@ } }, "response": [] + }, + { + "name": "postToken client-credentials", + "event": [ + { + "listen": "prerequest", + "script": { + "exec": [ + " pm.environment.get(\"clientId\")\r", + " pm.environment.get(\"clientSecret\")" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Auth - postToken - Responses with 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Auth - postToken - Verify response body\", function () {\r", + " let jsonResponse = pm.response.json();\r", + " pm.expect(jsonResponse).have.property(\"tokenType\").to.eq(\"bearer\");\r", + " pm.expect(jsonResponse).have.property(\"expiresIn\").to.eq(14400);\r", + " pm.expect(jsonResponse).have.property(\"accessToken\");\r", + "\r", + " pm.variables.set(\"accessToken\", jsonResponse.accessToken)\r", + "});" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "url": { + "raw": "{{p4paAuthBaseUrl}}/payhub/auth/token?client_id={{clientId}}&grant_type=client_credentials&scope=openid&client_secret={{clientSecret}}", + "host": [ + "{{p4paAuthBaseUrl}}" + ], + "path": [ + "payhub", + "auth", + "token" + ], + "query": [ + { + "key": "client_id", + "value": "{{clientId}}" + }, + { + "key": "grant_type", + "value": "client_credentials" + }, + { + "key": "scope", + "value": "openid" + }, + { + "key": "client_secret", + "value": "{{clientSecret}}" + } + ] + } + }, + "response": [] } ], "event": [