@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,141 +0,0 @@
|
|
|
1
|
-
const { expect } = require('chai');
|
|
2
|
-
const { validate } = require('../../dist/conf');
|
|
3
|
-
const { describe, it } = require('mocha');
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const warningRes = { regex: 'Warning - your regex doesn\'t contain a capturing group' };
|
|
7
|
-
|
|
8
|
-
describe('conf validate', () => {
|
|
9
|
-
describe('validate extract parameter', () => {
|
|
10
|
-
const EXTRACTED_TO = 'extractedTo';
|
|
11
|
-
const tested = validate.extractedValue;
|
|
12
|
-
|
|
13
|
-
it('validate extract parameter returns todo boom', () => {
|
|
14
|
-
expect(tested('yada-yada', EXTRACTED_TO)).equals(undefined);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('validate extract parameter returns todo boom with true boolean', () => {
|
|
18
|
-
expect(tested('true', EXTRACTED_TO)).equals(undefined);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('validate extract parameter returns todo boom with false boolean', () => {
|
|
22
|
-
expect(tested('false', EXTRACTED_TO)).equals(undefined);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('validate extract parameter returns todo boom when reserved word in a phrase', () => {
|
|
26
|
-
expect(tested('yada-yada url', EXTRACTED_TO)).equals(undefined);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('validate extract parameter fails on empty field', () => {
|
|
30
|
-
const res = tested('', EXTRACTED_TO);
|
|
31
|
-
expect(res[EXTRACTED_TO]).equals('Extracted value can\'t be empty');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('validate extract parameter fails on { character', () => {
|
|
35
|
-
const res = tested('yada{yada', EXTRACTED_TO);
|
|
36
|
-
expect(res[EXTRACTED_TO]).equals('Unacceptable character: \'{\'');
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('validate extract parameter fails on reserved word', () => {
|
|
40
|
-
const res = tested('url', EXTRACTED_TO);
|
|
41
|
-
expect(res[EXTRACTED_TO]).equals('Can\'t extract reserved HTTP words - URL, headers etc...');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('validate extract parameter fails on another reserved word - just to be safe', () => {
|
|
45
|
-
const res = tested('jsonPath', EXTRACTED_TO);
|
|
46
|
-
expect(res[EXTRACTED_TO]).equals('Can\'t extract reserved HTTP words - URL, headers etc...');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe('validate parameterDoesntExist', () => {
|
|
52
|
-
const entities = [{ rivi: 'riviVal' }, { shimi: 'shimiVal' }, { simi: 'simiVal' }, { emptyVal: '' }];
|
|
53
|
-
const tested = validate.parameterDoesntExist;
|
|
54
|
-
|
|
55
|
-
it('validate parameterDoesntExist returns error when entity exists', () => {
|
|
56
|
-
const res = tested('rivi', 'parameter', entities, 'name');
|
|
57
|
-
expect(res['parameter']).equals('parameter rivi already exists');
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('validate parameterDoesntExist returns undefined when entity doesnt exist', () => {
|
|
61
|
-
expect(tested('yo', 'parameter', entities)).equals(undefined);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('validate parameterDoesntExist returns undefined when no entity', () => {
|
|
65
|
-
expect(tested(null, 'parameter', entities)).equals(undefined);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('validate parameterDoesntExist returns undefined when empty entity', () => {
|
|
69
|
-
expect(tested({}, 'parameter', entities)).equals(undefined);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('validate parameterDoesntExist returns undefined when empty collection', () => {
|
|
73
|
-
expect(tested('yo', 'parameter', [])).equals(undefined);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('validate parameterDoesntExist returns undefined when null collection', () => {
|
|
77
|
-
expect(tested('yo', 'parameter', null)).equals(undefined);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('validate parameterDoesntExist returns undefined when field is empty', () => {
|
|
81
|
-
const res = tested('', 'parameter', entities);
|
|
82
|
-
expect(res).equals(undefined);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('validate parameterDoesntExist returns undefined when value is empty', () => {
|
|
86
|
-
const res = tested('emptyVal', 'parameter', entities);
|
|
87
|
-
expect(res['parameter']).equals('parameter emptyVal already exists');
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
describe('Validate regex capture', () => {
|
|
92
|
-
it('regexCapture empty string returns warning', () => {
|
|
93
|
-
expect(validate.regexCapture('')).to.eql(warningRes);
|
|
94
|
-
});
|
|
95
|
-
it('regexCapture a returns warning', () => {
|
|
96
|
-
expect(validate.regexCapture('a')).to.eql(warningRes);
|
|
97
|
-
});
|
|
98
|
-
it('regexCapture valid regex without capture returns warning', () => {
|
|
99
|
-
expect(validate.regexCapture('/.*/')).to.eql(warningRes);
|
|
100
|
-
});
|
|
101
|
-
it('regexCapture valid regex with capture returns undefined', () => {
|
|
102
|
-
expect(validate.regexCapture('/(.*)/')).to.eql(undefined);
|
|
103
|
-
});
|
|
104
|
-
it('regexCapture valid regex without slashes with capture returns undefined', () => {
|
|
105
|
-
expect(validate.regexCapture('(.*)')).to.eql(undefined);
|
|
106
|
-
});
|
|
107
|
-
it('regexCapture valid regex with literal capture signs returns warning', () => {
|
|
108
|
-
expect(validate.regexCapture('/\\(.*\\)/')).to.eql(warningRes);
|
|
109
|
-
});
|
|
110
|
-
it('regexCapture valid regex with multiple capture returns undefined', () => {
|
|
111
|
-
expect(validate.regexCapture('/(a(1|2)).*(3)/')).to.eql(undefined);
|
|
112
|
-
});
|
|
113
|
-
it('regexCapture valid regex with multiple capture and quotes returns undefined', () => {
|
|
114
|
-
expect(validate.regexCapture('\'/(a(1|2)).*(3)/\'')).to.eql(undefined);
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
describe('validate url', () => {
|
|
120
|
-
const tested = validate.url;
|
|
121
|
-
it('returns undefined when url is valid', () => {
|
|
122
|
-
const res = tested('https://www.loadmill.com/');
|
|
123
|
-
expect(res).equals(undefined);
|
|
124
|
-
});
|
|
125
|
-
it('returns "Invalid URL" when url is with spaces', () => {
|
|
126
|
-
const res = tested('www.loadmill.c om/');
|
|
127
|
-
expect(res.url).equals('Invalid URL');
|
|
128
|
-
});
|
|
129
|
-
it('returns "Invalid URL" when url has no address', () => {
|
|
130
|
-
const res = tested('http://');
|
|
131
|
-
expect(res.url).equals('Invalid URL');
|
|
132
|
-
});
|
|
133
|
-
it('returns "Invalid URL" when url has a dot in the end', () => {
|
|
134
|
-
const res = tested('https://www.loadmill.com.');
|
|
135
|
-
expect(res.url).equals('Invalid URL');
|
|
136
|
-
});
|
|
137
|
-
it('returns "Missing protocol or host name" when url has no http protocol', () => {
|
|
138
|
-
const res = tested('www.loadmill.com');
|
|
139
|
-
expect(res.url).equals('Missing protocol or host name');
|
|
140
|
-
});
|
|
141
|
-
});
|
package/test/har/is-har.spec.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const { expect } = require('chai');
|
|
2
|
-
const { describe, it } = require('mocha');
|
|
3
|
-
const { isHar } = require('../../dist/har');
|
|
4
|
-
|
|
5
|
-
describe('har-utils isHar', () => {
|
|
6
|
-
it('valid har', () => {
|
|
7
|
-
expect(isHar({ log: { version: '1.2', entries: [] } })).to.equal(true);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('no log', () => {
|
|
11
|
-
expect(isHar({})).to.equal(false);
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
it('no version', () => {
|
|
15
|
-
expect(isHar({ log: { entries: [] } })).to.equal(false);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('wrong version number', () => {
|
|
19
|
-
expect(isHar({ log: { version: '0.5', entries: [] } })).to.equal(false);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('wrong version type', () => {
|
|
23
|
-
expect(isHar({ log: { version: 1, entries: [] } })).to.equal(false);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('no entries', () => {
|
|
27
|
-
expect(isHar({ log: { version: '1.2' } })).to.equal(false);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('wrong entries type', () => {
|
|
31
|
-
expect(isHar({ log: { version: '1.2', entries: 2 } })).to.equal(false);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
import { suite, describe, it } from 'mocha';
|
|
5
|
-
import { expect } from 'chai';
|
|
6
|
-
|
|
7
|
-
import { PostFormData } from '../../src/request/index';
|
|
8
|
-
import { Form, FormEntry, mapToMultipartFormData, multipartFormDataTextToPostFormData } from '../../src/multipart-form-data/form-data-utils';
|
|
9
|
-
const multipartPostDataWithText = JSON.parse(fs.readFileSync(path.join(__dirname, './resources/multipart-form-data-file-text-content.json')));
|
|
10
|
-
|
|
11
|
-
const { text } = multipartPostDataWithText;
|
|
12
|
-
|
|
13
|
-
const params: FormEntry[] = [
|
|
14
|
-
{
|
|
15
|
-
'name': 'the_name_of_the_thing',
|
|
16
|
-
'contentType': 'application/vnd.mspowerpoint-sniffing.x-rar-compressed',
|
|
17
|
-
'fileName': 'some file name.ext',
|
|
18
|
-
'value': 'the_contents_of_the_file'
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
'name': 'entityId',
|
|
22
|
-
'value': '123456789123456789123456789'
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
'name': 'shouldDoStuff',
|
|
26
|
-
'value': 'true'
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
'name': 'content-transfer-encoding',
|
|
30
|
-
'value': 'quoted-printable'
|
|
31
|
-
},
|
|
32
|
-
];
|
|
33
|
-
|
|
34
|
-
suite('form-data-utils - multipart form data', () => {
|
|
35
|
-
describe('Form Class - manages and manipulates multipart form data', () => {
|
|
36
|
-
it('to string', () => {
|
|
37
|
-
const boundary = '------WebKitFormBoundary12345678ASDFGHJ';
|
|
38
|
-
const expectedText = '--------WebKitFormBoundary12345678ASDFGHJ\r\nContent-Disposition: form-data; name="the_name_of_the_thing"; filename="some file name.ext"\r\ncontent-type: application/vnd.mspowerpoint-sniffing.x-rar-compressed\r\n\r\nthe_contents_of_the_file\r\n--------WebKitFormBoundary12345678ASDFGHJ\r\nContent-Disposition: form-data; name="entityId"\r\n\r\n123456789123456789123456789\r\n--------WebKitFormBoundary12345678ASDFGHJ\r\nContent-Disposition: form-data; name="shouldDoStuff"\r\n\r\ntrue\r\n--------WebKitFormBoundary12345678ASDFGHJ\r\nContent-Disposition: form-data; name="content-transfer-encoding"\r\n\r\nquoted-printable\r\n--------WebKitFormBoundary12345678ASDFGHJ--\r\n';
|
|
39
|
-
const form = new Form(params, boundary);
|
|
40
|
-
const result = form.toString();
|
|
41
|
-
expect(result).equals(expectedText);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
describe('mapToMultipartFormData', () => {
|
|
46
|
-
it ('should convert HAR parameters to PostFormData', () => {
|
|
47
|
-
const requestUnderTest = { postData: { params } } as { postData?: { params?, text?, mimeType? }, postFormData?: PostFormData };
|
|
48
|
-
const expectedResult = {
|
|
49
|
-
postFormData: [
|
|
50
|
-
{
|
|
51
|
-
name: 'the_name_of_the_thing',
|
|
52
|
-
value: 'the_contents_of_the_file',
|
|
53
|
-
fileName: 'some file name.ext',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: 'entityId',
|
|
57
|
-
value: '123456789123456789123456789'
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
name: 'shouldDoStuff',
|
|
61
|
-
value: 'true'
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: 'content-transfer-encoding',
|
|
65
|
-
value: 'quoted-printable'
|
|
66
|
-
},
|
|
67
|
-
]
|
|
68
|
-
};
|
|
69
|
-
mapToMultipartFormData(requestUnderTest); // mutate request under test
|
|
70
|
-
expect(requestUnderTest.postFormData).to.have.deep.ordered.members(expectedResult.postFormData);
|
|
71
|
-
});
|
|
72
|
-
it ('should convert HAR multipart/form-data body TEXT to PostFormData', () => {
|
|
73
|
-
const requestUnderTest = { postData: { text } } as { postData?: { params?, text?, mimeType? }, postFormData?: PostFormData };
|
|
74
|
-
const expectedResult = {
|
|
75
|
-
postFormData: [
|
|
76
|
-
{
|
|
77
|
-
name: 'file',
|
|
78
|
-
value: 'ÿØÿà\u0000\u0010JFIF\u0000\u0001\u0001\u0000\u0000\u0001\u0000\u0001\u0000\u0000ÿÛ\u0000\u0000\u0005\u0003\u0004\t\t\b\t\t\t\t\t\t\t\t\t\u0005u001c\u0017\t\b\u001a\t\t\u0006\u0018!\u0018\u001a\u001d\u001d\u001f\u001f\u001f\u0007\u000b"\u0018"\u001e\u0018\u001c\u001e\u001f\u001e\u0001\u0005\u0005\u0005\b\u0007\b\u000e\b\b\r\u0012\r\u000e\r\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012R#B?\u00005Ù',
|
|
79
|
-
fileName: 'silk_sonic.jpeg',
|
|
80
|
-
},
|
|
81
|
-
]
|
|
82
|
-
};
|
|
83
|
-
mapToMultipartFormData(requestUnderTest); // mutate request under test
|
|
84
|
-
expect(requestUnderTest.postFormData).to.have.deep.ordered.members(expectedResult.postFormData);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('multipartFormDataTextToPostFormData', () => {
|
|
89
|
-
it('should return empty array when text is empty', () => {
|
|
90
|
-
const result = multipartFormDataTextToPostFormData('');
|
|
91
|
-
expect(result).to.have.deep.ordered.members([]);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('should return name-value', () => {
|
|
95
|
-
const text = '----10453916712809342873442003634\r\nContent-Disposition: form-data; name="arnon"\r\n\r\npeleg\r\n----10453916712809342873442003634--\r\n';
|
|
96
|
-
const result = multipartFormDataTextToPostFormData(text);
|
|
97
|
-
expect(result).to.have.deep.ordered.members([{ name: 'arnon', value: 'peleg' }]);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('should return 2 name-values', () => {
|
|
101
|
-
const text = '----10453916712\r\nContent-Disposition: form-data; name="arnon"\r\n\r\npeleg\r\n----10453916712\r\nContent-Disposition: form-data; name="rivi"\r\n\r\nshimi\r\n----10453916712--\r\n';
|
|
102
|
-
const result = multipartFormDataTextToPostFormData(text);
|
|
103
|
-
expect(result).to.have.deep.ordered.members([{ name: 'arnon', value: 'peleg' }, { name: 'rivi', value: 'shimi' }]);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('should return name-value-filename', () => {
|
|
107
|
-
const text = '-----------------------------10453916712809342873442003634\r\nContent-Disposition: form-data; name="file"; filename="silk_sonic.jpeg"\r\nContent-Type: image/jpeg\r\n\r\nXCXCXCXCXCXCXCXCXCXCXCXCXCXC\t\r\n\t \n\n\nXXC101010101010101101010101010\r\n-----------------------------10453916712809342873442003634--\r\n';
|
|
108
|
-
const result = multipartFormDataTextToPostFormData(text);
|
|
109
|
-
expect(result).to.have.deep.ordered.members([
|
|
110
|
-
{
|
|
111
|
-
name: 'file',
|
|
112
|
-
value: 'XCXCXCXCXCXCXCXCXCXCXCXCXCXC\t\r\n\t \n\n\nXXC101010101010101101010101010',
|
|
113
|
-
fileName: 'silk_sonic.jpeg'
|
|
114
|
-
}
|
|
115
|
-
]);
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
it('should return also the value of a simple file', () => {
|
|
119
|
-
const text = '------WebKitFormBoundaryntAaM2MokVD4YVOO\r\nContent-Disposition: form-data; name="file"; filename="Cars.csv"\r\nContent-Type: text/csv\r\n\r\nID,First_Name,Last_Name,Car_Make,Car_Model,Car_Color,Car_Model Year,Car_VIN\n1,Lenora,Hegdonne,Lincoln,Town Car,Blue,1994,WAUUL98E68A703943\n2,Jermaine,Bradane,Ford,GT,Pink,2005,1N6AA0EC1FN193806\r\n------WebKitFormBoundaryntAaM2MokVD4YVOO--\r\n';
|
|
120
|
-
const result = multipartFormDataTextToPostFormData(text);
|
|
121
|
-
expect(result).to.have.deep.ordered.members([
|
|
122
|
-
{
|
|
123
|
-
name: 'file',
|
|
124
|
-
value: 'ID,First_Name,Last_Name,Car_Make,Car_Model,Car_Color,Car_Model Year,Car_VIN\n1,Lenora,Hegdonne,Lincoln,Town Car,Blue,1994,WAUUL98E68A703943\n2,Jermaine,Bradane,Ford,GT,Pink,2005,1N6AA0EC1FN193806',
|
|
125
|
-
fileName: 'Cars.csv'
|
|
126
|
-
}
|
|
127
|
-
]);
|
|
128
|
-
});
|
|
129
|
-
it('should detect content-type', () => {
|
|
130
|
-
const text = '----------------------------148649485734387205386089\r\nContent-Disposition: form-data; name="file"; filename="Bell data engineer.docx"\r\ncontent-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document\r\n\r\nUEsDBBQABgAIAAAAIQCTkoLJhQEAACkHAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIo\r\n----------------------------148649485734387205386089--\r\n';
|
|
131
|
-
const result = multipartFormDataTextToPostFormData(text);
|
|
132
|
-
expect(result).to.have.deep.ordered.members([
|
|
133
|
-
{
|
|
134
|
-
name: 'file',
|
|
135
|
-
value: 'PK\u0003\u0004\u0014\u0000\u0006\u0000\b\u0000\u0000\u0000!\u0000É
\u0001\u0000\u0000)\u0007\u0000\u0000\u0013\u0000\b\u0002[Content_Types].xml ¢\u0004\u0002(',
|
|
136
|
-
fileName: 'Bell data engineer.docx',
|
|
137
|
-
contentType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
138
|
-
}
|
|
139
|
-
]);
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
});
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"mimeType": "multipart/form-data; boundary=---------------------------10453916712809342873442003634",
|
|
3
|
-
"params": [],
|
|
4
|
-
"text": "-----------------------------10453916712809342873442003634\r\nContent-Disposition: form-data; name=\"file\"; filename=\"silk_sonic.jpeg\"\r\nContent-Type: image/jpeg\r\n\r\nÿØÿà\u0000\u0010JFIF\u0000\u0001\u0001\u0000\u0000\u0001\u0000\u0001\u0000\u0000ÿÛ\u0000\u0000\u0005\u0003\u0004\t\t\b\t\t\t\t\t\t\t\t\t\u0005u001c\u0017\t\b\u001a\t\t\u0006\u0018!\u0018\u001a\u001d\u001d\u001f\u001f\u001f\u0007\u000b\"\u0018\"\u001e\u0018\u001c\u001e\u001f\u001e\u0001\u0005\u0005\u0005\b\u0007\b\u000e\b\b\r\u0012\r\u000e\r\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012\u0012R#B?\u00005Ù\r\n-----------------------------10453916712809342873442003634--\r\n"
|
|
5
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
const { expect } = require('chai');
|
|
2
|
-
const { describe, it } = require('mocha');
|
|
3
|
-
require('../../dist/parameters');
|
|
4
|
-
const { textualParameterFunctions } = require('../../dist/parameters/parameter-functions/textual-parameter-functions');
|
|
5
|
-
|
|
6
|
-
const __jsonpath = textualParameterFunctions.__jsonpath.operate;
|
|
7
|
-
const __jsonpath_keys = textualParameterFunctions.__jsonpath_keys.operate;
|
|
8
|
-
const __jsonpath_all = textualParameterFunctions.__jsonpath_all.operate;
|
|
9
|
-
const __jsonpath_apply = textualParameterFunctions.__jsonpath_apply.operate;
|
|
10
|
-
|
|
11
|
-
describe('jsonpath functions unit test', () => {
|
|
12
|
-
describe('__jsonpath function:', () => {
|
|
13
|
-
it('Returns the expected value', () => {
|
|
14
|
-
expect(__jsonpath('{"key":"val"}','$.key')).equals('val');
|
|
15
|
-
});
|
|
16
|
-
it('Returns the expected value', () => {
|
|
17
|
-
expect(__jsonpath('{"key":"val","key2":"val2"}','$.key2')).equals('val2');
|
|
18
|
-
});
|
|
19
|
-
it('Returns an empty string when no result is found', () => {
|
|
20
|
-
expect(__jsonpath('{"key":"val"}','$.abc')).equals('');
|
|
21
|
-
});
|
|
22
|
-
it('Returns the default value', () => {
|
|
23
|
-
expect(__jsonpath('{"key":"val"}','$.abc','default')).equals('default');
|
|
24
|
-
});
|
|
25
|
-
it('Extraction the first argument from array', () => {
|
|
26
|
-
expect(__jsonpath('{"phoneNumbers": [{"type": "iPhone","number": "0123-4567-8888"},{"type": "home","number": "0123-4567-8910"}]}','$.phoneNumbers..type')).equals('iPhone');
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('__jsonpath_all function:', () => {
|
|
31
|
-
it('Returns the expected value', () => {
|
|
32
|
-
expect(__jsonpath_all(
|
|
33
|
-
'{"phoneNumbers": [{"type": "iPhone","number": "0123-4567-8888"},{"type": "home","number": "0123-4567-8910"}]}','$.phoneNumbers..type'))
|
|
34
|
-
.equals('["iPhone","home"]');
|
|
35
|
-
});
|
|
36
|
-
it('Returns the expected value', () => {
|
|
37
|
-
expect(__jsonpath_all(
|
|
38
|
-
'{"phoneNumbers": [{"type": "iPhone","number": "0123-4567-8888"},{"type": "home","number": "0123-4567-8910"}]}','$.phoneNumbers.*.number'))
|
|
39
|
-
.equals('["0123-4567-8888","0123-4567-8910"]');
|
|
40
|
-
});
|
|
41
|
-
it('Returns a single value in array', () => {
|
|
42
|
-
expect(__jsonpath_all('{"key":"val"}','$.key')).equals('["val"]');
|
|
43
|
-
});
|
|
44
|
-
it('Returns an empty array when no result is found', () => {
|
|
45
|
-
expect(__jsonpath_all('{"key":"val"}','$.abc')).equals('[]');
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('__jsonpath_keys function:', () => {
|
|
50
|
-
it('Returns the expected value', () => {
|
|
51
|
-
expect(__jsonpath_keys(
|
|
52
|
-
'{"name":"Dana Levi","phoneNumber":"052-4567-888","address":"Tel-Aviv"}','$'))
|
|
53
|
-
.equals('["name","phoneNumber","address"]');
|
|
54
|
-
});
|
|
55
|
-
it('Returns the expected value', () => {
|
|
56
|
-
expect(__jsonpath_keys(
|
|
57
|
-
'{"user": {"name":"Dana Levi","phoneNumber":"052-4567-888","address":"Tel-Aviv"}}','$.user'))
|
|
58
|
-
.equals('["name","phoneNumber","address"]');
|
|
59
|
-
});
|
|
60
|
-
it('Returns an empty array when no result is found', () => {
|
|
61
|
-
expect(__jsonpath_keys(
|
|
62
|
-
'{"name":"Dana Levi","phoneNumber":"052-4567-888","address":"Tel-Aviv"}','$.abc')).equals('[]');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
describe('__jsonpath_keys function:', () => {
|
|
68
|
-
it('Returns the expected value', () => {
|
|
69
|
-
expect(__jsonpath_apply(
|
|
70
|
-
'[{"country":"Japan","currency":"Yen"},{"country":"China","currency":"Yuan"}]','$[0].currency','USD'))
|
|
71
|
-
.equals('[{"country":"Japan","currency":"USD"},{"country":"China","currency":"Yuan"}]' );
|
|
72
|
-
});
|
|
73
|
-
it('Returns the expected value', () => {
|
|
74
|
-
expect(__jsonpath_apply(
|
|
75
|
-
'{"name":"Dana Levi","phoneNumber":"052-4567-888","address":"Tel-Aviv"}','$.name','Anat Cohen'))
|
|
76
|
-
.equals('{"name":"Anat Cohen","phoneNumber":"052-4567-888","address":"Tel-Aviv"}');
|
|
77
|
-
});
|
|
78
|
-
it('Jsonpath not found, returns the value unchanged', () => {
|
|
79
|
-
expect(__jsonpath_apply(
|
|
80
|
-
'{"name":"Dana Levi","phoneNumber":"052-4567-888","address":"Tel-Aviv"}','$.bla','nothing'))
|
|
81
|
-
.equals('{"name":"Dana Levi","phoneNumber":"052-4567-888","address":"Tel-Aviv"}');
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
});
|
|
85
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { suite, describe, it } from 'mocha';
|
|
2
|
-
import { expect } from 'chai';
|
|
3
|
-
|
|
4
|
-
import { getLongestJsonPathToken } from '../../src/parameters/json-path-utils';
|
|
5
|
-
|
|
6
|
-
suite('json-path-utils', () => {
|
|
7
|
-
describe('getLongestJsonPathToken', () => {
|
|
8
|
-
describe('bad inputs (string not representing a valid jsonPath) will throw', () => {
|
|
9
|
-
it('empty string should throw', () => {
|
|
10
|
-
expect(() => getLongestJsonPathToken('')).to.throw();
|
|
11
|
-
});
|
|
12
|
-
it('missing quotes should throw', () => {
|
|
13
|
-
expect(() => getLongestJsonPathToken('$["x]')).to.throw();
|
|
14
|
-
});
|
|
15
|
-
it('$. should throw', () => {
|
|
16
|
-
expect(() => getLongestJsonPathToken('$.')).to.throw();
|
|
17
|
-
});
|
|
18
|
-
it('$[] should throw', () => {
|
|
19
|
-
expect(() => getLongestJsonPathToken('$[]')).to.throw();
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
describe('double quotes style', () => {
|
|
23
|
-
it('$["aaa"]["bb"]["cc"] should return aaa', () => {
|
|
24
|
-
expect(getLongestJsonPathToken('$["aaa"]["bb"]["cc"]')).to.equal('aaa');
|
|
25
|
-
});
|
|
26
|
-
it('$["aa"]["bbb"]["cc"] should return bbb', () => {
|
|
27
|
-
expect(getLongestJsonPathToken('$["aa"]["bbb"]["cc"]')).to.equal('bbb');
|
|
28
|
-
});
|
|
29
|
-
it('$["aa"]["bb"]["ccc"] should return ccc', () => {
|
|
30
|
-
expect(getLongestJsonPathToken('$["aa"]["bb"]["ccc"]')).to.equal('ccc');
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
describe('dot style', () => {
|
|
34
|
-
it('$.aaa.bb.cc should return aaa', () => {
|
|
35
|
-
expect(getLongestJsonPathToken('$.aaa.bb.cc')).to.equal('aaa');
|
|
36
|
-
});
|
|
37
|
-
it('$.aa.bbb.cc should return bbb', () => {
|
|
38
|
-
expect(getLongestJsonPathToken('$.aa.bbb.cc')).to.equal('bbb');
|
|
39
|
-
});
|
|
40
|
-
it('$.aa.bb.ccc should return ccc', () => {
|
|
41
|
-
expect(getLongestJsonPathToken('$.aa.bb.ccc')).to.equal('ccc');
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
describe('mixed styles', () => {
|
|
45
|
-
it('["a"].bb should return bb', () => {
|
|
46
|
-
expect(getLongestJsonPathToken('$["a"].bb')).to.equal('bb');
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const { expect } = require('chai');
|
|
2
|
-
const { describe, it } = require('mocha');
|
|
3
|
-
|
|
4
|
-
require('../../dist/parameters');
|
|
5
|
-
const { canHaveNullParameterValue } = require('../../dist/parameters/parameter-functions/parameter-functions');
|
|
6
|
-
|
|
7
|
-
describe('parameter functions unit test', () => {
|
|
8
|
-
describe('Can Have Null Parameter Value', () => {
|
|
9
|
-
/**
|
|
10
|
-
* !!!WARNING!!!
|
|
11
|
-
*
|
|
12
|
-
* If one of these unit tests is failing and you have changed the function name a change must take place in Orca too.
|
|
13
|
-
*
|
|
14
|
-
* !!!WARNING!!!
|
|
15
|
-
*/
|
|
16
|
-
it('canHaveNullParameterValue for __escape_quotes should return true', () => {
|
|
17
|
-
expect(canHaveNullParameterValue('__escape_quotes')).equals(true);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('canHaveNullParameterValue for __encode_url should return true', () => {
|
|
21
|
-
expect(canHaveNullParameterValue('__encode_url')).equals(true);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('canHaveNullParameterValue for __decode_url should return true', () => {
|
|
25
|
-
expect(canHaveNullParameterValue('__decode_url')).equals(true);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('canHaveNullParameterValue for non relevant function should return false', () => {
|
|
29
|
-
expect(canHaveNullParameterValue('__matches')).equals(false);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it('canHaveNullParameterValue for non existing function should return false', () => {
|
|
33
|
-
expect(canHaveNullParameterValue('RIVI')).equals(false);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('canHaveNullParameterValue for null function should return false', () => {
|
|
37
|
-
expect(canHaveNullParameterValue(null)).equals(false);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('canHaveNullParameterValue for undefined function should return false', () => {
|
|
41
|
-
expect(canHaveNullParameterValue(undefined)).equals(false);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('canHaveNullParameterValue for 1 function should return false', () => {
|
|
45
|
-
expect(canHaveNullParameterValue(1)).equals(false);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
});
|