postman-runtime 7.36.1 → 7.36.2
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/CHANGELOG.yaml +8 -0
- package/README.md +8 -1
- package/dist/index.js +1 -1
- package/lib/runner/extensions/item.command.js +1 -1
- package/lib/runner/extensions/request.command.js +35 -12
- package/lib/runner/extensions/waterfall.command.js +4 -0
- package/lib/runner/util.js +73 -1
- package/package.json +3 -3
|
@@ -165,7 +165,7 @@ module.exports = {
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
if (shouldSkipExecution) {
|
|
168
|
-
this.triggers.item(prereqExecutionError, coords, item);
|
|
168
|
+
this.triggers.item(prereqExecutionError, coords, item, null, { isSkipped: true });
|
|
169
169
|
|
|
170
170
|
return callback && callback.call(this, prereqExecutionError, {
|
|
171
171
|
prerequest: prereqExecutions
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
var _ = require('lodash'),
|
|
2
2
|
sdk = require('postman-collection'),
|
|
3
|
-
|
|
4
3
|
createItemContext = require('../create-item-context'),
|
|
5
4
|
|
|
6
5
|
/**
|
|
@@ -28,28 +27,52 @@ var _ = require('lodash'),
|
|
|
28
27
|
payload.data,
|
|
29
28
|
payload.environment.values,
|
|
30
29
|
payload.collectionVariables.values,
|
|
31
|
-
payload.globals.values
|
|
32
|
-
|
|
30
|
+
payload.globals.values
|
|
31
|
+
// @note vault variables are added later
|
|
33
32
|
],
|
|
33
|
+
|
|
34
|
+
hasVaultSecrets = payload.vaultSecrets.values.count() > 0,
|
|
35
|
+
|
|
36
|
+
// @note URL string is used to resolve nested variables as URL parser doesn't support them well.
|
|
34
37
|
urlString = context.item.request.url.toString(),
|
|
38
|
+
unresolvedUrlString = urlString,
|
|
39
|
+
|
|
40
|
+
vaultVariables,
|
|
35
41
|
item,
|
|
36
42
|
auth;
|
|
37
43
|
|
|
44
|
+
if (hasVaultSecrets) {
|
|
45
|
+
// get the vault variables that match the unresolved URL string
|
|
46
|
+
vaultVariables = payload.vaultSecrets.__getMatchingVariables(urlString);
|
|
47
|
+
|
|
48
|
+
// resolve variables in URL string with initial vault variables
|
|
49
|
+
urlString = sdk.Property.replaceSubstitutions(urlString, [...variableDefinitions, vaultVariables]);
|
|
50
|
+
|
|
51
|
+
if (urlString !== unresolvedUrlString) {
|
|
52
|
+
// get the final list of vault variables that match the resolved URL string
|
|
53
|
+
vaultVariables = payload.vaultSecrets.__getMatchingVariables(urlString);
|
|
54
|
+
|
|
55
|
+
// resolve vault variables in URL string
|
|
56
|
+
// @note other variable scopes are skipped as they are already resolved
|
|
57
|
+
urlString = sdk.Property.replaceSubstitutions(urlString, [vaultVariables]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// add vault variables to the list of variable definitions
|
|
61
|
+
variableDefinitions.push(vaultVariables);
|
|
62
|
+
}
|
|
63
|
+
else if (urlString) {
|
|
64
|
+
urlString = sdk.Property.replaceSubstitutions(urlString, variableDefinitions);
|
|
65
|
+
}
|
|
66
|
+
|
|
38
67
|
// @todo - no need to sync variables when SDK starts supporting resolution from scope directly
|
|
39
68
|
// @todo - avoid resolving the entire item as this unnecessarily resolves URL
|
|
40
69
|
item = context.item = new sdk.Item(context.item.toObjectResolved(null,
|
|
41
70
|
variableDefinitions, { ignoreOwnVariables: true }));
|
|
42
71
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// resolve variables in URL string
|
|
46
|
-
if (urlString) {
|
|
47
|
-
// @note this adds support resolving nested variables as URL parser doesn't support them well.
|
|
48
|
-
urlString = sdk.Property.replaceSubstitutions(urlString, variableDefinitions);
|
|
72
|
+
// re-parse and update the URL from the resolved string
|
|
73
|
+
urlString && (item.request.url = new sdk.Url(urlString));
|
|
49
74
|
|
|
50
|
-
|
|
51
|
-
item.request.url = new sdk.Url(urlString);
|
|
52
|
-
}
|
|
75
|
+
auth = context.auth;
|
|
53
76
|
|
|
54
77
|
// resolve variables in auth
|
|
55
78
|
auth && (context.auth = new sdk.RequestAuth(auth.toObjectResolved(null,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var _ = require('lodash'),
|
|
2
2
|
Cursor = require('../cursor'),
|
|
3
3
|
VariableScope = require('postman-collection').VariableScope,
|
|
4
|
+
{ prepareVaultVariableScope } = require('../util'),
|
|
4
5
|
|
|
5
6
|
prepareLookupHash,
|
|
6
7
|
extractSNR,
|
|
@@ -81,6 +82,9 @@ module.exports = {
|
|
|
81
82
|
state.collectionVariables : new VariableScope(state.collectionVariables);
|
|
82
83
|
state._variables = new VariableScope();
|
|
83
84
|
|
|
85
|
+
// prepare the vault variable scope
|
|
86
|
+
prepareVaultVariableScope(state.vaultSecrets);
|
|
87
|
+
|
|
84
88
|
// ensure that the items and iteration data set is in place
|
|
85
89
|
!_.isArray(state.items) && (state.items = []);
|
|
86
90
|
!_.isArray(state.data) && (state.data = []);
|
package/lib/runner/util.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
var
|
|
1
|
+
var { Url, UrlMatchPatternList, VariableList } = require('postman-collection'),
|
|
2
|
+
|
|
3
|
+
/**
|
|
2
4
|
* @const
|
|
3
5
|
* @type {string}
|
|
4
6
|
*/
|
|
@@ -162,5 +164,75 @@ module.exports = {
|
|
|
162
164
|
// stream reading utility function that does the heavy lifting of
|
|
163
165
|
// calling there resolver to return the stream
|
|
164
166
|
return createReadStream(resolver, fileSrc, callback);
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Mutates the given variable scope to be a vault variable scope by
|
|
171
|
+
* converting the domains to UrlMatchPattern and adding a helper function
|
|
172
|
+
* to get the matching variables for a given URL string.
|
|
173
|
+
*
|
|
174
|
+
* @note vault variables have a meta property called `domains` which is an
|
|
175
|
+
* array of URL match pattern strings.
|
|
176
|
+
*
|
|
177
|
+
* @private
|
|
178
|
+
* @param {PostmanVariableScope} scope - Postman variable scope instance
|
|
179
|
+
*/
|
|
180
|
+
prepareVaultVariableScope (scope) {
|
|
181
|
+
// bail out if the given scope is already a vault variable scope
|
|
182
|
+
if (scope.__vaultVariableScope) {
|
|
183
|
+
return scope;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// traverse all the variables and convert the domains to UrlMatchPattern
|
|
187
|
+
scope.values.each((variable) => {
|
|
188
|
+
const domains = variable && variable._ && variable._.domains;
|
|
189
|
+
|
|
190
|
+
if (!(Array.isArray(domains) && domains.length)) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// mark the scope as having domain patterns
|
|
195
|
+
scope.__hasDomainPatterns = true;
|
|
196
|
+
|
|
197
|
+
// convert the domains to UrlMatchPattern
|
|
198
|
+
variable._.domainPatterns = new UrlMatchPatternList(null, domains.map((domain) => {
|
|
199
|
+
const url = new Url(domain);
|
|
200
|
+
|
|
201
|
+
// @note URL path is ignored
|
|
202
|
+
return `${url.protocol || 'https'}://${url.getRemote()}/*`;
|
|
203
|
+
}));
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Returns a list of variables that match the given URL string against
|
|
208
|
+
* the domain patterns.
|
|
209
|
+
*
|
|
210
|
+
* @private
|
|
211
|
+
* @param {String} urlString - URL string to match against
|
|
212
|
+
* @returns {PostmanVariableList}
|
|
213
|
+
*/
|
|
214
|
+
scope.__getMatchingVariables = function (urlString) {
|
|
215
|
+
// return all the variables if there are no domain patterns
|
|
216
|
+
if (!scope.__hasDomainPatterns) {
|
|
217
|
+
return scope.values;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const variables = scope.values.filter((variable) => {
|
|
221
|
+
const domainPatterns = variable && variable._ && variable._.domainPatterns;
|
|
222
|
+
|
|
223
|
+
if (!domainPatterns) {
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return domainPatterns.test(urlString);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
return new VariableList(null, variables.map((variable) => {
|
|
231
|
+
return variable.toJSON(); // clone the variable
|
|
232
|
+
}));
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// mark the scope as a vault variable scope
|
|
236
|
+
scope.__vaultVariableScope = true;
|
|
165
237
|
}
|
|
166
238
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postman-runtime",
|
|
3
|
-
"version": "7.36.
|
|
3
|
+
"version": "7.36.2",
|
|
4
4
|
"description": "Underlying library of executing Postman Collections",
|
|
5
5
|
"author": "Postman Inc.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -86,14 +86,14 @@
|
|
|
86
86
|
"mocha": "^9.1.3",
|
|
87
87
|
"nyc": "^15.1.0",
|
|
88
88
|
"parse-gitignore": "^1.0.1",
|
|
89
|
-
"passport": "^0.
|
|
89
|
+
"passport": "^0.7.0",
|
|
90
90
|
"passport-http": "^0.3.0",
|
|
91
91
|
"recursive-readdir": "^2.2.3",
|
|
92
92
|
"server-destroy": "^1.0.1",
|
|
93
93
|
"shelljs": "^0.8.5",
|
|
94
94
|
"sinon": "^12.0.1",
|
|
95
95
|
"teleport-javascript": "^1.0.0",
|
|
96
|
-
"terser": "^5.
|
|
96
|
+
"terser": "^5.27.0",
|
|
97
97
|
"tmp": "^0.2.1",
|
|
98
98
|
"webpack": "^5.89.0",
|
|
99
99
|
"yankee": "^1.0.8"
|