postman-runtime 7.26.5-beta.1 → 7.26.5
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/lib/authorizer/oauth2.js
CHANGED
|
@@ -6,7 +6,7 @@ var _ = require('lodash'),
|
|
|
6
6
|
MAC = 'mac',
|
|
7
7
|
AUTHORIZATION = 'Authorization',
|
|
8
8
|
ACCESS_TOKEN = 'access_token',
|
|
9
|
-
AUTHORIZATION_PREFIX = 'Bearer
|
|
9
|
+
AUTHORIZATION_PREFIX = 'Bearer',
|
|
10
10
|
OAUTH2_PARAMETERS = [
|
|
11
11
|
'accessToken',
|
|
12
12
|
'addTokenTo',
|
|
@@ -92,7 +92,10 @@ module.exports = {
|
|
|
92
92
|
params.addTokenTo = params.addTokenTo || HEADER; // Add token to header by default
|
|
93
93
|
params.tokenType = params.tokenType || BEARER; // Use `Bearer` token type by default
|
|
94
94
|
params.headerPrefix = _.isNil(params.headerPrefix) ?
|
|
95
|
-
AUTHORIZATION_PREFIX : String(params.headerPrefix);
|
|
95
|
+
AUTHORIZATION_PREFIX : _.trim(String(params.headerPrefix));
|
|
96
|
+
|
|
97
|
+
// add a space after prefix only if there is any prefix
|
|
98
|
+
params.headerPrefix && (params.headerPrefix += ' ');
|
|
96
99
|
|
|
97
100
|
// Some servers send 'Bearer' while others send 'bearer'
|
|
98
101
|
tokenType = _.toLower(params.tokenType);
|
|
@@ -495,7 +495,7 @@ module.exports = {
|
|
|
495
495
|
// Refer: https://github.com/postmanlabs/postman-sandbox/pull/512
|
|
496
496
|
// Adding back here to avoid breaking change in `script` callback.
|
|
497
497
|
// @todo revisit script callback args in runtime v8.
|
|
498
|
-
payload.context && payload.context.response &&
|
|
498
|
+
result && payload.context && payload.context.response &&
|
|
499
499
|
(result.response = new sdk.Response(payload.context.response));
|
|
500
500
|
|
|
501
501
|
// persist the pm.variables for the next script
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postman-runtime",
|
|
3
|
-
"version": "7.26.5
|
|
3
|
+
"version": "7.26.5",
|
|
4
4
|
"description": "Underlying library of executing Postman Collections (used by Newman)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"directories": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"async": "2.6.3",
|
|
36
36
|
"aws4": "1.10.1",
|
|
37
|
-
"eventemitter3": "4.0.
|
|
37
|
+
"eventemitter3": "4.0.7",
|
|
38
38
|
"handlebars": "4.7.6",
|
|
39
39
|
"http-reasons": "0.1.0",
|
|
40
40
|
"httpntlm": "1.7.6",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"lodash": "4.17.20",
|
|
44
44
|
"node-oauth1": "1.3.0",
|
|
45
45
|
"performance-now": "2.1.0",
|
|
46
|
-
"postman-collection": "3.6.
|
|
46
|
+
"postman-collection": "3.6.6",
|
|
47
47
|
"postman-request": "2.88.1-postman.24",
|
|
48
|
-
"postman-sandbox": "3.5.9
|
|
48
|
+
"postman-sandbox": "3.5.9",
|
|
49
49
|
"postman-url-encoder": "2.1.3",
|
|
50
50
|
"resolve-from": "5.0.0",
|
|
51
51
|
"serialised-error": "1.1.3",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"shelljs": "0.8.4",
|
|
86
86
|
"sinon": "8.1.1",
|
|
87
87
|
"teleport-javascript": "1.0.0",
|
|
88
|
-
"terser": "5.2.
|
|
88
|
+
"terser": "5.2.1",
|
|
89
89
|
"tmp": "0.2.1",
|
|
90
90
|
"yankee": "1.0.8"
|
|
91
91
|
},
|
|
@@ -1632,6 +1632,56 @@ describe('Auth Handler:', function () {
|
|
|
1632
1632
|
});
|
|
1633
1633
|
});
|
|
1634
1634
|
|
|
1635
|
+
it('should separate custom header prefix and token with a space', function () {
|
|
1636
|
+
var clonedRequestObj,
|
|
1637
|
+
request,
|
|
1638
|
+
auth,
|
|
1639
|
+
authInterface,
|
|
1640
|
+
handler;
|
|
1641
|
+
|
|
1642
|
+
clonedRequestObj = _.cloneDeep(requestObj);
|
|
1643
|
+
clonedRequestObj.auth.oauth2.headerPrefix = 'Postman';
|
|
1644
|
+
|
|
1645
|
+
request = new Request(clonedRequestObj);
|
|
1646
|
+
auth = request.auth;
|
|
1647
|
+
authInterface = createAuthInterface(auth);
|
|
1648
|
+
handler = AuthLoader.getHandler(auth.type);
|
|
1649
|
+
|
|
1650
|
+
handler.sign(authInterface, request, _.noop);
|
|
1651
|
+
|
|
1652
|
+
expect(request.headers.all()).to.be.an('array').that.has.lengthOf(1);
|
|
1653
|
+
expect(request.headers.toJSON()[0]).to.eql({
|
|
1654
|
+
key: 'Authorization',
|
|
1655
|
+
value: 'Postman ' + requestObj.auth.oauth2.accessToken,
|
|
1656
|
+
system: true
|
|
1657
|
+
});
|
|
1658
|
+
});
|
|
1659
|
+
|
|
1660
|
+
it('should trim extra spaces in custom header prefix', function () {
|
|
1661
|
+
var clonedRequestObj,
|
|
1662
|
+
request,
|
|
1663
|
+
auth,
|
|
1664
|
+
authInterface,
|
|
1665
|
+
handler;
|
|
1666
|
+
|
|
1667
|
+
clonedRequestObj = _.cloneDeep(requestObj);
|
|
1668
|
+
clonedRequestObj.auth.oauth2.headerPrefix = ' Postman ';
|
|
1669
|
+
|
|
1670
|
+
request = new Request(clonedRequestObj);
|
|
1671
|
+
auth = request.auth;
|
|
1672
|
+
authInterface = createAuthInterface(auth);
|
|
1673
|
+
handler = AuthLoader.getHandler(auth.type);
|
|
1674
|
+
|
|
1675
|
+
handler.sign(authInterface, request, _.noop);
|
|
1676
|
+
|
|
1677
|
+
expect(request.headers.all()).to.be.an('array').that.has.lengthOf(1);
|
|
1678
|
+
expect(request.headers.toJSON()[0]).to.eql({
|
|
1679
|
+
key: 'Authorization',
|
|
1680
|
+
value: 'Postman ' + requestObj.auth.oauth2.accessToken,
|
|
1681
|
+
system: true
|
|
1682
|
+
});
|
|
1683
|
+
});
|
|
1684
|
+
|
|
1635
1685
|
it('should add empty header prefix when headerPrefix = ""', function () {
|
|
1636
1686
|
var clonedRequestObj,
|
|
1637
1687
|
request,
|