mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
69fb149274
* fix: some external modules are missing * chore: update @types/tv4 * chore: use map instead of switch-case statement * test(scripting): check using external libs in the critical test suite
1117 lines
35 KiB
YAML
1117 lines
35 KiB
YAML
_type: export
|
|
__export_format: 4
|
|
__export_date: 2024-02-13T07:27:17.322Z
|
|
__export_source: insomnia.desktop.app:v8.6.1
|
|
resources:
|
|
- _id: req_bd8b1eb53418482585b70d0a9616a8cc
|
|
parentId: wrk_6b9b8455fd784462ae19cd51d7156f86
|
|
modified: 1707809216530
|
|
created: 1707809085329
|
|
url: https://api.insomnia.rest
|
|
name: Fetch from remote
|
|
description: ""
|
|
method: GET
|
|
body: {}
|
|
preRequestScript: |-
|
|
const res = await fetch('https://api.insomnia.rest');
|
|
console.log(res)
|
|
parameters: []
|
|
headers:
|
|
- name: User-Agent
|
|
value: insomnia/8.6.1
|
|
authentication: {}
|
|
metaSortKey: -1707809028549
|
|
isPrivate: false
|
|
pathParameters: []
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
_type: request
|
|
- _id: wrk_6b9b8455fd784462ae19cd51d7156f86
|
|
parentId: null
|
|
modified: 1707808692801
|
|
created: 1707808692801
|
|
name: Pre-request Scripts
|
|
description: ""
|
|
scope: collection
|
|
_type: workspace
|
|
- _id: req_244fe815da6c4342a17f0cfd98cf648c
|
|
parentId: wrk_6b9b8455fd784462ae19cd51d7156f86
|
|
modified: 1707809218855
|
|
created: 1707808697304
|
|
url: http://127.0.0.1:4010/echo
|
|
name: Long running task
|
|
description: ""
|
|
method: GET
|
|
body: {}
|
|
preRequestScript: |-
|
|
function delay(ms) {
|
|
return new Promise(resolve => setTimeout(resolve, ms));
|
|
}
|
|
|
|
async function printAfterDelay() {
|
|
console.log("Delaying");
|
|
await delay(3000);
|
|
console.log("Delayed");
|
|
}
|
|
|
|
await printAfterDelay();
|
|
parameters: []
|
|
headers:
|
|
- name: User-Agent
|
|
value: insomnia/8.6.1
|
|
authentication: {}
|
|
metaSortKey: -1707809028499
|
|
isPrivate: false
|
|
pathParameters: []
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
_type: request
|
|
- _id: req_72099fd8f19e47f99554062989302711
|
|
parentId: wrk_6b9b8455fd784462ae19cd51d7156f86
|
|
modified: 1707809035895
|
|
created: 1707809028449
|
|
url: http://127.0.0.1:4010/echo
|
|
name: Range error
|
|
description: ""
|
|
method: GET
|
|
body: {}
|
|
preRequestScript: let arr = new Array(-1); // Negative length
|
|
parameters: []
|
|
headers:
|
|
- name: User-Agent
|
|
value: insomnia/8.6.1
|
|
authentication: {}
|
|
metaSortKey: -1707809028449
|
|
isPrivate: false
|
|
pathParameters: []
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
_type: request
|
|
- _id: req_2e524a047e9346b0a0d568f0f82b1568
|
|
parentId: wrk_6b9b8455fd784462ae19cd51d7156f86
|
|
modified: 1707808953866
|
|
created: 1707808727077
|
|
url: http://127.0.0.1:4010/echo
|
|
name: Syntax error
|
|
description: ""
|
|
method: GET
|
|
body: {}
|
|
preRequestScript: console.log('Hello, world' // Missing closing parenthesis
|
|
parameters: []
|
|
headers:
|
|
- name: User-Agent
|
|
value: insomnia/8.6.1
|
|
authentication: {}
|
|
metaSortKey: -1707808727077
|
|
isPrivate: false
|
|
pathParameters: []
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
_type: request
|
|
- _id: req_a398a5e19cc74611ae5fc9212980c14c
|
|
parentId: wrk_6b9b8455fd784462ae19cd51d7156f86
|
|
modified: 1707808979424
|
|
created: 1707808961112
|
|
url: http://127.0.0.1:4010/echo
|
|
name: Type error
|
|
description: ""
|
|
method: GET
|
|
body: {}
|
|
preRequestScript: |-
|
|
let greeting = "Hello, world";
|
|
console.log(greetting); // Typo in variable name
|
|
parameters: []
|
|
headers:
|
|
- name: User-Agent
|
|
value: insomnia/8.6.1
|
|
authentication: {}
|
|
metaSortKey: -1707808712191
|
|
isPrivate: false
|
|
pathParameters: []
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
_type: request
|
|
- _id: req_3084b61cefc0406e965362cccff9f8ce
|
|
parentId: wrk_6b9b8455fd784462ae19cd51d7156f86
|
|
modified: 1707809017110
|
|
created: 1707809000715
|
|
url: http://127.0.0.1:4010/echo
|
|
name: Reference error
|
|
description: ""
|
|
method: GET
|
|
body: {}
|
|
preRequestScript: console.log(foo); // Typo in variable name
|
|
parameters: []
|
|
headers:
|
|
- name: User-Agent
|
|
value: insomnia/8.6.1
|
|
authentication: {}
|
|
metaSortKey: -1707808704748
|
|
isPrivate: false
|
|
pathParameters: []
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
_type: request
|
|
- _id: env_f9ef1d097c5e00986051fcb4f7a921eea1a86916
|
|
parentId: wrk_6b9b8455fd784462ae19cd51d7156f86
|
|
modified: 1707808692805
|
|
created: 1707808692805
|
|
name: Base Environment
|
|
data: {}
|
|
dataPropertyOrder: null
|
|
color: null
|
|
isPrivate: false
|
|
metaSortKey: 1707808692805
|
|
_type: environment
|
|
- _id: jar_f9ef1d097c5e00986051fcb4f7a921eea1a86916
|
|
parentId: wrk_6b9b8455fd784462ae19cd51d7156f86
|
|
modified: 1707808692807
|
|
created: 1707808692807
|
|
name: Default Jar
|
|
cookies: []
|
|
_type: cookie_jar
|
|
- _id: fld_01de564274824ecaad272330339ea6b2
|
|
parentId: wrk_6b9b8455fd784462ae19cd51d7156f86
|
|
modified: 1668533312225
|
|
created: 1668533312225
|
|
name: FolderWithEnv
|
|
description: ""
|
|
environment:
|
|
customValue: "fromFolder"
|
|
environmentPropertyOrder: null
|
|
metaSortKey: -1668533312225
|
|
_type: request_group
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df3c
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: echo pre-request script result
|
|
description: ""
|
|
method: POST
|
|
body: {}
|
|
parameters: []
|
|
headers: []
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df3d
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: test certificate manipulation
|
|
description: ""
|
|
method: POST
|
|
body: {}
|
|
parameters: []
|
|
headers: []
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
// print the original one
|
|
console.log('key:', insomnia.request.certificate.key.src);
|
|
console.log('cert:', insomnia.request.certificate.cert.src);
|
|
console.log('passphrass:', insomnia.request.certificate.passphrass);
|
|
console.log('pfx:', insomnia.request.certificate.pfx.src);
|
|
// update
|
|
insomnia.request.certificate.update({
|
|
disabled: true,
|
|
key: {src: 'invalid.key'},
|
|
cert: {src: 'invalid.cert'},
|
|
passphrase: '',
|
|
pfx: {src: ''},
|
|
});
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df3e
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: test proxies manipulation
|
|
description: ""
|
|
method: POST
|
|
body: {}
|
|
parameters: []
|
|
headers: []
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
console.log(insomnia.request.proxy.getProxyUrl());
|
|
insomnia.request.proxy.update({
|
|
host: 'localhost',
|
|
match: '<all_urls>',
|
|
port: 8888,
|
|
tunnel: false,
|
|
authenticate: false,
|
|
username: '',
|
|
password: '',
|
|
});
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df00
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: environments setting and overriding
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
insomnia.environment.set("environmentName", insomnia.environment.name);
|
|
insomnia.environment.set("baseEnvironmentName", insomnia.baseEnvironment.name);
|
|
insomnia.environment.set("collectionVariablesName", insomnia.collectionVariables.name);
|
|
// manipulation
|
|
insomnia.baseEnvironment.set('fromBaseEnv', 'baseEnv');
|
|
insomnia.baseEnvironment.set('scriptValue', 'fromBase');
|
|
insomnia.environment.set('scriptValue', 'fromEnv');
|
|
// "preDefinedValue" is already defined in the base environment modal.
|
|
// but it is rewritten here
|
|
insomnia.baseEnvironment.set('preDefinedValue', 'fromScript');
|
|
// "customValue" is already defined in the folder environment.
|
|
// folder version will override the following one
|
|
insomnia.baseEnvironment.set('customValue', 'fromScript');
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"environmentName": "{{ _.environmentName }}",
|
|
"baseEnvironmentName": "{{ _.baseEnvironmentName }}",
|
|
"collectionVariablesName": "{{ _.collectionVariablesName }}",
|
|
"fromBaseEnv": "{{ _.fromBaseEnv }}",
|
|
"scriptValue": "{{ _.scriptValue }}",
|
|
"preDefinedValue": "{{ _.preDefinedValue }}",
|
|
"customValue": "{{ _.customValue }}"
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df01
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: variables / manipulate variables and set them to environment
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
// set local
|
|
insomnia.variables.set('varStr', 'varStr');
|
|
insomnia.variables.set('varNum', 777);
|
|
insomnia.variables.set('varBool', true);
|
|
// has
|
|
insomnia.environment.set('varStr', insomnia.variables.get('varStr'));
|
|
insomnia.environment.set('varNum', insomnia.variables.get('varNum'));
|
|
insomnia.environment.set('varBool', insomnia.variables.get('varBool'));
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"varStr": "{{ _.varStr }}",
|
|
"varNum": {{ _.varNum }},
|
|
"varBool": {{ _.varBool }}
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df02
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: require / require classes from insomnia-collection module and init them
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
const { Property, Header, Variable, QueryParam, Url, RequestAuth, ProxyConfig, Cookie, Certificate, RequestBody, Request, Response } = require('insomnia-collection');
|
|
const prop = new Property('pid', 'pname');
|
|
const header = new Header({ key: 'headerKey', value: 'headerValue' });
|
|
const variable = new Variable({ key: 'headerKey', value: 'headerValue' });
|
|
const qParam = new QueryParam({ key: 'queryKey', value: 'queryValue' });
|
|
const url = new Url({
|
|
host: ['insomnia', 'rest'],
|
|
path: ['path1', 'path2'],
|
|
protocol: 'https',
|
|
});
|
|
const proxyConfig = new ProxyConfig({
|
|
match: 'http+https://*.example.com:80/*',
|
|
host: 'proxy.com',
|
|
port: 8080,
|
|
tunnel: true,
|
|
disabled: false,
|
|
authenticate: true,
|
|
username: 'proxy_username',
|
|
password: 'proxy_password',
|
|
});
|
|
const reqAuth = new RequestAuth({
|
|
type: 'basic',
|
|
basic: [
|
|
{ key: 'username', value: 'user1' },
|
|
{ key: 'password', value: 'pwd1' },
|
|
],
|
|
});
|
|
const cookie = new Cookie({ key: 'queryKey', value: 'queryValue' });
|
|
const cert = new Certificate({
|
|
name: 'Certificate for example.com',
|
|
matches: ['https://example.com'],
|
|
key: { src: '/User/path/to/certificate/key' },
|
|
cert: { src: '/User/path/to/certificate' },
|
|
passphrase: 'iampassphrase',
|
|
});
|
|
const reqBody = new RequestBody({
|
|
mode: 'urlencoded',
|
|
urlencoded: [
|
|
{ key: 'urlencodedKey', value: 'urlencodedValue' },
|
|
],
|
|
options: {},
|
|
});
|
|
const req = new Request({
|
|
url: 'https://hostname.com/path',
|
|
method: 'GET',
|
|
header: [
|
|
{ key: 'header1', value: 'val1' },
|
|
{ key: 'header2', value: 'val2' },
|
|
],
|
|
body: {
|
|
mode: 'raw',
|
|
raw: 'body content',
|
|
},
|
|
auth: {
|
|
type: 'basic',
|
|
basic: [
|
|
{ key: 'username', value: 'myname' },
|
|
{ key: 'password', value: 'mypwd' },
|
|
],
|
|
},
|
|
proxy: undefined,
|
|
certificate: undefined,
|
|
});
|
|
const resp = new Response({
|
|
code: 200,
|
|
reason: 'OK',
|
|
header: [
|
|
{ key: 'header1', value: 'val1' },
|
|
{ key: 'header2', value: 'val2' },
|
|
{ key: 'Content-Length', value: '100' },
|
|
{ key: 'Content-Disposition', value: 'attachment; filename="filename.txt"' },
|
|
{ key: 'Content-Type', value: 'text/plain; charset=utf-8' },
|
|
],
|
|
cookie: [
|
|
{ key: 'header1', value: 'val1' },
|
|
{ key: 'header2', value: 'val2' },
|
|
],
|
|
body: '{"key": 888}',
|
|
stream: undefined,
|
|
responseTime: 100,
|
|
status: 'OK',
|
|
originalRequest: req,
|
|
});
|
|
// set part of values
|
|
insomnia.environment.set('propJson', JSON.stringify(prop.toJSON()));
|
|
insomnia.environment.set('headerJson', JSON.stringify(header.toJSON()));
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"propJson": {{ _.propJson }},
|
|
"headerJson": {{ _.headerJson }}
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df03
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: insomnia.request manipulation
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
const { Header } = require('insomnia-collection');
|
|
insomnia.request.method = 'GET';
|
|
insomnia.request.url.addQueryParams('k1=v1');
|
|
insomnia.request.headers.add(new Header({
|
|
key: 'Content-Type',
|
|
value: 'text/plain'
|
|
}));
|
|
insomnia.request.headers.add(new Header({
|
|
key: 'X-Hello',
|
|
value: 'hello'
|
|
}));
|
|
insomnia.request.body.update({
|
|
mode: 'raw',
|
|
raw: 'rawContent',
|
|
});
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df05
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: insomnia.request auth manipulation (bearer)
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
insomnia.request.auth.update(
|
|
{
|
|
type: 'bearer',
|
|
bearer: [
|
|
{key: 'token', value: 'tokenValue'},
|
|
{key: 'prefix', value: 'CustomTokenPrefix'},
|
|
],
|
|
},
|
|
'bearer'
|
|
);
|
|
body:
|
|
mimeType: "application/json"
|
|
text: '{}'
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df06
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: insomnia.request auth manipulation (basic)
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
insomnia.request.auth.update(
|
|
{
|
|
type: 'basic',
|
|
basic: [
|
|
{key: 'username', value: 'myName'},
|
|
{key: 'password', value: 'myPwd'},
|
|
],
|
|
},
|
|
'basic'
|
|
);
|
|
body:
|
|
mimeType: "application/json"
|
|
text: '{}'
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df07
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: eval() works in script
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
const evalResult = eval('8+8');
|
|
insomnia.environment.set('evalResult', evalResult);
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"evalResult": {{ _.evalResult }}
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df08
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: require the url module
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
const { URL } = require('url');
|
|
const url = new URL('https://user:pwd@insomnia.com:6666/p1?q1=a&q2=b#hashcontent');
|
|
insomnia.environment.set('hash', "#hashcontent");
|
|
insomnia.environment.set('host', "insomnia.com:6666");
|
|
insomnia.environment.set('hostname', "insomnia.com");
|
|
insomnia.environment.set('href', "https://user:pwd@insomnia.com:6666/p1?q1=a&q2=b#hashcontent");
|
|
insomnia.environment.set('origin', "https://insomnia.com:6666");
|
|
insomnia.environment.set('password', "pwd");
|
|
insomnia.environment.set('pathname', "/p1");
|
|
insomnia.environment.set('port', "6666");
|
|
insomnia.environment.set('protocol', "https:");
|
|
insomnia.environment.set('search', "?q1=a&q2=b");
|
|
insomnia.environment.set('username', "user");
|
|
insomnia.environment.set('seachParam', url.searchParams.toString());
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"hash": "{{ _.hash }}",
|
|
"host": "{{ _.host }}",
|
|
"hostname": "{{ _.hostname }}",
|
|
"href": "{{ _.href }}",
|
|
"origin": "{{ _.origin }}",
|
|
"password": "{{ _.password }}",
|
|
"pathname": "{{ _.pathname }}",
|
|
"port": "{{ _.port }}",
|
|
"protocol": "{{ _.protocol }}",
|
|
"search": "{{ _.search }}",
|
|
"username": "{{ _.username }}",
|
|
"seachParam": "{{ _.seachParam }}"
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df09
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: require node.js modules
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
const path = require('path');
|
|
const assert = require('assert');
|
|
const buffer = require('buffer');
|
|
const util = require('util');
|
|
const url = require('url');
|
|
const punycode = require('punycode');
|
|
const querystring = require('querystring');
|
|
const stringDecoder = require('string_decoder');
|
|
const stream = require('stream');
|
|
const timers = require('timers');
|
|
const events = require('events');
|
|
// set them
|
|
insomnia.environment.set('path', path != null);
|
|
insomnia.environment.set('assert', assert != null);
|
|
insomnia.environment.set('buffer', buffer != null);
|
|
insomnia.environment.set('util', util != null);
|
|
insomnia.environment.set('url', url != null);
|
|
insomnia.environment.set('punycode', punycode != null);
|
|
insomnia.environment.set('querystring', querystring != null);
|
|
insomnia.environment.set('stringDecoder', stringDecoder != null);
|
|
insomnia.environment.set('stream', stream != null);
|
|
insomnia.environment.set('timers', timers != null);
|
|
insomnia.environment.set('events', events != null);
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"path": {{ _.path }},
|
|
"assert": {{ _.assert }},
|
|
"buffer": {{ _.buffer }},
|
|
"util": {{ _.util }},
|
|
"url": {{ _.url }},
|
|
"punycode": {{ _.punycode }},
|
|
"querystring": {{ _.querystring }},
|
|
"stringDecoder": {{ _.stringDecoder }},
|
|
"stream": {{ _.stream }},
|
|
"timers": {{ _.timers }},
|
|
"events": {{ _.events }}
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df1
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: insomnia.test
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
insomnia.test('happy tests', () => {
|
|
insomnia.expect(200).to.eql(200);
|
|
insomnia.expect('uname').to.be.a('string');
|
|
insomnia.expect('a').to.have.lengthOf(1);
|
|
insomnia.expect('xxx_customer_id_yyy').to.include("customer_id");
|
|
insomnia.expect(201).to.be.oneOf([201,202]);
|
|
insomnia.expect(199).to.be.below(200);
|
|
// test objects
|
|
insomnia.expect({a: 1, b: 2}).to.have.all.keys('a', 'b');
|
|
insomnia.expect({a: 1, b: 2}).to.have.any.keys('a', 'b');
|
|
insomnia.expect({a: 1, b: 2}).to.not.have.any.keys('c', 'd');
|
|
insomnia.expect({a: 1}).to.have.property('a');
|
|
insomnia.expect({a: 1, b: 2}).to.be.a('object')
|
|
.that.has.all.keys('a', 'b');
|
|
});
|
|
insomnia.test('unhappy tests', () => {
|
|
insomnia.expect(199).to.eql(200);
|
|
insomnia.expect(199).to.be.oneOf([201,202]);
|
|
});
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df2
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: get sendRequest response through await or callback
|
|
description: ""
|
|
method: GET
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
let respFromCallback;
|
|
const respFromAwait = await insomnia.sendRequest(
|
|
'http://127.0.0.1:4010/echo',
|
|
(err, resp) => {
|
|
if (err != null) {
|
|
throw err;
|
|
} else {
|
|
respFromCallback = resp;
|
|
}
|
|
}
|
|
);
|
|
insomnia.environment.set('bodyFromAwait', respFromAwait.body);
|
|
insomnia.environment.set('bodyFromCallback', respFromCallback.body);
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"bodyFromAwait": {{ _.bodyFromAwait }},
|
|
"bodyFromCallback": {{ _.bodyFromCallback }}
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df10
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: require the uuid module
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
const uuid = require('uuid');
|
|
insomnia.environment.set('uuid', uuid.NIL);
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"uuid": "{{ _.uuid}}"
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df11
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: require external modules and built-in lodash
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
const atob = require('atob');
|
|
const btoa = require('btoa');
|
|
const chai = require('chai');
|
|
const cheerio = require('cheerio');
|
|
const crypto = require('crypto-js');
|
|
const csv = require('csv-parse/lib/sync');
|
|
const lodash = require('lodash');
|
|
const moment = require('moment');
|
|
const tv4 = require('tv4');
|
|
const uuid = require('uuid');
|
|
const xml2js = require('xml2js');
|
|
// set them
|
|
insomnia.environment.set('atob', atob != null);
|
|
insomnia.environment.set('btoa', btoa != null);
|
|
insomnia.environment.set('chai', chai != null);
|
|
insomnia.environment.set('cheerio', cheerio != null);
|
|
insomnia.environment.set('crypto', crypto != null);
|
|
insomnia.environment.set('csv', csv != null);
|
|
insomnia.environment.set('lodash', lodash != null);
|
|
insomnia.environment.set('moment', moment != null);
|
|
insomnia.environment.set('tv4', tv4 != null);
|
|
insomnia.environment.set('uuid', uuid != null);
|
|
insomnia.environment.set('xml2js', xml2js != null);
|
|
insomnia.environment.set('builtInLodash', _ != null);
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"atob": {{ _.atob }},
|
|
"btoa": {{ _.btoa }},
|
|
"chai": {{ _.chai }},
|
|
"cheerio": {{ _.cheerio }},
|
|
"crypto": {{ _.crypto }},
|
|
"csv": {{ _.csv }},
|
|
"lodash": {{ _.lodash }},
|
|
"moment": {{ _.moment }},
|
|
"tv4": {{ _.tv4 }},
|
|
"uuid": {{ _.uuid }},
|
|
"xml2js": {{ _.xml2js }},
|
|
"builtInLodash": {{ _.builtInLodash }}
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df12
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: not return until all Promise settled
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
new Promise(resolve => {
|
|
setTimeout(() => {
|
|
insomnia.environment.set("asyncTaskDone", true);
|
|
resolve();
|
|
}, 500)
|
|
});
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"asyncTaskDone": {{ _.asyncTaskDone}}
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df13
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: not return until all setTimeout finished
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
setTimeout(() => {
|
|
insomnia.environment.set("asyncTaskDone", true);
|
|
}, 500)
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"asyncTaskDone": {{ _.asyncTaskDone}}
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df14
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: not return until all async tasks finished
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
const resp = insomnia.sendRequest(
|
|
'http://127.0.0.1:4010/echo',
|
|
(err, resp) => {
|
|
if (err != null) {
|
|
throw err;
|
|
} else {
|
|
insomnia.environment.set("asyncTaskDone", true);
|
|
}
|
|
}
|
|
);
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{
|
|
"asyncTaskDone": {{ _.asyncTaskDone}}
|
|
}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df15
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: persist environment
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
insomnia.environment.set('__fromScript', 'environment');
|
|
insomnia.baseEnvironment.set('__fromScript1', 'baseEnvironment');
|
|
insomnia.collectionVariables.set('__fromScript2', 'collection');
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{}
|
|
_type: request
|
|
- _id: req_89dade2ee9ee42fbb22d588783a9df16
|
|
parentId: fld_01de564274824ecaad272330339ea6b2
|
|
modified: 1636707449231
|
|
created: 1636141014552
|
|
url: http://127.0.0.1:4010/echo
|
|
name: use external modules
|
|
description: ""
|
|
method: POST
|
|
parameters: []
|
|
headers:
|
|
- name: 'Content-Type'
|
|
value: 'application/json'
|
|
authentication: {}
|
|
metaSortKey: -1636141014553
|
|
isPrivate: false
|
|
settingStoreCookies: true
|
|
settingSendCookies: true
|
|
settingDisableRenderRequestBody: false
|
|
settingEncodeUrl: true
|
|
settingRebuildPath: true
|
|
settingFollowRedirects: global
|
|
preRequestScript: |-
|
|
const ajv = require("ajv")
|
|
const chai = require('chai');
|
|
const lodash = require('lodash');
|
|
const tv4 = require('tv4');
|
|
const uuid = require('uuid');
|
|
const xml2js = require('xml2js');
|
|
const csv = require('csv-parse/lib/sync');
|
|
const cheerio = require('cheerio');
|
|
const crypto = require('crypto-js');
|
|
const moment = require('moment');
|
|
body:
|
|
mimeType: "application/json"
|
|
text: |-
|
|
{}
|
|
_type: request
|