| 123456789101112131415161718 |
- {
- "name": "verify-http-body-base64",
- "nodes": [
- {"id": "n1", "name": "Trigger", "type": "click-trigger", "position": {"x": 0, "y": 0}, "config": {}},
- {"id": "n2", "name": "Raw Body Is Sent", "type": "code", "position": {"x": 0, "y": 100},
- "config": {"code": "const payload = JSON.stringify({ username: 'admin', password: 'admin' });\n\nconst viaBase64 = smartbotic.http.request({\n method: 'POST',\n url: 'http://localhost:8090/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: 'http://localhost:8090/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};"}}
- ],
- "connections": [
- {"sourceNodeId": "n1", "sourceOutput": "main", "targetNodeId": "n2", "targetInput": "data"}
- ],
- "expect": {
- "n2": {"status": "completed", "output": {"result": {
- "status": 200,
- "gotToken": true,
- "wrongPasswordRejected": true
- }}}
- }
- }
|