http-body-base64.json 1.4 KB

123456789101112131415161718
  1. {
  2. "name": "verify-http-body-base64",
  3. "nodes": [
  4. {"id": "n1", "name": "Trigger", "type": "click-trigger", "position": {"x": 0, "y": 0}, "config": {}},
  5. {"id": "n2", "name": "Raw Body Is Sent", "type": "code", "position": {"x": 0, "y": 100},
  6. "config": {"code": "const payload = JSON.stringify({ username: 'admin', password: 'admin' });\n\nconst viaBase64 = smartbotic.http.request({\n method: 'POST',\n url: '{{API}}/api/v1/auth/login',\n headers: { 'Content-Type': 'application/json' },\n bodyBase64: smartbotic.utils.base64Encode(payload),\n timeout: 15000\n});\n\nlet parsed = viaBase64.data;\nif (typeof parsed === 'string') { parsed = JSON.parse(parsed); }\n\nconst garbled = smartbotic.http.request({\n method: 'POST',\n url: '{{API}}/api/v1/auth/login',\n headers: { 'Content-Type': 'application/json' },\n bodyBase64: smartbotic.utils.base64Encode('{\"username\":\"admin\",\"password\":\"wrong\"}'),\n timeout: 15000\n});\n\nreturn {\n status: viaBase64.status,\n gotToken: typeof parsed.accessToken === 'string' && parsed.accessToken.length > 20,\n wrongPasswordRejected: garbled.status >= 400\n};"}}
  7. ],
  8. "connections": [
  9. {"sourceNodeId": "n1", "sourceOutput": "main", "targetNodeId": "n2", "targetInput": "data"}
  10. ],
  11. "expect": {
  12. "n2": {"status": "completed", "output": {"result": {
  13. "status": 200,
  14. "gotToken": true,
  15. "wrongPasswordRejected": true
  16. }}}
  17. }
  18. }