Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/runner/extensions/event.command.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ module.exports = {

isNestedRequest = this.state.nestedRequest !== undefined,

rootItemId = isNestedRequest ? this.state.nestedRequest.rootItemId : item.id,
rootItem = isNestedRequest ? this.state.nestedRequest.rootItem : item,

// create copy of cursor so we don't leak script ids outside `event.command`
// and across scripts
Expand Down Expand Up @@ -420,7 +420,7 @@ module.exports = {
try {
// eslint-disable-next-line require-atomic-updates
hasVaultAccess = Boolean(this.state.nestedRequest?.hasVaultAccess ||
await vaultSecrets?._?.allowScriptAccess(rootItemId));
await vaultSecrets?._?.allowScriptAccess(rootItem.id));
}
catch (_) {
// eslint-disable-next-line require-atomic-updates
Expand Down
5 changes: 3 additions & 2 deletions lib/runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ _.assign(Runner.prototype, {
* @param {Number} [options.nestedRequest.rootCursor] - The cursor of the root request that spun up this
* nested request runner. This is recursively passed down to keep track of which execution started the chain
* and modify cursors for all nested req events for reporters built on top of postman-runtime.
* @param {Number} [options.nestedRequest.rootItemId] - The id of the root item that spawned this nested request.
* @param {Number} [options.nestedRequest.rootItem] - The root item that spawned this nested request.
* Used by vault to get consent for root request and determine whether vault access check was performed even once
* throughout the chain.
* throughout the chain. And by request resolver bridge to receive any stored metadata like name/location of
* the request being resolved
* @param {Number} [options.nestedRequest.hasVaultAccess] - Mutated and set by any nested or parent request
* to indicate whether vault access check has been performed.
* @param {Number} [options.nestedRequest.invocationCount] - The number of requests currently accummulated
Expand Down
19 changes: 17 additions & 2 deletions lib/runner/nested-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function runNestedRequest ({ executionId, isExecutionSkipped, vaultSecrets, item
self.state.nestedRequest = _.defaults(self.state.nestedRequest || {}, {
isNestedRequest: true,
rootCursor: cursor,
rootItemId: item.id,
rootItem: item,
invocationCount: 0
});

Expand All @@ -39,8 +39,23 @@ function runNestedRequest ({ executionId, isExecutionSkipped, vaultSecrets, item
' calls have been reached for this request.'));
}

let rootRequestEventsList = self.state.nestedRequest.rootItem.events?.all?.() || [],
requestMetadataFromItem = null,
additionalInfo = { rootRequestId: self.state.nestedRequest.rootItem.id };

for (const event of rootRequestEventsList) {
if (event.script && event.script.requests && event.script.requests[requestToRunId]) {
requestMetadataFromItem = event.script.requests[requestToRunId];
break;
}
}

if (requestMetadataFromItem) {
additionalInfo.requestMetadataFromItem = requestMetadataFromItem;
}

// Should fetch the request from the consumer of postman-runtime & resolve scripts and variables
requestResolver(requestToRunId, function (err, collection) {
requestResolver(requestToRunId, additionalInfo, function (err, collection) {
if (err) {
return dispatchErrorToListener(err);
}
Expand Down
Loading