node-tdd 3.4.0 → 3.4.3
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.
|
@@ -12,6 +12,11 @@ export default (opts) => {
|
|
|
12
12
|
}), 'Invalid Options Provided');
|
|
13
13
|
let original = null;
|
|
14
14
|
|
|
15
|
+
const byteToHex = [];
|
|
16
|
+
for (let i = 0; i < 256; i += 1) {
|
|
17
|
+
byteToHex[i] = (i + 0x100).toString(16).slice(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
return {
|
|
16
21
|
inject: () => {
|
|
17
22
|
assert(original === null);
|
|
@@ -19,7 +24,8 @@ export default (opts) => {
|
|
|
19
24
|
original = {
|
|
20
25
|
crypto: {
|
|
21
26
|
randomBytes: crypto.randomBytes,
|
|
22
|
-
randomFillSync: crypto.randomFillSync
|
|
27
|
+
randomFillSync: crypto.randomFillSync,
|
|
28
|
+
randomUUID: crypto.randomUUID
|
|
23
29
|
},
|
|
24
30
|
Math: {
|
|
25
31
|
random: Math.random
|
|
@@ -39,7 +45,7 @@ export default (opts) => {
|
|
|
39
45
|
let result = crypto
|
|
40
46
|
.createHash('sha256')
|
|
41
47
|
.update(opts.seed)
|
|
42
|
-
.update(key)
|
|
48
|
+
.update(opts.reseed === true ? 'null' : key)
|
|
43
49
|
.update(String(executionCounts[key]))
|
|
44
50
|
.digest();
|
|
45
51
|
while (result.length < size) {
|
|
@@ -57,6 +63,49 @@ export default (opts) => {
|
|
|
57
63
|
});
|
|
58
64
|
return buffer;
|
|
59
65
|
};
|
|
66
|
+
crypto.randomUUID = () => {
|
|
67
|
+
const rnds = crypto.randomBytes(16);
|
|
68
|
+
|
|
69
|
+
// Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
70
|
+
// eslint-disable-next-line no-bitwise
|
|
71
|
+
rnds[6] = (rnds[6] & 0x0f) | 0x40;
|
|
72
|
+
// eslint-disable-next-line no-bitwise
|
|
73
|
+
rnds[8] = (rnds[8] & 0x3f) | 0x80;
|
|
74
|
+
|
|
75
|
+
return `${
|
|
76
|
+
byteToHex[rnds[0]]
|
|
77
|
+
}${
|
|
78
|
+
byteToHex[rnds[1]]
|
|
79
|
+
}${
|
|
80
|
+
byteToHex[rnds[2]]
|
|
81
|
+
}${
|
|
82
|
+
byteToHex[rnds[3]]
|
|
83
|
+
}-${
|
|
84
|
+
byteToHex[rnds[4]]
|
|
85
|
+
}${
|
|
86
|
+
byteToHex[rnds[5]]
|
|
87
|
+
}-${
|
|
88
|
+
byteToHex[rnds[6]]
|
|
89
|
+
}${
|
|
90
|
+
byteToHex[rnds[7]]
|
|
91
|
+
}-${
|
|
92
|
+
byteToHex[rnds[8]]
|
|
93
|
+
}${
|
|
94
|
+
byteToHex[rnds[9]]
|
|
95
|
+
}-${
|
|
96
|
+
byteToHex[rnds[10]]
|
|
97
|
+
}${
|
|
98
|
+
byteToHex[rnds[11]]
|
|
99
|
+
}${
|
|
100
|
+
byteToHex[rnds[12]]
|
|
101
|
+
}${
|
|
102
|
+
byteToHex[rnds[13]]
|
|
103
|
+
}${
|
|
104
|
+
byteToHex[rnds[14]]
|
|
105
|
+
}${
|
|
106
|
+
byteToHex[rnds[15]]
|
|
107
|
+
}`;
|
|
108
|
+
};
|
|
60
109
|
Math.random = () => crypto.randomBytes(4).readUInt32LE() / 0xffffffff;
|
|
61
110
|
},
|
|
62
111
|
release: () => {
|
|
@@ -2,7 +2,6 @@ import crypto from 'crypto';
|
|
|
2
2
|
import qs from 'querystring';
|
|
3
3
|
import get from 'lodash.get';
|
|
4
4
|
|
|
5
|
-
import { v4 as uuid4 } from 'uuid';
|
|
6
5
|
import xml2js from 'xml2js';
|
|
7
6
|
|
|
8
7
|
const parseRequestBody = (body) => Object.values(Object
|
|
@@ -47,7 +46,7 @@ export default (requestBody, responseBody, scope) => {
|
|
|
47
46
|
'SendMessageBatchResultEntry',
|
|
48
47
|
idx,
|
|
49
48
|
'MessageId'
|
|
50
|
-
],
|
|
49
|
+
], crypto.randomUUID())
|
|
51
50
|
}</MessageId>`,
|
|
52
51
|
`<MD5OfMessageBody>${
|
|
53
52
|
crypto.createHash('md5').update(MessageBody).digest('hex')
|
|
@@ -68,7 +67,7 @@ export default (requestBody, responseBody, scope) => {
|
|
|
68
67
|
0,
|
|
69
68
|
'RequestId',
|
|
70
69
|
0
|
|
71
|
-
],
|
|
70
|
+
], crypto.randomUUID())
|
|
72
71
|
}</RequestId>`,
|
|
73
72
|
'</ResponseMetadata>',
|
|
74
73
|
'</SendMessageBatchResponse>'
|
|
@@ -4,6 +4,7 @@ import path from 'path';
|
|
|
4
4
|
import fs from 'smart-fs';
|
|
5
5
|
import Joi from 'joi-strict';
|
|
6
6
|
import nock from 'nock';
|
|
7
|
+
import get from 'lodash.get';
|
|
7
8
|
import cloneDeep from 'lodash.clonedeep';
|
|
8
9
|
import compareUrls from 'compare-urls';
|
|
9
10
|
import nockCommon from 'nock/lib/common.js';
|
|
@@ -120,8 +121,11 @@ export default (opts) => {
|
|
|
120
121
|
}));
|
|
121
122
|
});
|
|
122
123
|
} else if (anyFlagPresent(['stub'])) {
|
|
124
|
+
const host = options.host || options.hostname;
|
|
125
|
+
const port = get(options, 'port', { http: 80, https: 443 }[protocol]);
|
|
126
|
+
const scope = `${protocol}://${host}:${port}`;
|
|
123
127
|
expectedCassette.push({
|
|
124
|
-
scope
|
|
128
|
+
scope,
|
|
125
129
|
method: options.method,
|
|
126
130
|
path: options.path,
|
|
127
131
|
body: tryParseJson(body),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-tdd",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.4.
|
|
4
|
+
"version": "3.4.3",
|
|
5
5
|
"description": "Drop in extension for mocha to abstract commonly used test setups",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -87,7 +87,6 @@
|
|
|
87
87
|
"smart-fs": "3.0.1",
|
|
88
88
|
"timekeeper": "2.2.0",
|
|
89
89
|
"tmp": "0.2.1",
|
|
90
|
-
"uuid": "8.3.0",
|
|
91
90
|
"xml2js": "0.4.23"
|
|
92
91
|
}
|
|
93
92
|
}
|