@loadmill/core 0.3.51 → 0.3.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/conf/defaults.ts +0 -25
- package/src/conf/extrema.ts +0 -36
- package/src/conf/index.ts +0 -95
- package/src/conf/notifications.ts +0 -17
- package/src/conf/types.ts +0 -100
- package/src/conf/validate.ts +0 -559
- package/src/distributed-logger-reporter.ts +0 -19
- package/src/echo/firehose.ts +0 -64
- package/src/echo/index.ts +0 -4
- package/src/echo/stats.ts +0 -84
- package/src/har/index.ts +0 -81
- package/src/multipart-form-data/form-data-utils.ts +0 -81
- package/src/multipart-form-data/is-binary-file.ts +0 -206
- package/src/multipart-form-data/multipart-text-to-post-form-data.ts +0 -149
- package/src/parameters/extractions.ts +0 -53
- package/src/parameters/extractors/cheerio-extractor.ts +0 -57
- package/src/parameters/extractors/expression-extractor.ts +0 -13
- package/src/parameters/extractors/extractor.ts +0 -3
- package/src/parameters/extractors/header-extractor.ts +0 -24
- package/src/parameters/extractors/index.ts +0 -10
- package/src/parameters/extractors/json-path-extractor.ts +0 -63
- package/src/parameters/extractors/parametrized-extractor.ts +0 -27
- package/src/parameters/extractors/regex-extractor.ts +0 -18
- package/src/parameters/extractors/regex-matcher.ts +0 -17
- package/src/parameters/extractors/ws-extractor.ts +0 -91
- package/src/parameters/generate-random.ts +0 -114
- package/src/parameters/index.ts +0 -624
- package/src/parameters/json-path-utils.ts +0 -20
- package/src/parameters/operators/binary-operator.ts +0 -23
- package/src/parameters/operators/index.ts +0 -39
- package/src/parameters/parameter-functions/boolean-parameter-functions.ts +0 -24
- package/src/parameters/parameter-functions/crypto.ts +0 -55
- package/src/parameters/parameter-functions/json-schema.ts +0 -29
- package/src/parameters/parameter-functions/numeric-input-parameter-functions.ts +0 -22
- package/src/parameters/parameter-functions/numeric-parameter-functions.ts +0 -37
- package/src/parameters/parameter-functions/parameter-function-utils.ts +0 -55
- package/src/parameters/parameter-functions/parameter-function.ts +0 -7
- package/src/parameters/parameter-functions/parameter-functions.ts +0 -54
- package/src/parameters/parameter-functions/random-parameter-functions.ts +0 -22
- package/src/parameters/parameter-functions/textual-parameter-functions.ts +0 -464
- package/src/parameters/parameter-regex-providers.ts +0 -78
- package/src/parameters/resolvers/random-parameters-resolver.ts +0 -8
- package/src/parameters/type.ts +0 -7
- package/src/parameters/value-utils.ts +0 -47
- package/src/request/index.ts +0 -526
- package/src/schema/json-schema-generator.ts +0 -76
- package/test/conf/validate.spec.js +0 -141
- package/test/har/is-har.spec.js +0 -33
- package/test/multipart-form-data/form-data-utils.spec.ts +0 -142
- package/test/multipart-form-data/resources/multipart-form-data-file-text-content.json +0 -5
- package/test/parameters/builtin-functions.spec.js +0 -85
- package/test/parameters/json-path-utils.spec.ts +0 -50
- package/test/parameters/parameter-functions.spec.js +0 -48
- package/test/parameters/parameter-utils.spec.js +0 -185
- package/test/parameters/regex-functions.spec.ts +0 -57
- package/test/parameters/value-utils.spec.js +0 -73
- package/test/schema/json-schema-generator.spec.js +0 -227
- package/tsconfig.json +0 -9
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
const { expect } = require('chai');
|
|
2
|
-
const { describe, it } = require('mocha');
|
|
3
|
-
|
|
4
|
-
const { parameterUtils, ParameterError } = require('../../dist/parameters');
|
|
5
|
-
const _ = require('lodash');
|
|
6
|
-
|
|
7
|
-
describe('parameter utils', () => {
|
|
8
|
-
const testParameters = [
|
|
9
|
-
{
|
|
10
|
-
'origin_1': 'test1.com'
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
'origin_2': 'test2.com'
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
'origin_3': 'test3.com'
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
'origin_5': 'test5.com'
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
'origin_7': 'test7.com'
|
|
23
|
-
}
|
|
24
|
-
];
|
|
25
|
-
|
|
26
|
-
it('validate suggestNewParamName function', () => {
|
|
27
|
-
let paramName = 'origin1';
|
|
28
|
-
let newKey = parameterUtils.suggestNewParamName(paramName, testParameters);
|
|
29
|
-
expect(newKey).equal('origin2');
|
|
30
|
-
|
|
31
|
-
paramName = 'stagingUrl';
|
|
32
|
-
newKey = parameterUtils.suggestNewParamName(paramName, testParameters);
|
|
33
|
-
expect(newKey).equal('stagingUrl_1');
|
|
34
|
-
|
|
35
|
-
paramName = 'origin_1';
|
|
36
|
-
newKey = parameterUtils.suggestNewParamName(paramName, testParameters);
|
|
37
|
-
expect(newKey).equal('origin_4');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('resolveAllExpressions', () => {
|
|
41
|
-
const res = parameterUtils.resolveAllExpressions([
|
|
42
|
-
{ d: '12' },
|
|
43
|
-
{ b: '${d}' },
|
|
44
|
-
{ c: '${__random_letters(b)}' },
|
|
45
|
-
]);
|
|
46
|
-
expect(res).to.include({ b: '12', d: '12' });
|
|
47
|
-
expect(res.c).to.be.a('string');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
describe('recursively find all used parameters', () => {
|
|
51
|
-
it(' get [{a:1}, {b:__random_letters(a)}] expect [{a:1}, {b:__random_letters(a)}]', () => {
|
|
52
|
-
const paramArr = [{ 'a':'1' },{ 'b':'${__random_letters(a)}' }];
|
|
53
|
-
const res = parameterUtils.findUsedParameters(paramArr, { 'b':'${__random_letters(a)}' }, []);
|
|
54
|
-
expect(res).to.have.deep.members(paramArr); // to.have.deep.memebers means equality of array of objects but order doesn't matter
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('get [{"a":"12"},{"b":"${a}"},{"c":"${__random_letters(b)}"}] expect [{"a":"12"},{"b":"${a}"},{"c":"${__random_letters(b)}"}]', () => {
|
|
58
|
-
const paramArr = [{ 'a':'12' },{ 'b':'${a}' },{ 'c':'${__random_letters(b)}' }];
|
|
59
|
-
const res = parameterUtils.findUsedParameters(paramArr, { 'c':'${__random_letters(b)}' }, []);
|
|
60
|
-
expect(res).to.have.deep.members(paramArr); // to.have.deep.memebers means equality of array of objects but order doesn't matter
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('get [{ number: "123" },{ letters: "${__random_letters(number)}" },{ rak: "Bibi" }] expect [{ number: "123" },{ letters: "${__random_letters(number)}" }', async () => {
|
|
64
|
-
const parameters = [
|
|
65
|
-
{ number: '123' },
|
|
66
|
-
{ letters: '${__random_letters(number)}' },
|
|
67
|
-
{ rak: 'Bibi' }
|
|
68
|
-
];
|
|
69
|
-
const res = parameterUtils.findUsedParameters(
|
|
70
|
-
parameters, { letters: '${__random_letters(number)}' }, []);
|
|
71
|
-
expect(res).to.have.deep.members([
|
|
72
|
-
{ number: '123' },
|
|
73
|
-
{ letters: '${__random_letters(number)}' }
|
|
74
|
-
]);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('get [{ a: "1" },{ b: "${a}" },{ c: "${a + b}" },{ d: "${__random_letters(c)}" }] expect [{ a: "1" },{ b: "${a}" },{ c: "${a + b}" },{ d: "${__random_letters(c)}" }]', async () => {
|
|
78
|
-
const parameters = [
|
|
79
|
-
{ a: '1' },
|
|
80
|
-
{ b: '${a}' },
|
|
81
|
-
{ c: '${a + b}' },
|
|
82
|
-
{ d: '${__random_letters(c)}' }
|
|
83
|
-
];
|
|
84
|
-
const res = parameterUtils.findUsedParameters(
|
|
85
|
-
parameters, { d: '${__random_letters(c)}' }, []);
|
|
86
|
-
expect(res).to.have.deep.ordered.members([
|
|
87
|
-
{ a: '1' },
|
|
88
|
-
{ b: '${a}' },
|
|
89
|
-
{ c: '${a + b}' },
|
|
90
|
-
{ d: '${__random_letters(c)}' }
|
|
91
|
-
]); // to.have.deep.ordered.members is deep (not strict) equality of array of objects
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('get [{ a: "1" },{ b: "${a}" },{ c: "${a + b}" },{ d: "${__if_then_else(a,b,c)}" }] expect [{ a: "1" },{ b: "${a}" },{ c: "${a + b}" },{ d: "${__if_then_else(a,b,c)}" }]', async () => {
|
|
95
|
-
const parameters = [
|
|
96
|
-
{ a: '1' },
|
|
97
|
-
{ b: '${a}' },
|
|
98
|
-
{ c: '${a + b}' },
|
|
99
|
-
{ d: '${__if_then_else(a,b,c)}' }
|
|
100
|
-
];
|
|
101
|
-
const res = parameterUtils.findUsedParameters(
|
|
102
|
-
parameters, { d: '${__if_then_else(a,b,c)}' }, []);
|
|
103
|
-
expect(res).to.have.deep.ordered.members([
|
|
104
|
-
{ a: '1' },
|
|
105
|
-
{ b: '${a}' },
|
|
106
|
-
{ c: '${a + b}' },
|
|
107
|
-
{ d: '${__if_then_else(a,b,c)}' }
|
|
108
|
-
]); // to.have.deep.ordered.members is deep (not strict) ordered equality of array of objects
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
describe('circular dependency - infinite recursion', () => {
|
|
113
|
-
it('parameter calls itself - singular case', () => {
|
|
114
|
-
const param = { 'a': '${a}' };
|
|
115
|
-
expect(() => parameterUtils.findUsedParameters(
|
|
116
|
-
[param], param, []
|
|
117
|
-
)).to.throw().and.be.an.instanceOf(ParameterError);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('parameter a calls b and vice versa - double case', () => {
|
|
121
|
-
const param = { 'a': '${b}' };
|
|
122
|
-
const params = [{ 'a': '${b}' }, { 'b': '${a}' }];
|
|
123
|
-
expect(() => parameterUtils.findUsedParameters(
|
|
124
|
-
params, param, []
|
|
125
|
-
)).to.throw().and.be.an.instanceOf(ParameterError);
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('parameter a_1 calls a_2 and so on... - general case', () => {
|
|
129
|
-
const params = [{ 'a_1': '${a_2}' }, { 'a_2': '${a_3}' }, { 'a_3': '${a_4}' }, { 'a_4': '${a_1}' }];
|
|
130
|
-
const param = _.sample(params);
|
|
131
|
-
expect(() => parameterUtils.findUsedParameters(
|
|
132
|
-
params, param, []
|
|
133
|
-
)).to.throw().and.be.an.instanceOf(ParameterError);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
describe('Test get used request param names', () => {
|
|
138
|
-
/* eslint-disable */
|
|
139
|
-
const goodStringifiedRequest = '{"url":"www.${a}.com/${b}","body":"${c}","headers":[{"name":"arnon","value":"${d}"}],"assertions":[{"value":"${g}","expression":"e","operation":2,"allParamNames":["e","","__launchedBy","__requestStartTime","__responseEndTime","__responseTime","__status","__statusText","__testRunId","__testStartTime"]}],"extractions":[{"attr":"","parameter":"e","expression":"${f}","type":0}],"loop":{"iterations":1,"assert":{"value":"${h}","expression":"e","operation":2},"open":true,"allParamNames":["e","","__launchedBy","__requestStartTime","__responseEndTime","__responseTime","__status","__statusText","__testRunId","__testStartTime"]}}';
|
|
140
|
-
const goodFunctionStringifiedRequest = '{"url":"www.${__random_letters(a)}.com/${__random_digits(b)}","body":"${__mult(c,d)}","headers":[{"name":"yochai","value":"${__add(e,f)}"}],"assertions":[{"value":"${__not(j)}","expression":"g","operation":2,"allParamNames":["g","","__launchedBy","__requestStartTime","__responseEndTime","__responseTime","__status","__statusText","__testRunId","__testStartTime"]}],"extractions":[{"attr":"","parameter":"g","expression":"${__neqi(h,i)}","type":0}],"loop":{"iterations":1,"assert":{"value":"${__abs(k)}","expression":"g","operation":2},"open":true,"allParamNames":["g","","__launchedBy","__requestStartTime","__responseEndTime","__responseTime","__status","__statusText","__testRunId","__testStartTime"]}}';
|
|
141
|
-
const badStringifiedRequest = '"url":"www","body":"","headers":[{"name":"","value":""}],"assertions":[{"value":"","expression":"","operation":0}],"extractions":[{"attr":"","parameter":"b","expression":"$.ayda","type":1},{"attr":"","parameter":"s_2","expression":"${\'4\' + \'3\'}","type":0}]}';
|
|
142
|
-
const bigBadStringifiedRequest = '{"url":"httpbin.org/anything","body":"{\n \"DailyMiniSnacksUnlocksAtMiliSec\": 1598270588383,\n \"activeTriplePromotionIds\": [],\n \"score\": 1910,\n \"jp_t\": 0,\n \"name\": \"Guest_18288\",\n \"raid\": {\n \"name\": \"Elaine\",\n \"id\": \"11111977\",\n \"image\": \"m:862236603899436\",\n \"coins\": 858000,\n \"raid_target\": \"nf\"\n },\n \"superBet\": {\n \"betLevel\": 1,\n \"betOptions\": [\n 1,\n 2,\n 3,\n 5\n ]\n },\n \"messages\": [],\n \"genericRewards\": [],\n \"pendingFriendsCount\": 0,\n \"image\": 1,\n \"spins\": 99,\n \"shields\": 0,\n \"maxShields\": 3,\n \"village\": 77,\n \"coins\": 100000,\n \"fillTime\": 1598270588362,\n \"msToNextDailyBonus\": 0,\n \"dailybonusextra\": 0,\n \"dailybonusextraPurchaseDisabled\": false,\n \"piggy\": {\n \"coins\": 1000000,\n \"productCode\": \"com.moonactive.cm.piggy.a\"\n },\n \"cardsXP\": 5,\n \"Ship\": 0,\n \"Farm\": 0,\n \"Crop\": 0,\n \"Statue\": 0,\n \"House\": 0,\n \"now\": 1598270590835,\n \"pay\": 0,\n \"seq\": 401,\n \"random\": {\n \"id\": \"11111980\",\n \"image\": \"10206586805734310\",\n \"name\": \"Denise\",\n \"coins\": 2442000,\n \"village\": {\n \"shields\": 0,\n \"village\": 56,\n \"Ship\": 1,\n \"Farm\": 13,\n \"Crop\": 12,\n \"Statue\": 1,\n \"House\": 1\n }\n },\n \"attack\": {\n \"id\": \"11111980\",\n \"image\": \"10206586805734310\",\n \"name\": \"Denise\",\n \"coins\": 2442000,\n \"village\": {\n \"shields\": 0,\n \"village\": 56,\n \"Ship\": 123,\n \"Farm\": 13,\n \"Crop\": 12,\n \"Statue\": 1,\n \"House\": 1\n }\n },\n \"r1\": 3,\n \"r2\": 3,\n \"r3\": 3,\n \"reward\": 2,\n \"coupons\": []\n}","headers":[{"name":"","value":""}],"assertions":[{"value":"","expression":"","operation":0}],"extractions":[{"attr":"","parameter":"village","expression":"$.json.attack.village","type":1},{"attr":"","parameter":"Ship","expression":"${__jsonpath(village,\'$.Ship\')}","type":0},{"attr":"","parameter":"shipIndicator_1","expression":"${Ship == \'1\'}","type":0},{"attr":"","parameter":"shipIndicator_15","expression":"${Ship == \'15\'}","type":0},{"attr":"","parameter":"shipBadIndicator","expression":"${__or(shipIndicator_1,shipIndicator_15)}","type":0},{"attr":"","parameter":"Farm","expression":"${__jsonpath(village,\'$.Farm\')}","type":0},{"attr":"","parameter":"farmIndicator_1","expression":"${Farm == \'1\'}","type":0},{"attr":"","parameter":"farmIndicator_15","expression":"${Farm == \'15\'}","type":0},{"attr":"","parameter":"farmBadIndicator","expression":"${__or(farmIndicator_1,farmIndicator_15)}","type":0},{"attr":"","parameter":"toAttack","expression":"${__switch(shipBadIndicator,\'false\',\'Ship\',farmBadIndicator,\'false\',\'Farm\')}","type":0},{"attr":"","parameter":"payload","expression":"${__jsonpath(village,toAttack)}","type":0}]}';
|
|
143
|
-
const noParenthesisBuiltInFunctionStringifiedRequest = '{"url":"www.arnon.com","body":"{\"usd\":\"${__usd}\",\"random_id\":\"${__random_uuid}\",\"now\":\"${__now}\",\"date_iso\":\"${__date_iso}\",\"now_iso\":${__now_iso}\"}","headers":[{"name":"","value":""}],"assertions":[{"value":"","expression":"","operation":0,"allParamNames":["","__launchedBy","__requestStartTime","__responseEndTime","__responseTime","__status","__statusText","__testRunId","__testStartTime"]}],"extractions":[{"attr":"","parameter":"","expression":"","type":1}],"loop":{"iterations":1,"assert":{"value":"","expression":"","operation":0},"open":false,"allParamNames":["","__launchedBy","__requestStartTime","__responseEndTime","__responseTime","__status","__statusText","__testRunId","__testStartTime"]}}';
|
|
144
|
-
/* eslint-enable */
|
|
145
|
-
|
|
146
|
-
it('good request normal params', () => {
|
|
147
|
-
const res = parameterUtils.getUsedRequestParamNames(goodStringifiedRequest);
|
|
148
|
-
expect(res.sort()).to.have.ordered.members(['a','b','c','d','f','g','h']);
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it('good request built-in function params', () => {
|
|
152
|
-
const res = parameterUtils.getUsedRequestParamNames(goodFunctionStringifiedRequest);
|
|
153
|
-
expect(res.sort()).to.have.ordered.members(['a','b','c','d','e','f','h','i','j','k']);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('bad request expect valid param names', () => {
|
|
157
|
-
const res = parameterUtils.getUsedRequestParamNames(badStringifiedRequest);
|
|
158
|
-
expect(res).to.have.ordered.members([]);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('longer bad request expect valid param names', () => {
|
|
162
|
-
const res = parameterUtils.getUsedRequestParamNames(bigBadStringifiedRequest);
|
|
163
|
-
expect(_.sortedUniq(res.sort())).to.have.ordered.members(
|
|
164
|
-
[
|
|
165
|
-
'Farm',
|
|
166
|
-
'Ship',
|
|
167
|
-
'farmBadIndicator',
|
|
168
|
-
'farmIndicator_1',
|
|
169
|
-
'farmIndicator_15',
|
|
170
|
-
'shipBadIndicator',
|
|
171
|
-
'shipIndicator_1',
|
|
172
|
-
'shipIndicator_15',
|
|
173
|
-
'toAttack',
|
|
174
|
-
'village'
|
|
175
|
-
]
|
|
176
|
-
);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it('Loadmill built in functions without parenthesis should not be considered used params', () => {
|
|
180
|
-
const res = parameterUtils.getUsedRequestParamNames(noParenthesisBuiltInFunctionStringifiedRequest);
|
|
181
|
-
expect(res).to.have.ordered.members([]);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { describe, it } from 'mocha';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
import { getCsrfTokenByRegexp } from '../../src/parameters';
|
|
4
|
-
|
|
5
|
-
describe('getCsrfTokenByRegex function', () => {
|
|
6
|
-
it ('Double quotes', () => {
|
|
7
|
-
expect(getCsrfTokenByRegexp('const csrf = "fndfjsjfisdga" ')[1]).to.equal('fndfjsjfisdga');
|
|
8
|
-
});
|
|
9
|
-
it ('Single quotes', () => {
|
|
10
|
-
expect(getCsrfTokenByRegexp('const csrf = \'fndfjsjfisdga\' ')[1]).to.equal('fndfjsjfisdga');
|
|
11
|
-
});
|
|
12
|
-
it ('Slash and double quotes', () => {
|
|
13
|
-
expect(getCsrfTokenByRegexp('const csrf = \\"fndfjsjfisdga\\" ')[1]).to.equal('fndfjsjfisdga');
|
|
14
|
-
});
|
|
15
|
-
it ('Slash and single quotes', () => {
|
|
16
|
-
expect(getCsrfTokenByRegexp('const csrf = \'fndfjsjfisdga\' ')[1]).to.equal('fndfjsjfisdga');
|
|
17
|
-
});
|
|
18
|
-
it ('CSRF in uppercase', () => {
|
|
19
|
-
expect(getCsrfTokenByRegexp('const CSRF = "fndfjsjfisdga" ')[1]).to.equal('fndfjsjfisdga');
|
|
20
|
-
expect(getCsrfTokenByRegexp('const blaCSRFbla = "fndfjsjfisdga" ')[1]).to.equal('fndfjsjfisdga');
|
|
21
|
-
expect(getCsrfTokenByRegexp('const blaCSRFbla = "fndfjsjfisdga" ')[0]).to.equal('blaCSRFbla = "fndfjsjfisdga"');
|
|
22
|
-
});
|
|
23
|
-
it ('csrf is hidden in a word', () => {
|
|
24
|
-
expect(getCsrfTokenByRegexp('const blacsrfbla = "fndfjsjfisdga" ')[1]).to.equal('fndfjsjfisdga');
|
|
25
|
-
expect(getCsrfTokenByRegexp('const blacsrfbla = "fndfjsjfisdga" ')[0]).to.equal('blacsrfbla = "fndfjsjfisdga"');
|
|
26
|
-
});
|
|
27
|
-
it ('Empty quotes', () => {
|
|
28
|
-
expect(getCsrfTokenByRegexp('const csrf = \'\' ')).to.equal(null);
|
|
29
|
-
expect(getCsrfTokenByRegexp('const csrf = "" ')).to.equal(null);
|
|
30
|
-
expect(getCsrfTokenByRegexp('const csrf = ""blablabla ')).to.equal(null);
|
|
31
|
-
});
|
|
32
|
-
it ('Spaces before and after the csrf value ', () => {
|
|
33
|
-
expect(getCsrfTokenByRegexp('const csrf = " fndfjsjfisdga " ')[1]).to.equal(' fndfjsjfisdga ');
|
|
34
|
-
});
|
|
35
|
-
it ('Two csrf in the same string, returns the first', () => {
|
|
36
|
-
expect(getCsrfTokenByRegexp('const ooooocsrfoooo = "11111";oooocsrf="222222"')[1]).to.equal('11111');
|
|
37
|
-
});
|
|
38
|
-
it ('Extract the csrf from full text', () => {
|
|
39
|
-
const str = `10\\u005B0\\u002D9\\u005D\\u0029\\u0028\\u003F\\u003A\\\\d\\u002B\\u007C\\\\d\\u007B1,3\\u007D\\u0028\\u003F\\u003A,\\\\d\\u007B3\\u007D\\u0029\\u002B\\u0029\\u003F\\u00r
|
|
40
|
-
CSRF_TOKEN = "f0fed68029c30044c8731a6f7c2cef9155eeeea49ac0c0ad360b91bef4e2d92db31df21ae9b5536dec92c898e1ef611f4eaf0e6bf804dcf2085d6eced5ad0adb";
|
|
41
|
-
\n\t\tvar CAN_EMAIL_FILES_AND_REPORTS = 0;\n
|
|
42
|
-
\t\tvar EVENT_TRACKING_DEFINITIONS = `;
|
|
43
|
-
expect(getCsrfTokenByRegexp(str)[1]).to.equal('f0fed68029c30044c8731a6f7c2cef9155eeeea49ac0c0ad360b91bef4e2d92db31df21ae9b5536dec92c898e1ef611f4eaf0e6bf804dcf2085d6eced5ad0adb');
|
|
44
|
-
});
|
|
45
|
-
it ('Extract the csrf from object', () => {
|
|
46
|
-
const obj = {
|
|
47
|
-
'application':{
|
|
48
|
-
'environment':'production',
|
|
49
|
-
'csrfToken':'6030f837f55c2b9418c4fe4f2a6476b84737a8297f9221d1ece63e6b6ead74be1692f5799948ce7c',
|
|
50
|
-
'baseUrl':'https://www.mollie.com/',
|
|
51
|
-
'baseName':'/dashboard/org_14022537/',
|
|
52
|
-
'apiBaseUrl':'https://www.mollie.com/api-internal/',
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
expect(getCsrfTokenByRegexp(JSON.stringify(obj))[1]).to.equal('6030f837f55c2b9418c4fe4f2a6476b84737a8297f9221d1ece63e6b6ead74be1692f5799948ce7c');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const { suite, describe, it } = require('mocha');
|
|
2
|
-
const { expect } = require('chai');
|
|
3
|
-
const { valueUtils } = require('@loadmill/core/dist/parameters');
|
|
4
|
-
|
|
5
|
-
suite('test valueUtils module', () => {
|
|
6
|
-
describe('verify isTruthyParameterValue function', () => {
|
|
7
|
-
describe('falsys return false', () => {
|
|
8
|
-
it('false => false', () => {
|
|
9
|
-
expect(valueUtils.isTruthyParameterValue(false)).equals(false);
|
|
10
|
-
});
|
|
11
|
-
it('0 => false', () => {
|
|
12
|
-
expect(valueUtils.isTruthyParameterValue(0)).equals(false);
|
|
13
|
-
});
|
|
14
|
-
it('-0 => false', () => {
|
|
15
|
-
expect(valueUtils.isTruthyParameterValue(-0)).equals(false);
|
|
16
|
-
});
|
|
17
|
-
it('0n => false', () => {
|
|
18
|
-
expect(valueUtils.isTruthyParameterValue(0n)).equals(false);
|
|
19
|
-
});
|
|
20
|
-
it('null => false', () => {
|
|
21
|
-
expect(valueUtils.isTruthyParameterValue(null)).equals(false);
|
|
22
|
-
});
|
|
23
|
-
it('undefined => false', () => {
|
|
24
|
-
expect(valueUtils.isTruthyParameterValue(undefined)).equals(false);
|
|
25
|
-
});
|
|
26
|
-
it('NaN => false', () => {
|
|
27
|
-
expect(valueUtils.isTruthyParameterValue(NaN)).equals(false);
|
|
28
|
-
});
|
|
29
|
-
it('"false" => false', () => {
|
|
30
|
-
expect(valueUtils.isTruthyParameterValue('false')).equals(false);
|
|
31
|
-
});
|
|
32
|
-
it('"null" => false', () => {
|
|
33
|
-
expect(valueUtils.isTruthyParameterValue('null')).equals(false);
|
|
34
|
-
});
|
|
35
|
-
it('"undefined" => false', () => {
|
|
36
|
-
expect(valueUtils.isTruthyParameterValue('undefined')).equals(false);
|
|
37
|
-
});
|
|
38
|
-
it('"NaN" => false', () => {
|
|
39
|
-
expect(valueUtils.isTruthyParameterValue('NaN')).equals(false);
|
|
40
|
-
});
|
|
41
|
-
it('"" => false', () => {
|
|
42
|
-
expect(valueUtils.isTruthyParameterValue('')).equals(false);
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe('truthys return true', () => {
|
|
47
|
-
it('1 => true', () => {
|
|
48
|
-
expect(valueUtils.isTruthyParameterValue(1)).equals(true);
|
|
49
|
-
});
|
|
50
|
-
it('-1 => true', () => {
|
|
51
|
-
expect(valueUtils.isTruthyParameterValue(-1)).equals(true);
|
|
52
|
-
});
|
|
53
|
-
it('true => true', () => {
|
|
54
|
-
expect(valueUtils.isTruthyParameterValue(true)).equals(true);
|
|
55
|
-
});
|
|
56
|
-
it('"a" => true', () => {
|
|
57
|
-
expect(valueUtils.isTruthyParameterValue('a')).equals(true);
|
|
58
|
-
});
|
|
59
|
-
it('1n => true', () => {
|
|
60
|
-
expect(valueUtils.isTruthyParameterValue(1n)).equals(true);
|
|
61
|
-
});
|
|
62
|
-
it('{} => true', () => {
|
|
63
|
-
expect(valueUtils.isTruthyParameterValue({})).equals(true);
|
|
64
|
-
});
|
|
65
|
-
it('[] => true', () => {
|
|
66
|
-
expect(valueUtils.isTruthyParameterValue([])).equals(true);
|
|
67
|
-
});
|
|
68
|
-
it('Infinity => true', () => {
|
|
69
|
-
expect(valueUtils.isTruthyParameterValue(Infinity)).equals(true);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
const { suite, describe, it } = require('mocha');
|
|
2
|
-
const { expect } = require('chai');
|
|
3
|
-
const { Validator } = require('jsonschema');
|
|
4
|
-
|
|
5
|
-
const { generateJSONSchema } = require('../../dist/schema/json-schema-generator');
|
|
6
|
-
|
|
7
|
-
const v = new Validator();
|
|
8
|
-
|
|
9
|
-
suite('JSON Schema generator', () => {
|
|
10
|
-
describe('Primitive cases', () => {
|
|
11
|
-
it('Just 1 string', () => {
|
|
12
|
-
const string = 'arnon';
|
|
13
|
-
const expected = { type: 'string' };
|
|
14
|
-
const res = generateJSONSchema(string);
|
|
15
|
-
expect(res).eql(expected);
|
|
16
|
-
|
|
17
|
-
const schemaRes = v.validate(string, res);
|
|
18
|
-
expect(schemaRes.errors).eql([]);
|
|
19
|
-
});
|
|
20
|
-
it('Just 1 number', () => {
|
|
21
|
-
const number = 123;
|
|
22
|
-
const expected = { 'type': 'number' };
|
|
23
|
-
const res = generateJSONSchema(number);
|
|
24
|
-
expect(res).eql(expected);
|
|
25
|
-
|
|
26
|
-
const schemaRes = v.validate(number, res);
|
|
27
|
-
expect(schemaRes.errors).eql([]);
|
|
28
|
-
});
|
|
29
|
-
it('Just 1 boolean', () => {
|
|
30
|
-
const boolie = false;
|
|
31
|
-
const expected = { 'type': 'boolean' };
|
|
32
|
-
const res = generateJSONSchema(boolie);
|
|
33
|
-
expect(res).eql(expected);
|
|
34
|
-
|
|
35
|
-
const schemaRes = v.validate(boolie, res);
|
|
36
|
-
expect(schemaRes.errors).eql([]);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
describe('Complex cases', () => {
|
|
40
|
-
it('Empty Array', () => {
|
|
41
|
-
const array = [];
|
|
42
|
-
const expected = {
|
|
43
|
-
'type': 'array',
|
|
44
|
-
'items': {}
|
|
45
|
-
};
|
|
46
|
-
const res = generateJSONSchema(array);
|
|
47
|
-
expect(res).eql(expected);
|
|
48
|
-
|
|
49
|
-
const schemaRes = v.validate(array, res);
|
|
50
|
-
expect(schemaRes.errors).eql([]);
|
|
51
|
-
});
|
|
52
|
-
it('Array of strings', () => {
|
|
53
|
-
const array = ['Arnon','Yochai'];
|
|
54
|
-
const expected = {
|
|
55
|
-
'type': 'array',
|
|
56
|
-
'items': {
|
|
57
|
-
'anyOf':
|
|
58
|
-
[
|
|
59
|
-
{
|
|
60
|
-
'type': 'string'
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
const res = generateJSONSchema(array);
|
|
66
|
-
expect(res).eql(expected);
|
|
67
|
-
|
|
68
|
-
const schemaRes = v.validate(array, res);
|
|
69
|
-
expect(schemaRes.errors).eql([]);
|
|
70
|
-
const schemaResRev = v.validate(array.reverse(), res);
|
|
71
|
-
expect(schemaResRev.errors).eql([]);
|
|
72
|
-
});
|
|
73
|
-
it('Object of primitives', () => {
|
|
74
|
-
const obj = { 'name':'arnon', 'age':48, 'isAntar':true };
|
|
75
|
-
const expected = {
|
|
76
|
-
'type': 'object',
|
|
77
|
-
'properties': {
|
|
78
|
-
'name': {
|
|
79
|
-
'type': 'string'
|
|
80
|
-
},
|
|
81
|
-
'age': {
|
|
82
|
-
'type': 'number'
|
|
83
|
-
},
|
|
84
|
-
'isAntar': {
|
|
85
|
-
'type': 'boolean'
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
const res = generateJSONSchema(obj);
|
|
90
|
-
expect(res).eql(expected);
|
|
91
|
-
|
|
92
|
-
const schemaRes = v.validate(obj, res);
|
|
93
|
-
expect(schemaRes.errors).eql([]);
|
|
94
|
-
});
|
|
95
|
-
it('Array of similar objects', () => {
|
|
96
|
-
const array = [{ 'street': 'Arnon', 'building': 42 }, { 'street': 'Yochai', 'building': 77 }];
|
|
97
|
-
const expected = {
|
|
98
|
-
'type': 'array',
|
|
99
|
-
'items': {
|
|
100
|
-
'anyOf': [
|
|
101
|
-
{
|
|
102
|
-
'type': 'object',
|
|
103
|
-
'properties': {
|
|
104
|
-
'street': {
|
|
105
|
-
'type': 'string'
|
|
106
|
-
},
|
|
107
|
-
'building': {
|
|
108
|
-
'type': 'number'
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
]
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
const res = generateJSONSchema(array);
|
|
116
|
-
expect(res).eql(expected);
|
|
117
|
-
|
|
118
|
-
const schemaRes = v.validate(array, res);
|
|
119
|
-
expect(schemaRes.errors).eql([]);
|
|
120
|
-
const schemaResRev = v.validate(array.reverse(), res);
|
|
121
|
-
expect(schemaResRev.errors).eql([]);
|
|
122
|
-
});
|
|
123
|
-
it('Array of different types of objects', () => {
|
|
124
|
-
const array = [
|
|
125
|
-
{ a: 1 },
|
|
126
|
-
{ a: 2 },
|
|
127
|
-
{ a: 3 },
|
|
128
|
-
{ a: 4 },
|
|
129
|
-
{ b: 5 },
|
|
130
|
-
{ b: 6 },
|
|
131
|
-
{ b: 7 },
|
|
132
|
-
{ b: 8 },
|
|
133
|
-
];
|
|
134
|
-
const expected = {
|
|
135
|
-
'type': 'array',
|
|
136
|
-
'items': {
|
|
137
|
-
'anyOf': [
|
|
138
|
-
{
|
|
139
|
-
'type': 'object',
|
|
140
|
-
'properties': {
|
|
141
|
-
'a': {
|
|
142
|
-
'type': 'number'
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
'type': 'object',
|
|
148
|
-
'properties': {
|
|
149
|
-
'b': {
|
|
150
|
-
'type': 'number'
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
]
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
const res = generateJSONSchema(array);
|
|
158
|
-
expect(res).eql(expected);
|
|
159
|
-
|
|
160
|
-
const schemaRes = v.validate(array, res);
|
|
161
|
-
expect(schemaRes.errors).eql([]);
|
|
162
|
-
const schemaResRev = v.validate(array.reverse(), res);
|
|
163
|
-
expect(schemaResRev.errors).eql([]);
|
|
164
|
-
});
|
|
165
|
-
it('Mixed object', () => {
|
|
166
|
-
const obj = {
|
|
167
|
-
'foo': 123,
|
|
168
|
-
'bar': {
|
|
169
|
-
'x': 1,
|
|
170
|
-
'y': 'one',
|
|
171
|
-
'null': null,
|
|
172
|
-
'yes': true
|
|
173
|
-
},
|
|
174
|
-
'arr': [1,2,[3]],
|
|
175
|
-
};
|
|
176
|
-
const expected = {
|
|
177
|
-
'type': 'object',
|
|
178
|
-
'properties': {
|
|
179
|
-
'foo': {
|
|
180
|
-
'type': 'number'
|
|
181
|
-
},
|
|
182
|
-
'bar': {
|
|
183
|
-
'type': 'object',
|
|
184
|
-
'properties': {
|
|
185
|
-
'x': {
|
|
186
|
-
'type': 'number'
|
|
187
|
-
},
|
|
188
|
-
'y': {
|
|
189
|
-
'type': 'string'
|
|
190
|
-
},
|
|
191
|
-
'null': {},
|
|
192
|
-
'yes': {
|
|
193
|
-
'type': 'boolean'
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
'arr': {
|
|
198
|
-
'type': 'array',
|
|
199
|
-
'items': {
|
|
200
|
-
'anyOf': [
|
|
201
|
-
{
|
|
202
|
-
'type': 'number'
|
|
203
|
-
},
|
|
204
|
-
{
|
|
205
|
-
'type': 'array',
|
|
206
|
-
'items': {
|
|
207
|
-
'anyOf':
|
|
208
|
-
[
|
|
209
|
-
{
|
|
210
|
-
'type': 'number'
|
|
211
|
-
}
|
|
212
|
-
]
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
]
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
};
|
|
220
|
-
const res = generateJSONSchema(obj);
|
|
221
|
-
expect(res).eql(expected);
|
|
222
|
-
|
|
223
|
-
const schemaRes = v.validate(obj, res);
|
|
224
|
-
expect(schemaRes.errors).eql([]);
|
|
225
|
-
});
|
|
226
|
-
});
|
|
227
|
-
});
|