Skip to content

Commit

Permalink
Merge branch 'release/6.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
codenirvana committed Aug 16, 2024
2 parents 3ea57fa + 6182469 commit f406493
Show file tree
Hide file tree
Showing 16 changed files with 399 additions and 314 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ jobs:
- name: Run unit tests
run: |
npm run test-unit
bash <(curl -s https://codecov.io/bash) -c -Z -f .coverage/coverage-final.json -F unit
bash <(curl -s https://codecov.io/bash) -c -Z -f .coverage/coverage-final.json -F unit -t ${{ secrets.CODECOV_TOKEN }}
- name: Run integration tests
run: |
npm run test-integration
bash <(curl -s https://codecov.io/bash) -c -Z -f .coverage/coverage-final.json -F integration
bash <(curl -s https://codecov.io/bash) -c -Z -f .coverage/coverage-final.json -F integration -t ${{ secrets.CODECOV_TOKEN }}
- name: Run CLI tests
run: |
npm run test-cli
bash <(curl -s https://codecov.io/bash) -c -Z -f .coverage/coverage-final.json -F cli
bash <(curl -s https://codecov.io/bash) -c -Z -f .coverage/coverage-final.json -F cli -t ${{ secrets.CODECOV_TOKEN }}
- name: Run library tests
run: |
npm run test-library
bash <(curl -s https://codecov.io/bash) -c -Z -f .coverage/coverage-final.json -F library
bash <(curl -s https://codecov.io/bash) -c -Z -f .coverage/coverage-final.json -F library -t ${{ secrets.CODECOV_TOKEN }}
12 changes: 12 additions & 0 deletions CHANGELOG.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
6.2.0:
date: 2024-08-16
new features:
- GH-3263 Added support for HTTP/2
fixed bugs:
- GH-3231 Fixed a bug where JUnit reporter sets the wrong classname
chores:
- >-
GH-3258 Converted the deprecated `apikey` parameter in Postman API urls to
`x-api-key` header
- Updated dependencies

6.1.3:
date: 2024-06-10
chores:
Expand Down
12 changes: 8 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,27 @@ coverage:

# coverage status for unit tests
unit:
flags: unit
target: 75
flags:
- unit

# coverage status for integration tests
integration:
flags: integration
target: 50
flags:
- integration

# coverage status for cli tests
cli:
flags: cli
target: 80
flags:
- cli

# coverage status for library tests
library:
flags: library
target: 65
flags:
- library

parsers:
javascript:
Expand Down
19 changes: 15 additions & 4 deletions lib/reporters/junit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,18 @@ var _ = require('lodash'),
xml = require('xmlbuilder'),

util = require('../../util'),
JunitReporter;
JunitReporter,

/**
* Normalizes the name of a test suite to a valid class name.
*
* @private
* @param {String} name - The name of the test suite.
* @returns {String} - The class name for the test suite.
*/
getClassName = (name) => {
return _.upperFirst(_.camelCase(name).replace(/\W/g, ''));
};

/**
* A function that creates raw XML to be written to Newman JUnit reports.
Expand All @@ -27,7 +38,7 @@ JunitReporter = function (newman, reporterOptions) {
return;
}

classname = _.upperFirst(_.camelCase(collection.name).replace(/\W/g, ''));
classname = getClassName(collection.name);

root = xml.create('testsuites', { version: '1.0', encoding: 'UTF-8' });
root.att('name', collection.name);
Expand Down Expand Up @@ -126,8 +137,8 @@ JunitReporter = function (newman, reporterOptions) {
testcase.att('time', executionTime.toFixed(3));

// Set the same classname for all the tests
testcase.att('classname', _.get(testcase.up(), 'attributes.name.value',
classname));
testcase.att('classname',
getClassName(_.get(testcase.up(), 'attribs.name.value')) || classname);

if (failures && failures.length) {
failure = testcase.ele('failure');
Expand Down
1 change: 1 addition & 0 deletions lib/run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ module.exports = function (options, callback) {
requester: {
useWhatWGUrlParser: true,
cookieJar: cookieJar,
protocolVersion: _.has(options, 'protocolVersion') ? options.protocolVersion : 'auto',
followRedirects: _.has(options, 'ignoreRedirects') ? !options.ignoreRedirects : undefined,
strictSSL: _.has(options, 'insecure') ? !options.insecure : undefined,
timings: Boolean(options.verbose),
Expand Down
48 changes: 24 additions & 24 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var fs = require('fs'),
{ URL } = require('url'),
{ Url } = require('postman-collection'),

_ = require('lodash'),
chardet = require('chardet'),
Expand Down Expand Up @@ -33,9 +33,12 @@ var fs = require('fs'),
'ISO-8859-1': 'latin1'
},

POSTMAN_API_HOST = 'api.getpostman.com',
POSTMAN_API_HOSTS = {
'api.postman.com': true,
'api.getpostman.com': true
},

POSTMAN_API_URL = 'https://' + POSTMAN_API_HOST,
POSTMAN_API_URL = 'https://api.postman.com',

/**
* Map of resource type and its equivalent API pathname.
Expand Down Expand Up @@ -152,8 +155,10 @@ util = {
fetchJson: function (type, location, options, callback) {
!callback && _.isFunction(options) && (callback = options, options = {});

var postmanApiKey = _.get(options, 'postmanApiKey'),
headers = { 'User-Agent': USER_AGENT_VALUE };
const postmanApiKey = _.get(options, 'postmanApiKey'),
headers = { 'User-Agent': USER_AGENT_VALUE },
urlObj = new Url(location),
isPostmanHost = urlObj && POSTMAN_API_HOSTS[urlObj.getHost().toLowerCase()];

// build API URL if `location` is a valid UID and api key is provided.
// Fetch from file in case a file with valid UID name is present.
Expand All @@ -162,18 +167,20 @@ util = {
headers[API_KEY_HEADER] = postmanApiKey;
}

if (isPostmanHost) {
const apikey = urlObj.query.get('apikey') || postmanApiKey;

apikey && (headers[API_KEY_HEADER] = apikey);

urlObj.query.remove('apikey');
location = urlObj.toString();
}

return (/^https?:\/\/.*/).test(location) ?
// Load from URL
request.get({
url: location,
json: true,
headers: headers,
// Temporary fix to fetch the collection from https URL on Node v12
// @todo find the root cause in postman-request
// Refer: https://github.com/postmanlabs/newman/issues/1991
agentOptions: {
keepAlive: true
}
headers: headers
}, (err, response, body) => {
if (err) {
return callback(_.set(err, 'help', `unable to fetch data from url "${location}"`));
Expand All @@ -186,18 +193,11 @@ util = {
return callback(_.set(e, 'help', `the url "${location}" did not provide valid JSON data`));
}

var error,
urlObj,
resource = 'resource';

if (response.statusCode !== 200) {
urlObj = new URL(location);

(urlObj.hostname === POSTMAN_API_HOST) &&
(resource = _(urlObj.pathname).split('/').get(1).slice(0, -1) || resource);

error = new Error(_.get(body, 'error.message',
`Error fetching ${resource}, the provided URL returned status code: ${response.statusCode}`));
const resource = isPostmanHost ? _(urlObj.getPath()).split('/').get(1).slice(0, -1) : 'resource',
error = new Error(_.get(body, 'error.message',
// eslint-disable-next-line max-len
`Error fetching ${resource}, the provided URL returned status code: ${response.statusCode}`));

return callback(_.assign(error, {
name: _.get(body, 'error.name', _.capitalize(resource) + 'FetchError'),
Expand Down
Loading

0 comments on commit f406493

Please sign in to comment.