-
Notifications
You must be signed in to change notification settings - Fork 2
/
RESTbot - API testing scaffolding.postman_collection.json
628 lines (628 loc) · 20.9 KB
/
RESTbot - API testing scaffolding.postman_collection.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
{
"info": {
"_postman_id": "60eb7df8-b2f7-472a-acea-cc89f641e1e7",
"name": "RESTbot: API testing scaffolding",
"description": "The original instructions are minimalistic, they just deal with establishing a connection and exiting a bot.\n\nExcept for establishing a connection, the _original_ REST API is as follows:\n\nCall `http://your-host-where-RESTbot-lives.com:9080//`\n\nwhile on the POST data, you put the actual parameters.\n\nEstablishing a connection will give you the `session_id`.",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "14772119"
},
"item": [
{
"name": "Login",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"if (!pm.collectionVariables.has(\"avatarFirstName\") || !pm.collectionVariables.has(\"avatarLastName\")) {",
" console.warn(\"missing avatar name...\");",
" return;",
"}",
"",
"if (pm.collectionVariables.has(\"avatarPassword\")) {",
" var sl_password = pm.collectionVariables.get(\"avatarPassword\");",
" var my_sl_password = CryptoJS.MD5(sl_password).toString();",
" ",
" console.log(\"avatar password: \" + sl_password + \"; MD5'ed: \" + my_sl_password);",
"",
" // Inject MD5'ed password into environment.",
" // This avoids losing the initial value of the password (gwyneth 20220107).",
" pm.collectionVariables.set(\"sl_md5_password\", my_sl_password);",
"} else {",
" console.warn(\"avatar password not found...\");",
"}"
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"console.log(\"Response body was: \", pm.response.text());",
"var jsonObject = xml2Json(pm.response.text());",
"console.log(\"After converting from XML to JSON:\", jsonObject);",
"if (typeof jsonObject.restbot.error !== 'undefined') {",
" // couldn't log in for some reason...",
" console.error(\"Failed to log in avatar with error from the grid; no session_id was returned!\");",
" return;",
"}",
"if (typeof jsonObject.restbot.session_id !== 'undefined') {",
" console.info(\"Already logged in; session_id is: '\" + jsonObject.restbot.session_id + \"'\");",
" pm.collectionVariables.set(\"session_id\", jsonObject.restbot.session_id);",
" return;",
"}",
"if (typeof jsonObject.restbot.success.session_id !== 'undefined') {",
" console.log(\"Successfully logged in; session_id is: '\" + jsonObject.restbot.success.session_id + \"'\");",
" pm.collectionVariables.set(\"session_id\", jsonObject.restbot.success.session_id);",
" return;",
"}",
"console.error(\"Either session_id was empty, or we couldn't extract it from XML...\");",
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "first",
"value": "{{avatarFirstName}}",
"description": "Avatar first name",
"type": "text"
},
{
"key": "last",
"value": "{{avatarLastName}}",
"description": "Avatar last name (or 'Resident' if no last name)",
"type": "text"
},
{
"key": "pass",
"value": "{{sl_md5_password}}",
"description": "Calculated MD5 of password",
"type": "text",
"disabled": true
},
{
"key": "pass",
"value": "{{avatarPassword}}",
"description": "Avatar password in plaintext",
"type": "text"
}
]
},
"url": {
"raw": "{{baseURL}}/establish_session/{{restBotPassword}}",
"host": [
"{{baseURL}}"
],
"path": [
"establish_session",
"{{restBotPassword}}"
]
},
"description": "**RESTbot password:** the default is simply `pass`. You can (and should!) change it on `configuration.xml`.\n\nThe _avatar_ password is another story. Under OpenSimulator, you can get away with your own generated MD5'ed password; the underlying libraries will add the `\"$1$\"` prefix (that properly identifies MD5 encoding as, well, MD5 encoding) and it works fine. Second Life, however, mumbles and grumbles and ultimately refuses to use your MD5'd password. Why that happens is completely beyond my knowledge and understanding.\n\nHowever, LibreMetaverse has added a neat feature — if a password is passed in plaintext (i.e. _not_ MD5-encoded), _then_ it will go through all proper steps to ensure that the Second Life Grid gets a properly MD5'd password _that SL accepts_. Weird, but it certainly works! So, if you are unable to login to SL with your MD5'd password, try to use your non-encoded password instead. A safety issue? Sure, _if_ you connect via `http` and not `https` to your RESTbot instance. The truth is that MD5 is easily breakable anyway, so encoding a password with MD5 and passing it unencrypted is not really safe these days (it might have been the case in 2003, but [today it's reasonably easy to crack](https://www.4armed.com/blog/hashcat-crack-md5-hashes/).\n\n`start` allows the avatar to start from its last location using the parameter value `last` (this is the default starting location), or optionally `home` (avatar will get rezzed at their previously set home position, if possible) or even using a specially formatted URI (allows teleport to a specific region and point inside that region), such as: Either \"last\", \"home\", or a string encoded URI with the body part (like this: `uri:hooper&128&152&`).\n\nIf successful, this call will return a _session identification key_:\n\n``` xml\n<restbot><success><session_id>5defa00c-1590-410b-a9e1-98066abd5ae4</session_id><key>53d9df15-7d7e-4422-b65f-f7f286d2c54d</key></success></restbot>\n\n```\n\nIf the wrong username or password was sent, you'll get (for Second Life):\n\n``` xml\n<restbot>\n <restbot>\n <error fatal=\"true\">Sorry! We couldn't log you in.\nPlease check to make sure you entered the right\n * Username (like bobsmith12 or steller.sunshine)\n * Password\n * Second Factor Token (if enabled)\nAlso, please make sure your Caps Lock key is off. If you feel this is an error, please contact support@secondlife.com.</error>\n</restbot>\n\n```\n\n(of course, Linden Lab may change the message at any time)\n\nIf this bot avatar had already been logged in by RESTbot, it detects that the session already exists, and returns:\n\n``` xml\n<restbot>\n <existing_session>true</existing_session>\n <session_id>aa3c8fad-32fd-4347-8ed8-15026354df71</session_id>\n <key>11817ab3-dafa-4ad7-98cc-0f454910f332</key>\n</restbot>\n\n```\n\n### Notes\n\n- Starting with v8.2.0, the session identification key (`session_id`) and avatar key (`key`, a UUID) are _also_ returned.\n- Other errors preventing the session to be instantiated _might_ be possible (not tested as of 20220111!), they're usually returned within `error` tags."
},
"response": [
{
"name": "Login",
"originalRequest": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "first",
"value": "Sample",
"description": "Avatar first name",
"type": "text"
},
{
"key": "last",
"value": "Resident",
"description": "Avatar last name (or 'Resident' if no last name)",
"type": "text"
},
{
"key": "pass",
"value": "",
"description": "Calculated MD5 of password",
"type": "text"
}
]
},
"url": {
"raw": "http://127.0.0.1:9080/establish_session/pass",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "9080",
"path": [
"establish_session",
"pass"
]
}
},
"_postman_previewlanguage": null,
"header": null,
"cookie": [],
"body": null
}
]
},
{
"name": "Logout",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"if (pm.collectionVariables.get(\"session_id\") == \"00000000-0000-0000-0000-000000000000\") {",
" console.warn(\"Empty or invalid session_id; did you remember to login first?\");",
"}"
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"console.log(\"Response body was: \", pm.response.text());",
"var jsonObject = xml2Json(pm.response.text());",
"console.log(\"After converting from XML to JSON:\", jsonObject);",
"if (typeof jsonObject.restbot.error !== 'undefined') {",
" // couldn't log in for some reason...",
" console.error(\"Failed to logout avatar with error from the grid; old session_id '\" + pm.collectionVariables.get(\"session_id\") + \"' retained\");",
" return;",
"}",
"if (typeof jsonObject.restbot.disposed !== 'undefined') {",
" if (jsonObject.restbot.disposed == 'true') {",
" pm.collectionVariables.set(\"session_id\", \"00000000-0000-0000-0000-000000000000\");",
" console.info(\"session disposed successfully; session_id reset to NULL_UUID\"); ",
" } else {",
" console.info(\"Failed to logout avatar; old session_id '\" + pm.collectionVariables.get(\"session_id\") + \"' retained\");",
" }",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": []
},
"url": {
"raw": "{{baseURL}}/exit/{{session_id}}",
"host": [
"{{baseURL}}"
],
"path": [
"exit",
"{{session_id}}"
]
},
"description": "`session_id` is the session identification key received on the previous call.\n\n### Returns:\n\n``` xml\n<restbot><status>success - all bot sessions very logged out and a request for queued shutdown</status></restbot>\n\n```"
},
"response": []
},
{
"name": "avatar_key",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"if (pm.collectionVariables.get(\"session_id\") == \"00000000-0000-0000-0000-000000000000\") {",
" console.warn(\"Empty or invalid session_id; did you remember to login first?\");",
" return;",
"}",
"",
"// if (pm.request.body.formdata(\"key\").)"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "name",
"value": "Governor Linden",
"description": "Name of avatar for which we're retrieving its key (UUID).",
"type": "default"
}
]
},
"url": {
"raw": "{{baseURL}}/avatar_key/{{session_id}}/",
"host": [
"{{baseURL}}"
],
"path": [
"avatar_key",
"{{session_id}}",
""
]
},
"description": "### Returns:\n\n```xml\n<restbot><key>d2cdf457-5027-4887-abd8-573c62a85226</key></restbot>\n```"
},
"response": []
},
{
"name": "avatar_name",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"if (pm.collectionVariables.get(\"session_id\") == \"00000000-0000-0000-0000-000000000000\") {",
" console.warn(\"Empty or invalid session_id; did you remember to login first?\");",
" return;",
"}",
"",
"// if (pm.request.body.formdata(\"key\").)"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "key",
"value": "3d6181b0-6a4b-97ef-18d8-722652995cf1",
"description": "Avatar key (UUID) to search for name. Note: either name or key can be set, but not both!",
"type": "text"
}
]
},
"url": {
"raw": "{{baseURL}}/avatar_name/{{session_id}}/",
"host": [
"{{baseURL}}"
],
"path": [
"avatar_name",
"{{session_id}}",
""
]
},
"description": "### Returns:\n\n``` xml\n<restbot><name>Gwyneth Llewelyn</name></restbot>\n\n```"
},
"response": []
},
{
"name": "avatar_online",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"if (pm.collectionVariables.get(\"session_id\") == \"00000000-0000-0000-0000-000000000000\") {",
" console.warn(\"Empty or invalid session_id; did you remember to login first?\");",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "key",
"value": "3d6181b0-6a4b-97ef-18d8-722652995cf1",
"description": "Avatar key (UUID) for which retrieve the online status.",
"type": "default"
}
]
},
"url": {
"raw": "{{baseURL}}/avatar_online/{{session_id}}/",
"host": [
"{{baseURL}}"
],
"path": [
"avatar_online",
"{{session_id}}",
""
]
},
"description": "### Returns:\n\n``` xml\n<restbot><online>False</online></restbot>\n\n```"
},
"response": []
},
{
"name": "avatar_profile",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"if (pm.collectionVariables.get(\"session_id\") == \"00000000-0000-0000-0000-000000000000\") {",
" console.warn(\"Empty or invalid session_id; did you remember to login first?\");",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "key",
"value": "3d6181b0-6a4b-97ef-18d8-722652995cf1",
"description": "Avatar key (UUID) to retrieve the profile for.",
"type": "default"
}
]
},
"url": {
"raw": "{{baseURL}}/avatar_profile/{{session_id}}/",
"host": [
"{{baseURL}}"
],
"path": [
"avatar_profile",
"{{session_id}}",
""
]
},
"description": "### Returns:\n\n``` xml\n<restbot><online>False</online></restbot>\n\n```"
},
"response": []
},
{
"name": "location",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"if (pm.collectionVariables.get(\"session_id\") == \"00000000-0000-0000-0000-000000000000\") {",
" console.warn(\"Empty or invalid session_id; did you remember to login first?\");",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": []
},
"url": {
"raw": "{{baseURL}}/location/{{session_id}}/",
"host": [
"{{baseURL}}"
],
"path": [
"location",
"{{session_id}}",
""
]
},
"description": "Shows the current region name, the IP and port addresses of that region, and the actual position of the 'bot inside it.\n\n### Returns:\n\n``` xml\n<restbot>\n\t<location>\n\t\t<CurrentSim>Beta Technologies (216.82.45.92:13000)</CurrentSim>\n\t\t<Position>103.0242,211.2815,30.03234</Position>\n\t</location>\n</restbot>\n\n```\n\n_Note:_ The parameter includes not only the name, but also the IP address of the simulator, for reasons unknown. Future versions might separate such information with different XML sub-tags, to ease parsing (important for LSL scripts, which might not have good XML parsing ability). There are a few more elements that can be returned, such as the _global_ position, the simulator version that is currently running on this region, and other statistics that are not currently being reported by the [Stats Plugin](https://github.com/GwynethLlewelyn/restbot/wiki/RESTbot-API#stats-plugin)."
},
"response": []
},
{
"name": "goto",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"if (pm.collectionVariables.get(\"session_id\") == \"00000000-0000-0000-0000-000000000000\") {",
" console.warn(\"Empty or invalid session_id; did you remember to login first?\");",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "sim",
"value": "Ahern",
"description": "Region simulator to teleport to (spaces should work fine if properly quoted)",
"type": "text"
},
{
"key": "x",
"value": "128",
"description": "Coordinates inside the region (floats)",
"type": "text"
},
{
"key": "y",
"value": "128",
"type": "text"
},
{
"key": "z",
"value": "30",
"type": "text"
}
]
},
"url": {
"raw": "{{baseURL}}/goto/{{session_id}}/",
"host": [
"{{baseURL}}"
],
"path": [
"goto",
"{{session_id}}",
""
]
},
"description": "Teleports 'bot to a specific simulator and a position `(x,y,z)` inside that sim. Position coordinates are floats.\n\n### Returns:\n\n``` xml\n<restbot>\n\t<teleport>\n\t\t<CurrentSim>Beta Technologies (216.82.45.92:13000)</CurrentSim>\n\t\t<Position>103.0242,211.2815,30.03234</Position>\n\t</teleport>\n</restbot>\n\n```\n\n_Note:_ The result is now consistent with the [Location](https://github.com/GwynethLlewelyn/restbot/wiki/RESTbot-API#location) plugin. See also the note about the simulator IP address."
},
"response": []
},
{
"name": "say",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
"if (pm.collectionVariables.get(\"session_id\") == \"00000000-0000-0000-0000-000000000000\") {",
" console.warn(\"Empty or invalid session_id; did you remember to login first?\");",
"}"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "message",
"value": "I am not yelling!",
"description": "Message to send (max. about 1024 bytes)",
"type": "text"
},
{
"key": "channel",
"value": "0",
"description": "[Optional] channel to send (signed integer); 0 is public chat (default)",
"type": "text"
},
{
"key": "chattype",
"value": "normal",
"description": "[Optional] can be: _normal_, _shout_ or _whisper_.",
"type": "text"
},
{
"key": "realism",
"value": "false",
"description": "[Optional] enables or disables realism mode (bot uses typing animation); default is _false_.",
"type": "text"
},
{
"key": "charspersecond",
"value": "3",
"description": "[Optional] simulates the number of characters typed by a minute per second; default is 3.",
"type": "text"
}
]
},
"url": {
"raw": "{{baseURL}}/say/{{session_id}}/",
"host": [
"{{baseURL}}"
],
"path": [
"say",
"{{session_id}}",
""
]
},
"description": "Sends a message to chat. Any channel can be chosen (default is 0, also known as 'public chat') as well as the chat type: normal, shout or whisper.\n\nSince v8.3.0, this call also includes the ability to use the 'realism' mode, hidden deep in LibreMetaverse, and which attempts to mimic how a human normally types. Default is off (realism=false). charspersecond is by default 3, which, according to the LibreMetaverse developers, is about the average typing time of humans. The 'bot avatar will engage the typing animation during this time (and a viewer with bubbles enabled will see the three dots until the 'bot avatar stops typing).\n\n### Returns:\n\nIf successful, returns what was sent in chat (or an error if it failed):\n``` xml\n<restbot><say><channel>0</channel><message>I am not yelling</message><chattype>normal</chattype></say></restbot>\n```"
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "baseURL",
"value": "http://127.0.0.1:9080",
"type": "string"
},
{
"key": "restBotPassword",
"value": "pass",
"type": "string"
},
{
"key": "avatarFirstName",
"value": "Sample",
"type": "string"
},
{
"key": "avatarLastName",
"value": "Resident",
"type": "string"
},
{
"key": "avatarPassword",
"value": "aPlainTextPassword",
"type": "string"
},
{
"key": "session_id",
"value": "00000000-0000-0000-0000-000000000000",
"type": "string"
},
{
"key": "sl_md5_password",
"value": ""
}
]
}