Skip to content

Commit

Permalink
Fix domain regex to match doimains with or without port
Browse files Browse the repository at this point in the history
  • Loading branch information
saksham-postman committed Oct 20, 2024
1 parent f06a951 commit 903d1fe
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/runner/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ module.exports = {
const url = new Url(domain);

// @note URL path is ignored
return `${url.protocol || 'https'}://${url.getRemote()}/*`;
return `${url.protocol || 'https'}://${url.getRemote()}:*/*`;
}));
});

Expand Down
81 changes: 81 additions & 0 deletions test/integration/sanity/vaultSecrets.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,87 @@ describe('vaultSecrets', function () {
});
});

describe('should resolve secrets when port is part of url', function () {
var testrun;

before(function (done) {
this.run({
vaultSecrets: {
id: 'vault',
prefix: 'vault:',
_allowScriptAccess: true,
values: [
{
key: 'vault:var1',
value: 'basic-auth',
_domains: ['https://postman-echo.com']
},
{
key: 'vault:var2',
value: 'postman',
_domains: ['https://postman-echo.com']
},
{
key: 'vault:var3',
value: 'password'
}
]
},
collection: {
item: [{
event: [
{
listen: 'prerequest',
script: {
exec: 'pm.vault.set(\'var4\', \'http://postman-echo.com\')'
}
}
],
request: {
url: 'https://postman-echo.com:80/{{vault:var1}}',
method: 'GET',
auth: {
type: 'basic',
basic: [
{ key: 'username', value: '{{vault:var2}}' },
{ key: 'password', value: '{{vault:var3}}' }
]
}
}
}]
}
}, function (err, results) {
testrun = results;
done(err);
});
});

it('should have completed the run', function () {
expect(testrun).to.be.ok;
expect(testrun.done.getCall(0).args[0]).to.be.null;
expect(testrun).to.nested.include({
'done.calledOnce': true,
'start.calledOnce': true
});
});

it('should handle protocol for a resolved domain', function () {
var url = testrun.request.getCall(0).args[3].url.toString();

expect(url).to.equal('https://postman-echo.com:80/basic-auth');
});

it('should resolve vault secrets in auth', function () {
var request = testrun.response.getCall(0).args[3],
auth = request.auth.parameters().toObject();

expect(auth).to.deep.include({
username: 'postman',
password: 'password'
});
});
});

describe('scripts', function () {
describe('should be able to get vault secrets using pm.vault.get', function () {
var testrun;
Expand Down

0 comments on commit 903d1fe

Please sign in to comment.