From a08dcc2939d536f5d44ef634594a72f851c3db5b Mon Sep 17 00:00:00 2001 From: noamcoh Date: Mon, 20 Oct 2025 15:01:33 +0000 Subject: [PATCH] Enable requests to Smart 1 Cloud management service --- .../CME_API.postman_collection | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/common/cme_api_postman/CME_API.postman_collection b/common/cme_api_postman/CME_API.postman_collection index b2ab6797..1c160e69 100644 --- a/common/cme_api_postman/CME_API.postman_collection +++ b/common/cme_api_postman/CME_API.postman_collection @@ -9307,24 +9307,39 @@ "type": "text/javascript", "exec": [ "pm.test(\"Check for collectionVariables\", function () {", - " let vars = ['managementIP', 'user', 'password'];", - " vars.forEach(function (item, index, array) {", - " console.log(item, index);", - " pm.expect(pm.collectionVariables.get(item), item + \" variable not set\").to.not.be.undefined;", - " pm.expect(pm.collectionVariables.get(item), item + \" variable not set\").to.not.be.empty; ", - " });", + " let managementIP = pm.collectionVariables.get(\"managementIP\");", + " let sessionId = pm.collectionVariables.get(\"sessionId\");", + " let user = pm.collectionVariables.get(\"user\");", + " let password = pm.collectionVariables.get(\"password\");", + " ", + " // Auto-detect S1C format: optimized detection and extraction", + " if (managementIP?.includes('/')) {", + " [managementIP, sessionId] = managementIP.split('/', 2);", + " pm.collectionVariables.set(\"sessionId\", sessionId);", + " }", + " ", + " pm.expect(managementIP, \"managementIP variable not set\").to.not.be.undefined;", + " pm.expect(managementIP, \"managementIP variable not set\").to.not.be.empty;", + " ", + " // Prepare login payload based on available credentials", + " let loginPayload = { 'session-id': sessionId };", + " ", + " if (!sessionId?.trim()) {", + " pm.expect(user, \"user variable not set\").to.not.be.undefined;", + " pm.expect(user, \"user variable not set\").to.not.be.empty;", + " pm.expect(password, \"password variable not set\").to.not.be.undefined;", + " pm.expect(password, \"password variable not set\").to.not.be.empty;", + " loginPayload = { user, password };", + " }", "", " if (!pm.collectionVariables.get(\"session\") || Date.now() > new Date(pm.collectionVariables.get(\"sessionTimeout\") * 1000)) {", " pm.sendRequest({", - " url: 'https://' + pm.collectionVariables.get(\"managementIP\") + '/web_api/v1.8/login',", + " url: 'https://${managementip}/web_api/v1.8/login',", " method: 'POST',", - " header: 'Content-Type: application/json', // Set the Content-Type header to application/json", + " header: 'Content-Type: application/json',", " body: {", - " mode: 'raw', // Use raw body mode", - " raw: JSON.stringify({ // Convert the object to JSON string", - " user: pm.collectionVariables.get(\"user\"),", - " password: pm.collectionVariables.get(\"password\")", - " })", + " mode: 'raw',", + " raw: JSON.stringify(loginPayload)", " }", " }, function (err, res) {", " if (err) {",