feat: ✨ Created a mini nodeJS server with NewMan for testing without PostMan GUI.
This will mimic a run in a CD/CI environment or docker container.
This commit is contained in:
598
node_modules/newman/CHANGELOG.yaml
generated
vendored
Normal file
598
node_modules/newman/CHANGELOG.yaml
generated
vendored
Normal file
@@ -0,0 +1,598 @@
|
||||
5.3.0:
|
||||
date: 2021-09-07
|
||||
new features:
|
||||
- >-
|
||||
GH-2806 Exposed the runner on newman and the runtime run object in start
|
||||
event
|
||||
- >-
|
||||
Added ability to see request and responses in CLI reporter `--verbose`
|
||||
mode. Also added ability to see additional meta such as header count,
|
||||
cookie count and body mime-types in verbose mode.
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
5.2.4:
|
||||
date: 2021-06-24
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
5.2.3:
|
||||
date: 2021-05-03
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
5.2.2:
|
||||
date: 2021-01-03
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
5.2.1:
|
||||
date: 2020-11-02
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
5.2.0:
|
||||
date: 2020-09-01
|
||||
new features:
|
||||
- GH-2393 Added support for providing custom Cookie Jar
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
5.1.2:
|
||||
date: 2020-07-13
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
5.1.1:
|
||||
date: 2020-07-08
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
5.1.0:
|
||||
date: 2020-06-09
|
||||
new features:
|
||||
- >-
|
||||
GH-2392 Added a new `requestAgents` option to define custom requesting
|
||||
agents
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
5.0.1:
|
||||
date: 2020-05-18
|
||||
fixed bugs:
|
||||
- GH-2335 Improved error messages on file load error
|
||||
chores:
|
||||
- GH-2354 Updated dependencies
|
||||
|
||||
5.0.0:
|
||||
date: 2020-04-08
|
||||
new features:
|
||||
- GH-2299 Uses next-generation URL processor
|
||||
breaking changes:
|
||||
- GH-2297 Dropped support for Node < v10
|
||||
- GH-2251 Changed escape character for CSV to double-quotes
|
||||
- GH-2303 Trimmed incoming CSV string to remove byte order mark
|
||||
chores:
|
||||
- >-
|
||||
GH-2308 Updated .npmignore to prevent the addition of tests and config
|
||||
files in the published package
|
||||
- GH-2301 Updated nyc configuration
|
||||
- GH-2298 Updated ESLint rules
|
||||
- GH-2298 Updated dependencies
|
||||
|
||||
4.6.1:
|
||||
date: 2020-04-06
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
4.6.0:
|
||||
date: 2020-02-24
|
||||
new features:
|
||||
- >-
|
||||
GH-2235 Added a new option `--ssl-client-cert-list` to allow setting
|
||||
different certificates for different URLs in the collection
|
||||
- >-
|
||||
GH-2208 Added a new option `--ssl-extra-ca-certs` to extend well known
|
||||
"root" CAs with the extra certificates in the file
|
||||
chores:
|
||||
- GH-2209 Added `nyc` and `codecov` for test coverage
|
||||
- GH-2236 Updated dependencies
|
||||
|
||||
4.5.7:
|
||||
date: 2019-12-06
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
4.5.6:
|
||||
date: 2019-11-18
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
4.5.5:
|
||||
fixed bugs:
|
||||
- Fixed a bug where runtime execution crashes on Node v12
|
||||
- >-
|
||||
GH-2062 Added warnings for "reporter not found" and "reporter could not be
|
||||
loaded"
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
4.5.4:
|
||||
date: 2019-08-14
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
4.5.3:
|
||||
date: 2019-08-02
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
4.5.2:
|
||||
date: 2019-08-01
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
4.5.1:
|
||||
date: 2019-06-19
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
4.5.0:
|
||||
date: 2019-05-16
|
||||
new features:
|
||||
- Added support for the working directory using SecureFS
|
||||
- Added --working-dir and --no-insecure-file-read CLI options
|
||||
fixed bugs:
|
||||
- >-
|
||||
Fixed a bug that caused fetching collection from HTTPS URL crashes on Node
|
||||
v12
|
||||
chores:
|
||||
- Updated dependencies
|
||||
|
||||
4.4.1:
|
||||
date: 2019-03-25
|
||||
chores:
|
||||
- Updated dependencies
|
||||
fixed bugs:
|
||||
- >-
|
||||
GH-1932 Removed classname from JUnit reports and add it to both passed and
|
||||
failed tests
|
||||
|
||||
4.4.0:
|
||||
date: 2019-02-20
|
||||
chores:
|
||||
- Updated dependencies
|
||||
fixed bugs:
|
||||
- >-
|
||||
GH-1871 Trimmed incoming JSON string to remove byte order marks and other
|
||||
such artifacts.
|
||||
- Contextual help messages for newman -h
|
||||
- Fixed JUnit report generation for nested requests/tests
|
||||
- Corrected disabled variable behavior
|
||||
new features:
|
||||
- Added automatic (best guess) encoding detection of UTF-16LE and ISO-8859-1
|
||||
- Added --verbose flag for detailed CLI output
|
||||
|
||||
4.3.1:
|
||||
date: 2018-12-26
|
||||
fixed bugs:
|
||||
- >-
|
||||
Added start timestamp, classname and failure message to JUnit reporter for
|
||||
Azure DevOps
|
||||
|
||||
4.3.0:
|
||||
date: 2018-12-26
|
||||
new features:
|
||||
- Added AJV to the script sandbox
|
||||
fixed bugs:
|
||||
- Respected form data field ordering
|
||||
- >-
|
||||
Fixed a bug that caused requests to fail when the URL protocol is not in
|
||||
lowercase
|
||||
|
||||
4.2.3:
|
||||
date: 2018-12-15
|
||||
fixed bugs:
|
||||
- GH-1823 Added missing skipped flag to assertion information aggregator
|
||||
|
||||
4.2.2:
|
||||
date: 2018-11-07
|
||||
fixed bugs:
|
||||
- >-
|
||||
GH-1784 Updated postman-runtime to v7.4.2, which fixes a hawk security
|
||||
vulnerability
|
||||
|
||||
4.2.1:
|
||||
date: 2018-11-04
|
||||
fixed bugs:
|
||||
- GH-1779 Updated postman-runtime to v7.4.1
|
||||
|
||||
4.2.0:
|
||||
date: 2018-11-03
|
||||
new features:
|
||||
- >-
|
||||
GH-1776 Introduced the generic postman/newman Docker image, bumped Node
|
||||
version to 10
|
||||
- GH-1731 Added support for custom HTTP verbs
|
||||
docs:
|
||||
- GH-1717 Updated Docker image documentation
|
||||
chores:
|
||||
- GH-1770 Shifted to Travis for Windows builds
|
||||
- >-
|
||||
GH-1769 Added .gitattributes to enforce consistent line endings for .js
|
||||
files
|
||||
- >-
|
||||
GH-1743 Updated CLI reporter left padding to account for commander v2.19
|
||||
changes
|
||||
- Updated dependencies
|
||||
|
||||
4.1.0:
|
||||
date: 2018-08-29
|
||||
new features:
|
||||
- GH-1654 Added ability to select multiple folders for collection run
|
||||
chores:
|
||||
- GH-1687 Added `newmanVersion` in collection run options
|
||||
- GH-1684 Fixed flaky tests
|
||||
- Updated Dependencies
|
||||
|
||||
4.0.2:
|
||||
date: 2018-08-09
|
||||
fixed bugs:
|
||||
- >-
|
||||
GH-1673 Fixed a bug that prevented request errors from showing up in CLI
|
||||
reports
|
||||
|
||||
4.0.1:
|
||||
date: 2018-08-08
|
||||
fixed bugs:
|
||||
- GH-1669 Deprecated support for the v1 Postman Collection format
|
||||
- GH-1670 Throw proper error message for invalid --color values
|
||||
|
||||
4.0.0:
|
||||
date: 2018-08-06
|
||||
new features:
|
||||
- GH-1633 Added ability to run collection via Postman API UID reference
|
||||
breaking changes:
|
||||
- GH-1605 Dropped support for Node < v6
|
||||
- GH-1610 Dropped support for v2 CLI options
|
||||
- GH-1660 Dropped support for the v1 Postman Collection format
|
||||
- >-
|
||||
GH-1616 Moved inbuilt HTML reporter to a standalone reporter:
|
||||
https://github.com/postmanlabs/newman-reporter-html
|
||||
- GH-1653 Updated `color` option behaviour, dropped support for --no-color
|
||||
fixed bugs:
|
||||
- GH-1609 Fixed CSV auto parse, to avoid parsing numbers inside quotes
|
||||
- GH-1630 Updated default timeout values to Infinity
|
||||
chores:
|
||||
- GH-1623 Refactored Newman CLI
|
||||
- GH-1608 Updated ESLint rules
|
||||
- GH-1618 Reformatted README
|
||||
- Updated Dependencies
|
||||
|
||||
3.10.0:
|
||||
date: 2018-07-04
|
||||
new features:
|
||||
- GH-1596 Added --reporter-cli-no-banner option
|
||||
- GH-1551 Bumped Alpine Docker image Node version to v8
|
||||
- GH-1555 Added failure list to HTML reports
|
||||
fixed bugs:
|
||||
- GH-1612 Fixed JUnit reports for failed cases
|
||||
- >-
|
||||
GH-1576 Accounted for cases where the export path is a pre-existing
|
||||
directory
|
||||
- GH-1601 Reversed reporter lookup logic
|
||||
- GH-1584 Improved timeout messaging in HTML reports
|
||||
- GH-1594 Fixed a bug that caused reporter flags to break with `=`
|
||||
- GH-1592 Added a link to the Alpine Docker image
|
||||
- GH-1583 Capped JUnit timing precision to 3 decimal places
|
||||
- GH-1563 Ensured that all exported variable files have a valid name
|
||||
- GH-1578 Switched to cli-table3
|
||||
- GH-1575 Fixed typo in directory collection runner example
|
||||
- >-
|
||||
GH-1553 Fixed a bug that caused HTML reports to incorrectly duplicate
|
||||
requests across multiple iterations
|
||||
|
||||
3.9.4:
|
||||
date: 2018-05-25
|
||||
fixed bugs:
|
||||
- GH-1390 Improved failure table reporting details
|
||||
- GH-1389 Fixed no-assertions behavior for the CLI reporter
|
||||
- GH-1428 Corrected help text for missing arguments
|
||||
- GH-1397 Added postpublish script for automated Docker image pushing
|
||||
- GH-1416 Corrected Postman API reference link
|
||||
- Switched to a YAML changelog 1448
|
||||
- GH-1443 Corrected error representation in JUnit reports
|
||||
- >-
|
||||
GH-1496 Removed wait spinner from CLI output when --disable-unicode is
|
||||
present
|
||||
- GH-1450 Added support for --no-success-assertions
|
||||
- GH-1528 Made folder and request IDs unique in generated HTML reports
|
||||
- Updated dependencies
|
||||
|
||||
3.9.3:
|
||||
date: 2018-01-19
|
||||
fixed bugs:
|
||||
- Updated dependencies
|
||||
- GH-1385 Fixed minor formatting issues in the readme.
|
||||
- >-
|
||||
GH-1368 Updated folder collection runner example to exclude package*.json
|
||||
files
|
||||
|
||||
3.9.2:
|
||||
date: 2018-01-11
|
||||
fixed bugs:
|
||||
- Updated dependencies
|
||||
- >-
|
||||
GH-1366 Replaced deprecated Slack community link in the readme with the
|
||||
shiny new Postman community
|
||||
- GH-1350 Added setNextRequest information to the CLI reporter
|
||||
- >-
|
||||
GH-1331 Fixed a bug that caused legacy arguments to be processed out of
|
||||
order
|
||||
|
||||
3.9.1:
|
||||
date: 2017-12-08
|
||||
fixed bugs:
|
||||
- GH-1326 Fixed folder option handling
|
||||
- GH-1323 Updated documentation for --bail and options.bail
|
||||
- GH-1325 Fixed typographical error in issue template
|
||||
|
||||
3.9.0:
|
||||
date: 2017-12-05
|
||||
new features:
|
||||
- GH-1320 Extended --bail`` to work with afolder` option
|
||||
- GH-1298 Improved help text for incorrect usage
|
||||
- GH-1292 Added a name field to all applicable errors
|
||||
- GH-1278 Migrated from argparse to commander
|
||||
- GH-1277 Added support for a global timeout option
|
||||
- GH-1275 Migrated from istanbul to nyc
|
||||
- GH-1273 Tests now run on Node v8 as well
|
||||
|
||||
3.8.3:
|
||||
date: 2017-10-04
|
||||
fixed bugs:
|
||||
- Updated dependencies
|
||||
- >-
|
||||
GH-1227 Added timeout-script to extend default sandbox script execution
|
||||
timeouts
|
||||
- GH-1206 Corrected failure table handle in non TTY environments
|
||||
- GH-1218 Made JSON parsing more robust
|
||||
|
||||
3.8.2:
|
||||
date: 2017-09-18
|
||||
fixed bugs:
|
||||
- Updated dependencies.
|
||||
- >-
|
||||
GH-1202 Fixed a bug that caused csv files with comma spaces to be
|
||||
processed incorrectly.
|
||||
- GH-1191 Corrected programmatic iterationData usage in README.
|
||||
- GH-1197 Fixed broken link in parallel-collection-runs.js
|
||||
|
||||
3.8.1:
|
||||
date: 2017-08-18
|
||||
fixed bugs:
|
||||
- GH-1173 Updated postman-runtime to v6.2.6
|
||||
- GH-1172 Updated postman-collection to v2.1.1
|
||||
|
||||
3.8.0:
|
||||
date: 2017-06-25
|
||||
new features:
|
||||
- GH-1142 Added support for global variable specification via the CLI
|
||||
|
||||
3.7.6:
|
||||
date: 2017-06-19
|
||||
fixed bugs:
|
||||
- >-
|
||||
Bumped postman-runtime to v6.2.5, which contains a critical cookie
|
||||
handling bugfix.
|
||||
- Updated other dependencies.
|
||||
|
||||
3.7.5:
|
||||
date: 2017-06-10
|
||||
fixed bugs:
|
||||
- >-
|
||||
GH-1110 Bumped Collection SDK to v2.0.2, which contains ProxyConfig
|
||||
improvements.
|
||||
- >-
|
||||
GH-1115 Ensured that failed fetches from resource URLs result in a
|
||||
non-zero exit code.
|
||||
- >-
|
||||
GH-1105 Fixed a backward compatibility bug related to Buffer construction
|
||||
in the HTML reporter.
|
||||
|
||||
3.7.4:
|
||||
date: 2017-06-29
|
||||
fixed bugs:
|
||||
- GH-1099 Corrected response.body reference in the HTML reporter
|
||||
|
||||
3.7.3:
|
||||
date: 2017-06-28
|
||||
fixed bugs:
|
||||
- Updated dependencies.
|
||||
- >-
|
||||
GH-1098 Restored response.body in the data supplied to the HTML reporter
|
||||
template.
|
||||
|
||||
3.7.2:
|
||||
date: 2017-06-23
|
||||
fixed bugs:
|
||||
- >-
|
||||
Updated postman-runtime to v6.2.1, which contains a critical bugfix for
|
||||
authorization with variables
|
||||
|
||||
3.7.1:
|
||||
date: 2017-06-19
|
||||
fixed bugs:
|
||||
- GH-1082 Updated postman-collection-transformer to v2.1.4
|
||||
|
||||
3.7.0:
|
||||
date: 2017-06-19
|
||||
new features:
|
||||
- >-
|
||||
GH-1080 Fixed a bug that caused empty results in response.json() and
|
||||
response.text()
|
||||
- >-
|
||||
Support for second generation scripting sandbox with support for limited
|
||||
require.
|
||||
- Addition of assertion functions on request and response.
|
||||
- Added momentjs to the sandbox.
|
||||
- Added support for authorization mechanisms and IO events.
|
||||
|
||||
3.6.1:
|
||||
date: 2017-06-09
|
||||
fixed bugs:
|
||||
- Updated dependencies
|
||||
- GH-1026 Ensured that stdout is flushed on process.exit in CLI mode
|
||||
- GH-1062 Fixed type error for failed requests in the HTML reporter
|
||||
- >-
|
||||
GH-1039 Updated JUnit reporter to add time attribute to testsuites and
|
||||
testcase elements
|
||||
|
||||
3.6.0:
|
||||
date: 2017-03-12
|
||||
new features:
|
||||
- Updated dependencies
|
||||
- Introduced all new pm.* API.
|
||||
|
||||
3.5.2:
|
||||
date: 2017-03-17
|
||||
fixed bugs:
|
||||
- >-
|
||||
Update postman-runtime to v5.0.0, which uses CertificateList for client
|
||||
side SSL
|
||||
|
||||
3.5.1:
|
||||
date: 2017-03-14
|
||||
fixed bugs:
|
||||
- GH-949 Fixed a bug which caused some test results to not be displayed
|
||||
- Merged aggregation partial into base HTML reporter template
|
||||
- >-
|
||||
Allowed options.iterationData to be specified as an array of objects in
|
||||
programmatic usage
|
||||
|
||||
3.5.0:
|
||||
date: 2017-03-07
|
||||
new features:
|
||||
- Added support for multi level folders in the cli, html and junit reporters
|
||||
- >-
|
||||
Updated postman-collection to v1.0.0, which contains helper methods for
|
||||
dealing with multi-level folders
|
||||
- Updated many other non-critical packages
|
||||
|
||||
3.4.3:
|
||||
date: 2017-01-31
|
||||
fixed bugs:
|
||||
- >-
|
||||
Updated postman-runtime to v4.0.3, which contains fixed bugs for URL
|
||||
parameter encoding
|
||||
- >-
|
||||
Updated postman-collection to v0.5.11, which contains fixed bugs for UTF-8
|
||||
encoded responses, and variables in URL hosts
|
||||
|
||||
3.4.2:
|
||||
date: 2017-01-09
|
||||
fixed bugs:
|
||||
- GH-859 Fixed a bug in the CLI reporter for Newman programmatic usage
|
||||
|
||||
3.4.1:
|
||||
date: 2017-01-06
|
||||
fixed bugs:
|
||||
- Fixed Buffer compatibility issue for Node v4
|
||||
- HTML reporter works correctly for failed requests
|
||||
|
||||
3.4.0:
|
||||
date: 2016-12-29
|
||||
new features:
|
||||
- >-
|
||||
Updated postman-runtime to v4.0, which has a lot of memory usage
|
||||
improvements
|
||||
- HTML reporter now contains folder information
|
||||
- Added --color option to force colored output in non-TTY environments
|
||||
|
||||
3.3.1:
|
||||
date: 2016-12-14
|
||||
fixed bugs:
|
||||
- Added more details to the HTML reporter
|
||||
- >-
|
||||
Updated postman-collection to the latest version which contains a bugfix
|
||||
for OAuth1 with realms
|
||||
- Updated postman-runtime which has a few fixes for browser based workflows
|
||||
|
||||
3.3.0:
|
||||
date: 2016-11-21
|
||||
new features:
|
||||
- Added options to provide client-side SSL certificates on the command line
|
||||
- Updated the versions of postman-runtime and postman-collection libraries
|
||||
|
||||
3.2.0:
|
||||
date: 2016-10-18
|
||||
new features:
|
||||
- Ensure that environment exports are consistent with the app
|
||||
- Simplified the importing logic for environment and globals
|
||||
|
||||
3.1.2:
|
||||
date: 2016-08-25
|
||||
fixed bugs:
|
||||
- >-
|
||||
Updated postman-runtime, postman-collection and
|
||||
postman-collection-transformer dependencies
|
||||
|
||||
3.1.1:
|
||||
date: 2016-08-25
|
||||
fixed bugs:
|
||||
- Fixed a bug which caused HTML reporter statistics to be incorrect
|
||||
- >-
|
||||
Added an option --disable-unicode to forcibly disable unicode symbols in
|
||||
the output
|
||||
- >-
|
||||
File based options in newman.run (environments, data, globals) can now be
|
||||
specified as JSON objects as well
|
||||
- >-
|
||||
Updated to the latest version of Postman Runtime, which contains a number
|
||||
of memory optimizations
|
||||
- >-
|
||||
Specifying an iteration data file now results in the correct number of
|
||||
iteration runs
|
||||
|
||||
3.1.0:
|
||||
date: 2016-08-25
|
||||
new features:
|
||||
- >-
|
||||
GH-553 Fixed issue with environment and globals export format was using
|
||||
wrong property names
|
||||
- Fixed issue where --export-* CLI option did not work with no parameters
|
||||
- Added support for postman.getResponseCookie in the script sandbox
|
||||
- Prettified HTML report template
|
||||
- >-
|
||||
Added support for custom HTML report templates via
|
||||
--reporter-html-template flag
|
||||
- Added file upload support
|
||||
- GH-547 Fixed a bug in the timeout request flag
|
||||
- Updated runtime dependency to 2.4.4
|
||||
- Fixed a bug that caused incorrect iterationCount detection
|
||||
- Better error messages
|
||||
- Fixed a bug that caused incorrect exports of environment and global values
|
||||
- The export parameters now default to /newman/*
|
||||
- >-
|
||||
Added a new CLI option, --silent which ensures Newman does not write
|
||||
anything to the terminal
|
||||
|
||||
3.0.1:
|
||||
date: 2016-08-09
|
||||
fixed bugs:
|
||||
- Updated Postman Runtime to v2.4.1
|
||||
- Newman now exits with a non-zero status code on test failures or errors
|
||||
|
||||
3.0.0:
|
||||
date: 2016-08-09
|
||||
fixed bugs:
|
||||
- First stable release of Newman v3.0
|
||||
- Added ability to suppress exit code on failures
|
||||
- >-
|
||||
Renamed the "--stop-on-error" option to "--bail", which ensures that
|
||||
Newman stops on test failures or errors
|
||||
|
||||
3.0.0-rc.1:
|
||||
date: 2016-08-08
|
||||
initial release:
|
||||
- Initial release of Newman v3. Migration Guide
|
203
node_modules/newman/LICENSE.md
generated
vendored
Normal file
203
node_modules/newman/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "{}"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2016 Postdot Technologies, Inc
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
445
node_modules/newman/MIGRATION.md
generated
vendored
Normal file
445
node_modules/newman/MIGRATION.md
generated
vendored
Normal file
@@ -0,0 +1,445 @@
|
||||
# Newman
|
||||
|
||||
## Table of contents
|
||||
|
||||
1. [Updating to the latest version](#updating-to-the-latest-version)
|
||||
2. [Migrating from V4 to V5](#migrating-from-v4-to-v5)
|
||||
3. [Migrating from V3 to V4](#migrating-from-v3-to-v4)
|
||||
4. [Migrating from V2 to V3](#migrating-from-v2-to-v3)
|
||||
|
||||
## Updating to the latest version
|
||||
|
||||
If you're updating from an older version of Newman, make sure you read the rest of this document, to understand the changes.
|
||||
|
||||
#### 1. Update Newman
|
||||
```console
|
||||
$ npm update -g newman
|
||||
```
|
||||
|
||||
#### 2. Check Installation
|
||||
```console
|
||||
$ newman --version # Should show the latest version of Newman
|
||||
$ npm show newman version # Should show the same version as of above
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Migrating from V4 to V5
|
||||
|
||||
Newman v5.0 drops support for Node v6 and v8. Also, the inbuilt URL and CSV processor are upgraded.
|
||||
|
||||
### Upgrading Node.js
|
||||
Newman v5 requires Node.js >= v10. [Install Node.js via package manager](https://nodejs.org/en/download/package-manager/).
|
||||
|
||||
### Next-Generation URL Processor
|
||||
Newman v5 introduces an improved URL processing system that fixes several limitations of the present URL processor around the aspects of parsing and encoding.
|
||||
Know more about the changes in [this GitHub issue](https://github.com/postmanlabs/postman-app-support/issues/8154) and [this blog post](https://blog.postman.com/2020/04/06/introducing-the-next-generation-postman-url-processor/).
|
||||
|
||||
### CSV parser
|
||||
The longstanding [disparity](https://github.com/postmanlabs/postman-app-support/issues/8024) between the Newman and Postman app's CSV parser is fixed.
|
||||
|
||||
#### Changed escape character to double-quotes
|
||||
|
||||
The default escape character is changed to `"` (double quote) from `\` (backslash).
|
||||
|
||||
##### V4 CSV input
|
||||
```csv
|
||||
id, name
|
||||
"\"1\"", "foo \"bar\" baz"
|
||||
```
|
||||
|
||||
##### V5 equivalent
|
||||
```csv
|
||||
id, name
|
||||
"""1""", "foo ""bar"" baz"
|
||||
```
|
||||
|
||||
#### Relaxed parsing
|
||||
|
||||
1. Preserve quotes inside unquoted field
|
||||
2. Discard inconsistent columns count
|
||||
3. Detect and exclude the byte order mark (BOM)
|
||||
|
||||
---
|
||||
|
||||
## Migrating from V3 to V4
|
||||
|
||||
Newman v4.0 drops support for Node v4 and dropped support for v2 CLI options. Also, the inbuilt HTML reporter has been moved to a standalone reporter.
|
||||
|
||||
### Upgrading Node.js
|
||||
Newman v4 requires Node.js >= v6. [Install Node.js via package manager](https://nodejs.org/en/download/package-manager/).
|
||||
|
||||
### Discontinued CLI Options
|
||||
Newman v4 drops support for all the deprecated v2 CLI options, check [V2 to V3 Migration Guide](#v2-to-v3-migration-guide).<br/>
|
||||
For the complete list of supported options, see the [README](README.md)
|
||||
|
||||
#### --no-color
|
||||
This option is dropped because of the changes made to the `color` option. See the section below for more details.
|
||||
|
||||
### Using `color` option
|
||||
The behaviour of this option is changed in both CLI and Library. Unlike Newman v3.x, this option alone can be used to enable
|
||||
or disable colored CLI output.
|
||||
|
||||
#### CLI
|
||||
|
||||
##### 1. Enabling colored output
|
||||
|
||||
###### V3 command
|
||||
```console
|
||||
$ newman run collection.json --color
|
||||
```
|
||||
|
||||
###### V4 equivalent
|
||||
```console
|
||||
$ newman run collection.json --color on
|
||||
```
|
||||
|
||||
##### 2. Disabling colored output
|
||||
|
||||
###### V3 command
|
||||
```console
|
||||
$ newman run collection.json --no-color
|
||||
```
|
||||
|
||||
###### V4 equivalent
|
||||
```console
|
||||
$ newman run collection.json --color off
|
||||
```
|
||||
|
||||
#### Library
|
||||
|
||||
##### 1. Enabling colored output
|
||||
|
||||
###### Using V3
|
||||
```javascript
|
||||
newman.run({
|
||||
collection: 'collection.json',
|
||||
reporters: ['cli'],
|
||||
color: true
|
||||
}, callback);
|
||||
```
|
||||
|
||||
###### V4 equivalent
|
||||
```javascript
|
||||
newman.run({
|
||||
collection: 'collection.json',
|
||||
reporters: ['cli'],
|
||||
color: 'on'
|
||||
}, callback);
|
||||
```
|
||||
|
||||
##### 2. Disabling colored output
|
||||
|
||||
###### Using V3
|
||||
```javascript
|
||||
newman.run({
|
||||
collection: 'collection.json',
|
||||
reporters: ['cli'],
|
||||
noColor: true
|
||||
}, callback);
|
||||
```
|
||||
|
||||
###### V4 equivalent
|
||||
```javascript
|
||||
newman.run({
|
||||
collection: 'collection.json',
|
||||
reporters: ['cli'],
|
||||
color: 'off'
|
||||
}, callback);
|
||||
```
|
||||
|
||||
**Note:**
|
||||
The default behavior is to detect color support for the terminal and act accordingly.
|
||||
This behavior can be modified by setting the color option to `on` or `off` respectively.
|
||||
|
||||
### Using HTML Reporter
|
||||
The inbuilt HTML reporter has been moved to a standalone reporter. Install it with:
|
||||
```console
|
||||
$ npm install -g newman-reporter-html
|
||||
```
|
||||
Installation should be global if newman is installed globally, local otherwise. (Remove `-g` flag from the above command for a local installation.)
|
||||
|
||||
The complete installation and usage guide is available here: https://github.com/postmanlabs/newman-reporter-html
|
||||
|
||||
### Deprecated support for the v1 collection format
|
||||
Newman >= v4 deprecates support for the v1 collection format.<br/>
|
||||
Use the [Postman Native app](https://postman.com/downloads) to export collections in the v2 format.
|
||||
|
||||
### CSV auto parse
|
||||
A [fix][pr1609] has been made to avoid parsing numbers inside quotes.<br/>
|
||||
Example, `"000123"` will not be parsed to `123` like before.
|
||||
|
||||
Fixes issues: [#1100][i1100], [#1215][i1215] & [#1346][i1346]
|
||||
|
||||
### Default timeouts
|
||||
All timeouts now have the default value of infinity. [#1630](pr1630)
|
||||
|
||||
[pr1609]: https://github.com/postmanlabs/newman/pull/1609
|
||||
[pr1630]: https://github.com/postmanlabs/newman/pull/1630
|
||||
[i1100]: https://github.com/postmanlabs/newman/issues/1100
|
||||
[i1215]: https://github.com/postmanlabs/newman/issues/1215
|
||||
[i1346]: https://github.com/postmanlabs/newman/issues/1346
|
||||
|
||||
---
|
||||
|
||||
## Migrating from V2 to V3
|
||||
|
||||
Newman v3.0 is a complete rewrite of Newman from the ground up, which works well with other Node libraries, and
|
||||
allows flexibility for future features such as parallel collection runs, or performing parallel requests within the
|
||||
same run. Above all, Newman now uses [Postman Runtime](https://github.com/postmanlabs/postman-runtime/) in order to
|
||||
provide a consistent experience on Postman Apps and on CLI.
|
||||
|
||||
### General overview of features
|
||||
|
||||
1. Newman collection runs now happen with the `run` command. See sections below for more examples.
|
||||
2. More informative terminal output with colourful details of what went wrong, and most importantly, where it went
|
||||
wrong.
|
||||
3. Ability to load environment, globals, collections as well as iteration data from urls.
|
||||
4. Friendlier usage as a library. A lot of use-cases depend on the use of Newman as a Node library, and v3.0 is written
|
||||
with a library-first mindset.
|
||||
5. Internally things (by things, we usually mean code) have been better organised to allow faster implementation of
|
||||
features.
|
||||
|
||||
### Changes since v2.x
|
||||
|
||||
Migrating to Newman v3.x for most simple use cases is a trivial affair. We have taken care to support older CLI options.
|
||||
Which means, if you upgrade, it should just work! Having said that, we would soon discontinue the older CLI options and
|
||||
you should start using the new ones. Furthermore, the new features are only available via the new CLI options.
|
||||
|
||||
Since Newman 3.x is a complete rewrite, expect it to have subtle behavioural differences when compared with Newman v2.x,
|
||||
your reports will look a bit different, the CLI output is a complete overhaul, your collection runs will inherit all the
|
||||
qualities of the new Postman Runtime (jQuery deprecation, discontinuation of DOM), etc. For a comprehensive list of
|
||||
usage changes across Newman V2 and V3, look at the table provided below.
|
||||
|
||||
As such, if there is something specific that not working with respect to v2.x or any workaround that you were doing,
|
||||
we will be glad to chat and find out if they can still be done. You can find us on our [Community Forum](https://community.postman.com).
|
||||
|
||||
### HTML, XML and other outputs are now "reporters"
|
||||
Newman v3 adopts a "reporter" model and as such features that were previously part of Newman core has now been moved
|
||||
into reporters. Consequently, the CLI options for these features are now accessible via `--reporter-*` options. You
|
||||
might also notice that some of the functionalities of reporters have been reduced even though the reporter outputs have
|
||||
become more detailed. This is to offload non-essential codebase away from Newman core and be later made pluggable into
|
||||
external reporter plugins.
|
||||
|
||||
### --no-color is automated
|
||||
Newman now automatically detects lack of colour support and as such this flag does not need to be explicitly provided
|
||||
any more. However, `--no-color` is still available to force not to use colors in terminal output.
|
||||
|
||||
### Discontinued CLI Options
|
||||
|
||||
#### -S --noTestSymbols
|
||||
This switch no longer has any effect. Newman v3 effectively handles unicode output on Windows Platform.
|
||||
|
||||
#### -p, --pretty
|
||||
This switch used to render exported JSON files in newman v2 in a pretty format. Newman v3 always exports in pretty
|
||||
format and as such, this switch is now not needed. If you want to use compressed export formats, run the exported files
|
||||
through some JSON minifier.
|
||||
|
||||
## V2 to V3 Migration Guide
|
||||
|
||||
The following tables enumerate the options that have either been deprecated / discontinued, or renamed in Newman V3. The
|
||||
V3 equivalents provided in the second column are intended for use with the `run` command (described below), and will not
|
||||
work in V2 mode. The original options from V2, still work (without `run`, of course) however, but will be removed in the
|
||||
next major Newman release.
|
||||
|
||||
In the V2 option status column, deprecated implies that the corresponding CLi option has been left for backward
|
||||
compatibility and will be removed in the next major Newman release. A status of discontinued implies that the option is
|
||||
no longer supported, or is implemented by default.
|
||||
|
||||
Options missing from the migration tables have been left as they were from Newman V2. For the complete list of supported
|
||||
options, see [README.md](https://github.com/postmanlabs/newman/blob/release/3.x/README.md)
|
||||
|
||||
### CLI
|
||||
|
||||
#### Sample use cases
|
||||
|
||||
##### 1. A collection run with all basic options configured, excluding reporter actions
|
||||
|
||||
###### V2 command
|
||||
```terminal
|
||||
newman --collection collection.json --environment env.json --data data.csv --globals globals.json --number 2 --exportGlobals globalOut.json --exportEnvironment envOut.json --delay 10 --requestTimeout 5000 --noTestSymbols --tls --exitCode --whiteScreen --avoidRedirects --stopOnError
|
||||
```
|
||||
###### V3 equivalent
|
||||
```terminal
|
||||
newman run collection.json --environment env.json --iteration-data data.csv --globals globals.json --iteration-count 2 --export-globals globalOut.json --export-environment envOut.json --delay-request 10 --timeout-request 5000 --disable-unicode --suppress-exit-code --ignore-redirects --bail
|
||||
```
|
||||
|
||||
##### 2. A collection run with various reporter tasks
|
||||
|
||||
###### V2 command
|
||||
```terminal
|
||||
newman --url https://a.com/collection.json --environment-url https://a.com/env.json --noColor --outputFile jsonOut.json --testReportFile xmlOut.xml --html htmlOutput.html --outputFileVerbose verboseOut.log
|
||||
```
|
||||
###### V3 equivalent
|
||||
```terminal
|
||||
newman run https://a.com/collection.json --environment https://a.com/env.json --reporters cli,html,json,junit --reporter-json-export jsonOut.json --reporter-junit-export xmlOut.xml --reporter-html-export htmlOutput.html
|
||||
```
|
||||
|
||||
#### CLI migration table
|
||||
| V2 CLI option | V3 equivalent | V2 option Status |
|
||||
|---------------|---------------|------------------|
|
||||
| -c --collection | N.A | Deprecated (Pass the collection file path without the collection flag) |
|
||||
| -u --url | N.A | Deprecated (Pass the collection file URL without the collection flag) |
|
||||
| --environment-url | N.A | Deprecated (Pass the environment file URL to -e --environment) |
|
||||
| -f --folder | --folder | Deprecated. The V3 folder option has been reduced to --folder |
|
||||
| -d --data | -d --iteration-data | Deprecated |
|
||||
| -n --number | -n --iteration-count | Deprecated |
|
||||
| -i --import | N.A | Deprecated |
|
||||
| -p --pretty | N.A | Discontinued |
|
||||
| -G --exportGlobals | --export-globals | Deprecated |
|
||||
| -E --exportEnvironment | --export-environment | Deprecated |
|
||||
| -y --delay | --delay-request | Deprecated |
|
||||
| -r --requestTimeout | --timeout-request | Deprecated |
|
||||
| -s --stopOnError | --bail | Deprecated |
|
||||
| -j --noSummary | --reporter-cli-no-summary | Deprecated |
|
||||
| -C --noColour | --no-color | Deprecated |
|
||||
| -S --noTestSymbols | --disable-unicode | **Discontinued** |
|
||||
| -l --tls | N.A | **Discontinued** |
|
||||
| -x --exitCode | -x --suppress-exit-code | Deprecated (The V3 option takes no arguments, and forces an exit code of 0)|
|
||||
| -w --whiteScreen | N.A | **Discontinued** |
|
||||
| -o --outputFile | --reporter-json-export | Deprecated |
|
||||
| -t --testReportFile | --reporter-junit-export | Deprecated |
|
||||
| -H --html | --reporter-html-export | Deprecated |
|
||||
| -O --outputFileVerbose | N.A | **Discontinued** |
|
||||
| -R --avoidRedirects | --ignore-redirects | Deprecated |
|
||||
|
||||
### Library usage
|
||||
|
||||
#### Sample use cases
|
||||
|
||||
##### 1. A collection run with all basic options configured, excluding reporter actions
|
||||
|
||||
###### V2 command
|
||||
```javascript
|
||||
newman.execute({
|
||||
collection: 'collection.json',
|
||||
environment: 'env.json',
|
||||
data: 'data.csv',
|
||||
globals: 'globals.json',
|
||||
number: 2,
|
||||
exportGlobals: 'globalOut.json',
|
||||
exportEnvironment: 'envOut.json',
|
||||
delay: 10,
|
||||
stopOnError: true,
|
||||
requestTimeout: 5000,
|
||||
noTestSymbols: true,
|
||||
tls: true,
|
||||
exitCode: true,
|
||||
whiteScreen: true,
|
||||
avoidRedirects: true
|
||||
}, callback);
|
||||
```
|
||||
|
||||
###### V3 equivalent
|
||||
```javascript
|
||||
newman.run({
|
||||
collection: 'collection.json',
|
||||
environment: 'env.json',
|
||||
iterationData: 'data.csv',
|
||||
globals: 'globals.json',
|
||||
iterationCount: 2,
|
||||
exportGlobals: 'globalOut.json',
|
||||
exportEnvironment: 'envOut.json',
|
||||
delayRequest: 10,
|
||||
bail: true,
|
||||
timeoutRequest: 5000,
|
||||
disableUnicode: true,
|
||||
suppressExitCode: true,
|
||||
ignoreRedirects: true
|
||||
}, callback);
|
||||
```
|
||||
|
||||
##### 2 A collection run with various reporter tasks
|
||||
|
||||
###### V2 command
|
||||
```javascript
|
||||
newman.execute({
|
||||
collection: 'https://a.com/collection.json',
|
||||
environment: {
|
||||
"id": "my-id",
|
||||
"name": "testEnv",
|
||||
"values": [
|
||||
{
|
||||
"key": "env",
|
||||
"value": "env2",
|
||||
},
|
||||
{
|
||||
"key": "data",
|
||||
"value": "env2",
|
||||
}
|
||||
]
|
||||
},
|
||||
globals: [
|
||||
{
|
||||
key: "var1",
|
||||
value: "/get",
|
||||
enabled: true
|
||||
},
|
||||
{
|
||||
key: "var2",
|
||||
value: "Global Bar",
|
||||
}
|
||||
],
|
||||
outputFile: 'jsonOut.json',
|
||||
testReportFile: 'xmlOut.xml',
|
||||
html: 'htmlOutput.html',
|
||||
outputFileVerbose: 'verboseOut.log'
|
||||
}, callback);
|
||||
```
|
||||
|
||||
###### V3 equivalent
|
||||
```javascript
|
||||
newman.run({
|
||||
collection: 'https://a.com/collection.json',
|
||||
environment: {
|
||||
"id": "my-id",
|
||||
"name": "testEnv",
|
||||
"values": [
|
||||
{
|
||||
"key": "env",
|
||||
"value": "env2",
|
||||
},
|
||||
{
|
||||
"key": "data",
|
||||
"value": "env2",
|
||||
}
|
||||
]
|
||||
},
|
||||
iterationData: [ {a: 1}, {a: 2} ],
|
||||
globals: [
|
||||
{
|
||||
key: "var1",
|
||||
value: "/get",
|
||||
enabled: true
|
||||
},
|
||||
{
|
||||
key: "var2",
|
||||
value: "Global Bar",
|
||||
}
|
||||
],
|
||||
reporters: ['html', 'junit', 'json'],
|
||||
reporter: {
|
||||
html: {
|
||||
export: 'htmlOutput.html'
|
||||
},
|
||||
junit: {
|
||||
export: 'xmlOut.xml'
|
||||
},
|
||||
json: {
|
||||
export: 'jsonOut.json'
|
||||
}
|
||||
}
|
||||
}, callback);
|
||||
```
|
||||
|
||||
#### Library migration table
|
||||
| V2 `options` | V3 equivalent | V2 option Status |
|
||||
|---------------|---------------|------------------|
|
||||
| data | iterationData | Deprecated |
|
||||
| number | iterationCount | Deprecated |
|
||||
| delay | delayRequest | Deprecated |
|
||||
| requestTimeout | timeoutRequest | Deprecated |
|
||||
| noTestSymbols | disableUnicode | **Discontinued** |
|
||||
| stopOnError | bail | Deprecated |
|
||||
| exitCode | suppressExitCode | Deprecated |
|
||||
| avoidRedirects | ignoreRedirects | Deprecated |
|
690
node_modules/newman/README.md
generated
vendored
Normal file
690
node_modules/newman/README.md
generated
vendored
Normal file
@@ -0,0 +1,690 @@
|
||||
### Newman v5 has been released. Check the [migration guide](MIGRATION.md#migrating-from-v4-to-v5) and [changelog](https://github.com/postmanlabs/newman/blob/v5.0.0/CHANGELOG.yaml#L1) for more details.
|
||||
|
||||
<a href="https://www.postman.com/"><img src="https://assets.getpostman.com/common-share/postman-logo-horizontal-320x132.png" /></a><br />
|
||||
_Manage all of your organization's APIs in Postman, with the industry's most complete API development environment._
|
||||
|
||||
# newman <sub>_the cli companion for postman_</sub> [](https://travis-ci.com/postmanlabs/newman) [](https://codecov.io/gh/postmanlabs/newman)
|
||||
|
||||
Newman is a command-line collection runner for Postman. It allows you to effortlessly run and test a Postman collection directly from the command-line. It is built with extensibility in mind so that you can easily integrate it with your continuous integration servers and build systems.
|
||||
|
||||
|
||||
## Table of contents
|
||||
|
||||
1. [Getting Started](#getting-started)
|
||||
2. [Usage](#usage)
|
||||
1. [Using Newman CLI](#using-newman-cli)
|
||||
2. [Using Newman as a Library](#using-newman-as-a-library)
|
||||
3. [Using Reporters with Newman](#using-reporters-with-newman)
|
||||
3. [Command Line Options](#command-line-options)
|
||||
1. [newman-options](#newman-options)
|
||||
2. [newman-run](#newman-run-collection-file-source-options)
|
||||
3. [SSL](#ssl)
|
||||
4. [Configuring Proxy](#configuring-proxy)
|
||||
4. [API Reference](#api-reference)
|
||||
1. [newman run](#newmanrunoptions-object--callback-function--run-eventemitter)
|
||||
2. [Run summary object](#newmanruncallbackerror-object--summary-object)
|
||||
3. [Events emitted during a collection run](#newmanrunevents)
|
||||
5. [Reporters](#reporters)
|
||||
1. [Configuring Reporters](#configuring-reporters)
|
||||
2. [CLI Reporter](#cli-reporter)
|
||||
3. [JSON Reporter](#json-reporter)
|
||||
4. [JUnit Reporter](#junitxml-reporter)
|
||||
5. [HTML Reporter](#html-reporter)
|
||||
6. [External Reporters](#external-reporters)
|
||||
1. [Using External Reporters](#using-external-reporters)
|
||||
2. [Creating Your Own Reporter](#creating-your-own-reporter)
|
||||
7. [File Uploads](#file-uploads)
|
||||
8. [Using Newman with the Postman API](#using-newman-with-the-postman-api)
|
||||
9. [Using Newman in Docker](#using-newman-in-docker)
|
||||
10. [Using Socks Proxy](#using-socks-proxy)
|
||||
11. [Migration Guide](#migration-guide)
|
||||
12. [Compatibility](#compatibility)
|
||||
13. [Contributing](#contributing)
|
||||
14. [Community Support](#community-support)
|
||||
15. [License](#license)
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
To run Newman, ensure that you have Node.js >= v10. [Install Node.js via package manager](https://nodejs.org/en/download/package-manager/).
|
||||
|
||||
### Installation
|
||||
The easiest way to install Newman is using NPM. If you have Node.js installed, it is most likely that you have NPM installed as well.
|
||||
|
||||
```console
|
||||
$ npm install -g newman
|
||||
```
|
||||
This installs Newman globally on your system allowing you to run it from anywhere. If you want to install it locally, Just remove the `-g` flag.
|
||||
|
||||
#### Using Homebrew
|
||||
Install Newman globally on your system using Homebrew.
|
||||
```console
|
||||
$ brew install newman
|
||||
```
|
||||
|
||||
[back to top](#table-of-contents)
|
||||
|
||||
## Usage
|
||||
|
||||
### Using Newman CLI
|
||||
The `newman run` command allows you to specify a collection to be run. You can easily export your Postman
|
||||
Collection as a json file from the [Postman App](https://www.postman.com/downloads/) and run it using Newman.
|
||||
|
||||
```console
|
||||
$ newman run examples/sample-collection.json
|
||||
```
|
||||
|
||||
If your collection file is available as an URL (such as from our [Cloud API service](https://api.getpostman.com)),
|
||||
Newman can fetch your file and run it as well.
|
||||
|
||||
```console
|
||||
$ newman run https://www.getpostman.com/collections/631643-f695cab7-6878-eb55-7943-ad88e1ccfd65-JsLv
|
||||
```
|
||||
|
||||
For the complete list of options, refer the [Command Line Options](#command-line-options) section below.
|
||||
|
||||

|
||||
|
||||
### Using Newman as a Library
|
||||
Newman can be easily used within your JavaScript projects as a Node.js module. The entire set of Newman CLI functionality is available for programmatic use as well. The following example runs a collection by reading a JSON collection file stored on disk.
|
||||
|
||||
```javascript
|
||||
const newman = require('newman'); // require newman in your project
|
||||
|
||||
// call newman.run to pass `options` object and wait for callback
|
||||
newman.run({
|
||||
collection: require('./sample-collection.json'),
|
||||
reporters: 'cli'
|
||||
}, function (err) {
|
||||
if (err) { throw err; }
|
||||
console.log('collection run complete!');
|
||||
});
|
||||
```
|
||||
|
||||
For the complete list of options, refer the [API Reference](#api-reference) section below.
|
||||
|
||||
### Using Reporters with Newman
|
||||
Reporters provide information about the current collection run in a format that is easy to both: disseminate and assimilate.
|
||||
Reporters can be configured using the `-r` or `--reporters` options. Inbuilt reporters in newman are: `cli`, `json`, `junit`, `progress` and `emojitrain`.
|
||||
|
||||
CLI reporter is enabled by default when Newman is used as a CLI, you do not need to specifically provide the same as part of reporters option. However, enabling one or more of the other reporters will result in no CLI output. Explicitly enable the CLI option in such a scenario. Check the example given below using the CLI and JSON reporters:
|
||||
|
||||
```console
|
||||
$ newman run examples/sample-collection.json -r cli,json
|
||||
```
|
||||
|
||||
For more details on [Reporters](#reporters) and writing your own [External Reporters](#external-reporters) refer to their corresponding sections below.
|
||||
|
||||
[back to top](#table-of-contents)
|
||||
|
||||
## Command Line Options
|
||||
|
||||
### `newman [options]`
|
||||
|
||||
- `-h`, `--help`<br />
|
||||
Show command line help, including a list of options, and sample use cases.
|
||||
|
||||
- `-v`, `--version`<br />
|
||||
Displays the current Newman version, taken from [package.json](https://github.com/postmanlabs/newman/blob/master/package.json)
|
||||
|
||||
|
||||
### `newman run <collection-file-source> [options]`
|
||||
|
||||
- `-e <source>`, `--environment <source>`<br />
|
||||
Specify an environment file path or URL. Environments provide a set of variables that one can use within collections.
|
||||
[Read More](https://learning.postman.com/docs/postman/variables-and-environments/managing-environments/)
|
||||
|
||||
- `-g <source>`, `--globals <source>`<br />
|
||||
Specify the file path or URL for global variables. Global variables are similar to environment variables but have a lower
|
||||
precedence and can be overridden by environment variables having the same name.
|
||||
|
||||
- `-d <source>`, `--iteration-data <source>`<br />
|
||||
Specify a data source file (JSON or CSV) to be used for iteration as a path to a file or as a URL.
|
||||
[Read More](https://learning.postman.com/docs/postman/collection-runs/working-with-data-files/)
|
||||
|
||||
- `-n <number>`, `--iteration-count <number>`<br />
|
||||
Specifies the number of times the collection has to be run when used in conjunction with iteration data file.
|
||||
|
||||
- `--folder <name>`<br />
|
||||
Run requests within a particular folder/folders or specific requests in a collection. Multiple folders or requests can be specified by using
|
||||
--folder multiple times, like so: --folder f1 --folder f2 --folder r1 --folder r2.
|
||||
|
||||
|
||||
- `--working-dir <path>`<br />
|
||||
Set the path of the working directory to use while reading files with relative paths. Default to current directory.
|
||||
|
||||
- `--no-insecure-file-read`<br />
|
||||
Prevents reading of files situated outside of the working directory.
|
||||
|
||||
- `--export-environment <path>`<br />
|
||||
The path to the file where Newman will output the final environment variables file before completing a run.
|
||||
|
||||
- `--export-globals <path>`<br />
|
||||
The path to the file where Newman will output the final global variables file before completing a run.
|
||||
|
||||
- `--export-collection <path>`<br />
|
||||
The path to the file where Newman will output the final collection file before completing a run.
|
||||
|
||||
- `--timeout <ms>`<br />
|
||||
Specify the time (in milliseconds) to wait for the entire collection run to complete execution.
|
||||
|
||||
- `--timeout-request <ms>`<br />
|
||||
Specify the time (in milliseconds) to wait for requests to return a response.
|
||||
|
||||
- `--timeout-script <ms>`<br />
|
||||
Specify the time (in milliseconds) to wait for scripts to complete execution.
|
||||
|
||||
- `-k`, `--insecure`<br />
|
||||
Disables SSL verification checks and allows self-signed SSL certificates.
|
||||
|
||||
- `--ignore-redirects`<br />
|
||||
Prevents newman from automatically following 3XX redirect responses.
|
||||
|
||||
- `--delay-request`<br />
|
||||
Specify the extent of delay between requests (milliseconds).
|
||||
|
||||
- `--cookie-jar <path>`<br />
|
||||
Specify the file path for a JSON Cookie Jar. Uses [`tough-cookie`](https://github.com/salesforce/tough-cookie) to deserialize the file.
|
||||
|
||||
- `--export-cookie-jar <path>`<br />
|
||||
The path to the file where Newman will output the final cookie jar file before completing a run. Uses `tough-cookie`'s serialize method.
|
||||
|
||||
- `--bail [optional modifiers]`<br />
|
||||
Specify whether or not to stop a collection run on encountering the first test script error.<br />
|
||||
Can optionally accept modifiers, currently include `folder` and `failure`.<br />
|
||||
`folder` allows you to skip the entire collection run in case an invalid folder
|
||||
was specified using the `--folder` option or an error was encountered in general.<br />
|
||||
On the failure of a test, `failure` would gracefully stop a collection run after completing the current test script.
|
||||
|
||||
- `-x`, `--suppress-exit-code`<br />
|
||||
Specify whether or not to override the default exit code for the current run.
|
||||
|
||||
- `--color <value>`<br />
|
||||
Enable or Disable colored CLI output. The color value can be any of the three: `on`, `off` or `auto`*(default)*.<br/>
|
||||
With `auto`, Newman attempts to automatically turn color on or off based on the color support in the terminal.
|
||||
This behaviour can be modified by using the `on` or `off` value accordingly.
|
||||
|
||||
- `--disable-unicode`<br />
|
||||
Specify whether or not to force the unicode disable option. When supplied, all symbols in the output will be replaced
|
||||
by their plain text equivalents.
|
||||
|
||||
- `--global-var "<global-variable-name>=<global-variable-value>"`<br />
|
||||
Allows the specification of global variables via the command line, in a key=value format. Multiple CLI global variables
|
||||
can be added by using `--global-var` multiple times, like so: `--global-var "foo=bar" --global-var "alpha=beta"`.
|
||||
|
||||
- `--env-var "<environment-variable-name>=<environment-variable-value>"`<br />
|
||||
Allows the specification of environment variables via the command line, in a key=value format. Multiple CLI environment variables
|
||||
can be added by using `--env-var` multiple times, like so: `--env-var "foo=bar" --env-var "alpha=beta"`.
|
||||
|
||||
- `--verbose`<br />
|
||||
Show detailed information of collection run and each request sent.
|
||||
|
||||
### SSL
|
||||
|
||||
#### Client Certificates
|
||||
|
||||
Client certificates are an alternative to traditional authentication mechanisms. These allow their users to make authenticated requests to a server, using a public certificate, and an optional private key that verifies certificate ownership. In some cases, the private key may also be protected by a secret passphrase, providing an additional layer of authentication security.
|
||||
|
||||
Newman supports SSL client certificates, via the following CLI options:
|
||||
|
||||
#### Using a single SSL client certificate
|
||||
- `--ssl-client-cert`<br/>
|
||||
The path to the public client certificate file.
|
||||
|
||||
- `--ssl-client-key`<br/>
|
||||
The path to the private client key (optional).
|
||||
|
||||
- `--ssl-client-passphrase`<br/>
|
||||
The secret passphrase used to protect the private client key (optional).
|
||||
|
||||
|
||||
#### Using SSL client certificates configuration file (supports multiple certificates per run)
|
||||
|
||||
- `--ssl-client-cert-list`<br/>
|
||||
The path to the SSL client certificate list configuration file (JSON format). See [examples/ssl-client-cert-list.json](https://github.com/postmanlabs/newman/blob/develop/examples/ssl-client-cert-list.json).
|
||||
|
||||
This option allows setting different SSL client certificate according to URL or hostname.
|
||||
This option takes precedence over `--ssl-client-cert`, `--ssl-client-key` and `--ssl-client-passphrase` options. If there is no match for the URL in the list, these options are used as fallback.
|
||||
|
||||
|
||||
#### Trusted CA
|
||||
|
||||
When it is not wanted to use the `--insecure` option, additionally trusted CA certificates can be provided like this:
|
||||
|
||||
- `--ssl-extra-ca-certs`<br/>
|
||||
The path to the file, that holds one or more trusted CA certificates in PEM format
|
||||
|
||||
### Configuring Proxy
|
||||
|
||||
Newman can also be configured to work with proxy settings via the following environment variables:
|
||||
|
||||
* `HTTP_PROXY` / `http_proxy`
|
||||
* `HTTPS_PROXY` / `https_proxy`
|
||||
* `NO_PROXY` / `no_proxy`
|
||||
|
||||
For more details on using these variables, [refer here](https://github.com/postmanlabs/postman-request/blob/master/README.md#controlling-proxy-behaviour-using-environment-variables).
|
||||
|
||||
[back to top](#table-of-contents)
|
||||
|
||||
## API Reference
|
||||
|
||||
### newman.run(options: _object_ , callback: _function_) => run: EventEmitter
|
||||
The `run` function executes a collection and returns the run result to a callback function provided as parameter. The
|
||||
return of the `newman.run` function is a run instance, which emits run events that can be listened to.
|
||||
|
||||
| Parameter | Description |
|
||||
|-----------|---------------|
|
||||
| options | This is a required argument and it contains all information pertaining to running a collection.<br /><br />_Required_<br />Type: `object` |
|
||||
| options.collection | The collection is a required property of the `options` argument. It accepts an object representation of a Postman Collection which should resemble the schema mentioned at [https://schema.getpostman.com/](https://schema.getpostman.com/). The value of this property could also be an instance of Collection Object from the [Postman Collection SDK](https://github.com/postmanlabs/postman-collection).<br /><br />As `string`, one can provide a URL where the Collection JSON can be found (e.g. [Postman Cloud API](https://api.getpostman.com/) service) or path to a local JSON file.<br /><br />_Required_<br />Type: `object\|string` [PostmanCollection](https://github.com/postmanlabs/postman-collection/wiki#Collection) |
|
||||
| options.environment | One can optionally pass an environment file path or URL as `string` to this property and that will be used to read Postman Environment Variables from. This property also accepts environment variables as an `object`. Environment files exported from Postman App can be directly used here.<br /><br />_Optional_<br />Type: `object\|string` |
|
||||
| options.envVar | One can optionally pass environment variables as an array of key-value string object pairs. It will be used to read Postman Environment Variables as well as overwrite environment variables from `options.environments`. <br /><br />_Optional_<br />Type: `array\|object` |
|
||||
| options.globals | Postman Global Variables can be optionally passed on to a collection run in form of path to a file or URL. It also accepts variables as an `object`.<br /><br />_Optional_<br />Type: `object\|string` |
|
||||
| options.globalVar | One can optionally pass global environment variables as an array of key-value string object pairs. It will be used to read Postman Global Environment Variables as well as overwrite global environment variables from `options.globals`. <br /><br />_Optional_<br />Type: `array\|object` |
|
||||
| options.iterationCount | Specify the number of iterations to run on the collection. This is usually accompanied by providing a data file reference as `options.iterationData`.<br /><br />_Optional_<br />Type: `number`, Default value: `1` |
|
||||
| options.iterationData | Path to the JSON or CSV file or URL to be used as data source when running multiple iterations on a collection.<br /><br />_Optional_<br />Type: `string` |
|
||||
| options.folder | The name or ID of the folder/folders (ItemGroup) in the collection which would be run instead of the entire collection.<br /><br />_Optional_<br />Type: `string\|array` |
|
||||
| options.workingDir | The path of the directory to be used as working directory.<br /><br />_Optional_<br />Type: `string`, Default value: `Current Directory` |
|
||||
| options.insecureFileRead | Allow reading files outside of working directory.<br /><br />_Optional_<br />Type: `boolean`, Default value: `true` |
|
||||
| options.timeout | Specify the time (in milliseconds) to wait for the entire collection run to complete execution.<br /><br />_Optional_<br />Type: `number`, Default value: `Infinity` |
|
||||
| options.timeoutRequest | Specify the time (in milliseconds) to wait for requests to return a response.<br /><br />_Optional_<br />Type: `number`, Default value: `Infinity` |
|
||||
| options.timeoutScript | Specify the time (in milliseconds) to wait for scripts to return a response.<br /><br />_Optional_<br />Type: `number`, Default value: `Infinity` |
|
||||
| options.delayRequest | Specify the time (in milliseconds) to wait for between subsequent requests.<br /><br />_Optional_<br />Type: `number`, Default value: `0` |
|
||||
| options.ignoreRedirects | This specifies whether newman would automatically follow 3xx responses from servers.<br /><br />_Optional_<br />Type: `boolean`, Default value: `false` |
|
||||
| options.insecure | Disables SSL verification checks and allows self-signed SSL certificates.<br /><br />_Optional_<br />Type: `boolean`, Default value: `false` |
|
||||
| options.bail | A switch to specify whether or not to gracefully stop a collection run (after completing the current test script) on encountering the first error. Takes additional modifiers as arguments to specify whether to end the run with an error for invalid name or path.<br /><br/>Available modifiers: `folder` and `failure`.<br />eg. `bail : ['folder']`<br /><br />_Optional_<br />Type: `boolean\|object`, Default value: `false` |
|
||||
| options.suppressExitCode | If present, allows overriding the default exit code from the current collection run, useful for bypassing collection result failures. Takes no arguments.<br /><br />_Optional_<br />Type: `boolean`, Default value: `false` |
|
||||
| options.reporters | Specify one reporter name as `string` or provide more than one reporter name as an `array`.<br /><br />Available reporters: `cli`, `json`, `junit`, `progress` and `emojitrain`.<br /><br />_Optional_<br />Type: `string\|array` |
|
||||
| options.reporter | Specify options for the reporter(s) declared in `options.reporters`. <br /> e.g. `reporter : { junit : { export : './xmlResults.xml' } }` <br /> e.g. `reporter : { html : { export : './htmlResults.html', template: './customTemplate.hbs' } }` <br /><br />_Optional_<br />Type: `object` |
|
||||
| options.color | Enable or Disable colored CLI output.<br/><br/>Available options: `on`, `off` and `auto`<br /><br />_Optional_<br />Type: `string`, Default value: `auto` |
|
||||
| options.sslClientCert | The path to the public client certificate file.<br /><br />_Optional_<br />Type: `string` |
|
||||
| options.sslClientKey | The path to the private client key file.<br /><br />_Optional_<br />Type: `string` |
|
||||
| options.sslClientPassphrase | The secret client key passphrase.<br /><br />_Optional_<br />Type: `string` |
|
||||
| options.sslClientCertList | The path to the client certificate configuration list file. This option takes precedence over `sslClientCert`, `sslClientKey` and `sslClientPassphrase`. When there is no match in this configuration list, `sslClientCert` is used as fallback.<br /><br />_Optional_<br />Type: `string\|array` |
|
||||
| options.sslExtraCaCerts | The path to the file, that holds one or more trusted CA certificates in PEM format.<br /><br />_Optional_<br />Type: `string` |
|
||||
| options.requestAgents | Specify the custom requesting agents to be used when performing HTTP and HTTPS requests respectively. Example: [Using Socks Proxy](#using-socks-proxy)<br /><br />_Optional_<br />Type: `object` |
|
||||
| options.cookieJar | One can optionally pass a CookieJar file path as `string` to this property and that will be deserialized using [`tough-cookie`](https://github.com/salesforce/tough-cookie). This property also accepts a `tough-cookie` CookieJar instance.<br /><br />_Optional_<br />Type: `object\|string` |
|
||||
| options.newmanVersion | The Newman version used for the collection run.<br /><br />_This will be set by Newman_ |
|
||||
| callback | Upon completion of the run, this callback is executed with the `error`, `summary` argument.<br /><br />_Required_<br />Type: `function` |
|
||||
|
||||
### newman.run~callback(error: _object_ , summary: _object_)
|
||||
|
||||
The `callback` parameter of the `newman.run` function receives two arguments: (1) `error` and (2) `summary`
|
||||
|
||||
| Argument | Description |
|
||||
|-----------|---------------|
|
||||
| error | In case newman faces an error during the run, the error is passed on to this argument of callback. By default, only fatal errors, such as the ones caused by any fault inside Newman is passed on to this argument. However, setting `abortOnError:true` or `abortOnFailure:true` as part of run options will cause newman to treat collection script syntax errors and test failures as fatal errors and be passed down here while stopping the run abruptly at that point.<br /><br />Type: `object` |
|
||||
| summary | The run summary will contain information pertaining to the run.<br /><br />Type: `object` |
|
||||
| summary.error | An error object which if exists, contains an error message describing the message <br /><br />Type: `object` |
|
||||
| summary.collection | This object contains information about the collection being run, it's requests, and their associated pre-request scripts and tests.<br /><br />Type: `object` |
|
||||
| summary.environment | An object with environment variables used for the current run, and the usage status for each of those variables.<br /><br />Type: `object` |
|
||||
| summary.globals | This object holds details about the globals used within the collection run namespace.<br /><br />Type: `object` |
|
||||
| summary.run | A cumulative run summary object that provides information on .<br /><br />Type: `object` |
|
||||
| summary.run.stats | An object which provides details about the total, failed, and pending counts for pre request scripts, tests, assertions, requests, and more.<br /><br />Type: `object` |
|
||||
| summary.run.failures | An array of failure objects, with each element holding details, including the assertion that failed, and the request.<br /><br />Type: `array.<object>` |
|
||||
| summary.run.executions | This object contains information about each request, along with it's associated activities within the scope of the current collection run.<br /><br />Type: `array.<object>` |
|
||||
|
||||
### newman.run~events
|
||||
|
||||
Newman triggers a whole bunch of events during the run.
|
||||
|
||||
```javascript
|
||||
newman.run({
|
||||
collection: require('./sample-collection.json'),
|
||||
iterationData: [{ "var": "data", "var_beta": "other_val" }],
|
||||
globals: {
|
||||
"id": "5bfde907-2a1e-8c5a-2246-4aff74b74236",
|
||||
"name": "test-env",
|
||||
"values": [
|
||||
{
|
||||
"key": "alpha",
|
||||
"value": "beta",
|
||||
"type": "text",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"timestamp": 1404119927461,
|
||||
"_postman_variable_scope": "globals",
|
||||
"_postman_exported_at": "2016-10-17T14:31:26.200Z",
|
||||
"_postman_exported_using": "Postman/4.8.0"
|
||||
},
|
||||
globalVar: [
|
||||
{ "key":"glboalSecret", "value":"globalSecretValue" },
|
||||
{ "key":"globalAnotherSecret", "value":`${process.env.GLOBAL_ANOTHER_SECRET}`}
|
||||
],
|
||||
environment: {
|
||||
"id": "4454509f-00c3-fd32-d56c-ac1537f31415",
|
||||
"name": "test-env",
|
||||
"values": [
|
||||
{
|
||||
"key": "foo",
|
||||
"value": "bar",
|
||||
"type": "text",
|
||||
"enabled": true
|
||||
}
|
||||
],
|
||||
"timestamp": 1404119927461,
|
||||
"_postman_variable_scope": "environment",
|
||||
"_postman_exported_at": "2016-10-17T14:26:34.940Z",
|
||||
"_postman_exported_using": "Postman/4.8.0"
|
||||
},
|
||||
envVar: [
|
||||
{ "key":"secret", "value":"secretValue" },
|
||||
{ "key":"anotherSecret", "value":`${process.env.ANOTHER_SECRET}`}
|
||||
],
|
||||
}).on('start', function (err, args) { // on start of run, log to console
|
||||
console.log('running a collection...');
|
||||
}).on('done', function (err, summary) {
|
||||
if (err || summary.error) {
|
||||
console.error('collection run encountered an error.');
|
||||
}
|
||||
else {
|
||||
console.log('collection run completed.');
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
All events receive two arguments (1) `error` and (2) `args`. **The list below describes the properties of the second
|
||||
argument object.**
|
||||
|
||||
| Event | Description |
|
||||
|-----------|---------------|
|
||||
| start | The start of a collection run |
|
||||
| beforeIteration | Before an iteration commences |
|
||||
| beforeItem | Before an item execution begins (the set of prerequest->request->test) |
|
||||
| beforePrerequest | Before `prerequest` script is execution starts |
|
||||
| prerequest | After `prerequest` script execution completes |
|
||||
| beforeRequest | Before an HTTP request is sent |
|
||||
| request | After response of the request is received |
|
||||
| beforeTest | Before `test` script is execution starts |
|
||||
| test | After `test` script execution completes |
|
||||
| beforeScript | Before any script (of type `test` or `prerequest`) is executed |
|
||||
| script | After any script (of type `test` or `prerequest`) is executed |
|
||||
| item | When an item (the whole set of prerequest->request->test) completes |
|
||||
| iteration | After an iteration completes |
|
||||
| assertion | This event is triggered for every test assertion done within `test` scripts |
|
||||
| console | Every time a `console` function is called from within any script, this event is propagated |
|
||||
| exception | When any asynchronous error happen in `scripts` this event is triggered |
|
||||
| beforeDone | An event that is triggered prior to the completion of the run |
|
||||
| done | This event is emitted when a collection run has completed, with or without errors |
|
||||
|
||||
<!-- TODO: write about callback summary -->
|
||||
|
||||
[back to top](#table-of-contents)
|
||||
|
||||
## Reporters
|
||||
|
||||
### Configuring Reporters
|
||||
|
||||
- `-r <reporter-name>`, `--reporters <reporter-name>`<br />
|
||||
Specify one reporter name as `string` or provide more than one reporter name as a comma separated list of reporter names. Available reporters are: `cli`, `json`, `junit`, `progress` and `emojitrain`.<br/><br/>
|
||||
Spaces should **not** be used between reporter names / commas whilst specifying a comma separated list of reporters. For instance:<br/><br/>
|
||||
:white_check_mark: `-r cli,json,junit`<br/>
|
||||
:x: `-r cli , json,junit`
|
||||
|
||||
- `--reporter-{{reporter-name}}-{{reporter-option}}`<br />
|
||||
When multiple reporters are provided, if one needs to specifically override or provide an option to one reporter, this
|
||||
is achieved by prefixing the option with `--reporter-{{reporter-name}}-`.<br /><br />
|
||||
For example, `... --reporters cli,json --reporter-cli-silent` would silence the CLI reporter only.
|
||||
|
||||
- `--reporter-{{reporter-options}}`<br />
|
||||
If more than one reporter accepts the same option name, they can be provided using the common reporter option syntax.
|
||||
<br /><br />
|
||||
For example, `... --reporters cli,json --reporter-silent` passes the `silent: true` option to both JSON and CLI
|
||||
reporter.
|
||||
|
||||
**Note:** Sample collection reports have been provided in [examples/reports](https://github.com/postmanlabs/newman/blob/develop/examples/reports).
|
||||
|
||||
### CLI Reporter
|
||||
The built-in CLI reporter supports the following options, use them with appropriate argument switch prefix. For example, the
|
||||
option `no-summary` can be passed as `--reporter-no-summary` or `--reporter-cli-no-summary`.
|
||||
|
||||
CLI reporter is enabled by default when Newman is used as a CLI, you do not need to specifically provide the same as part of `--reporters` option.
|
||||
However, enabling one or more of the other reporters will result in no CLI output. Explicitly enable the CLI option in
|
||||
such a scenario.
|
||||
|
||||
| CLI Option | Description |
|
||||
|-------------|-------------------|
|
||||
| `--reporter-cli-silent` | The CLI reporter is internally disabled and you see no output to terminal. |
|
||||
|
||||
| `--reporter-cli-show-timestamps` | This prints the local time for each request made. |
|
||||
| `--reporter-cli-no-summary` | The statistical summary table is not shown. |
|
||||
| `--reporter-cli-no-failures` | This prevents the run failures from being separately printed. |
|
||||
| `--reporter-cli-no-assertions` | This turns off the output for request-wise assertions as they happen. |
|
||||
| `--reporter-cli-no-success-assertions` | This turns off the output for successful assertions as they happen. |
|
||||
| `--reporter-cli-no-console` | This turns off the output of `console.log` (and other console calls) from collection's scripts. |
|
||||
| `--reporter-cli-no-banner` | This turns off the `newman` banner shown at the beginning of each collection run. |
|
||||
|
||||
### JSON Reporter
|
||||
The built-in JSON reporter is useful in producing a comprehensive output of the run summary. It takes the path to the
|
||||
file where to write the report. The content of this file is exactly the same as the `summary` parameter sent to the callback
|
||||
when Newman is used as a library.
|
||||
|
||||
To enable JSON reporter, provide `--reporters json` as a CLI option.
|
||||
|
||||
| CLI Option | Description |
|
||||
|-------------|-------------------|
|
||||
| `--reporter-json-export <path>` | Specify a path where the output JSON file will be written to disk. If not specified, the file will be written to `newman/` in the current working directory. If the specified path does not exist, it will be created. However, if the specified path is a pre-existing directory, the report will be generated in that directory. |
|
||||
|
||||
### JUNIT/XML Reporter
|
||||
The built-in JUnit reporter can output a summary of the collection run to a JUnit compatible XML file. To enable the JUNIT reporter, provide
|
||||
`--reporters junit` as a CLI option.
|
||||
|
||||
| CLI Option | Description |
|
||||
|-------------|-------------------|
|
||||
| `--reporter-junit-export <path>` | Specify a path where the output XML file will be written to disk. If not specified, the file will be written to `newman/` in the current working directory. If the specified path does not exist, it will be created. However, if the specified path is a pre-existing directory, the report will be generated in that directory. |
|
||||
|
||||
### HTML Reporter
|
||||
An external reporter, maintained by Postman, which can be installed via `npm install -g newman-reporter-html`. This reporter was part of the Newman project but was separated out into its own project in V4.
|
||||
|
||||
The complete installation and usage guide is available at [newman-reporter-html](https://github.com/postmanlabs/newman-reporter-html#readme). Once the HTML reporter is installed you can provide `--reporters html` as a CLI option.
|
||||
|
||||
[back to top](#table-of-contents)
|
||||
|
||||
## External Reporters
|
||||
|
||||
### Using External Reporters
|
||||
Newman also supports external reporters, provided that the reporter works with Newman's event sequence. Working examples of
|
||||
how Newman reporters work can be found in [lib/reporters](https://github.com/postmanlabs/newman/tree/develop/lib/reporters).
|
||||
|
||||
For instance, to use the [Newman HTML Reporter](https://github.com/postmanlabs/newman-reporter-html):
|
||||
|
||||
- Install the reporter package. Note that the name of the package is of the form `newman-reporter-<name>`. The installation should be global if Newman is installed globally, local otherwise. (Remove `-g` flag from the command below for a local installation.)
|
||||
```console
|
||||
$ npm install -g newman-reporter-html
|
||||
```
|
||||
|
||||
- Use the installed reporter, either via the CLI, or programmatic usage. Here, the `newman-reporter` prefix is **not** required while specifying the reporter name in the options.<br/>
|
||||
```console
|
||||
$ newman run /path/to/collection.json -r cli,html
|
||||
```
|
||||
```javascript
|
||||
const newman = require('newman');
|
||||
|
||||
newman.run({
|
||||
collection: '/path/to/collection.json',
|
||||
reporters: ['cli', 'html']
|
||||
}, process.exit);
|
||||
```
|
||||
|
||||
#### Community Maintained Reporters
|
||||
|
||||
Several members of the Postman community have created custom reporters offering different option to output the data coming from Newman. Listed below is a selection of these but more can be found [here](https://www.npmjs.com/search?q=newman-reporter) on NPM.
|
||||
|
||||
Once the custom reporter NPM package has been installed either globally or locally, this can be then used with Newman in the following ways:
|
||||
|
||||
```console
|
||||
$ newman run /path/to/collection.json -r htmlextra,csv
|
||||
```
|
||||
|
||||
```javascript
|
||||
const newman = require('newman');
|
||||
|
||||
newman.run({
|
||||
collection: '/path/to/collection.json',
|
||||
reporters: ['htmlextra', 'csv']
|
||||
}, process.exit);
|
||||
```
|
||||
|
||||
- [htmlextra](https://github.com/DannyDainton/newman-reporter-htmlextra) -
|
||||
This is an updated version of the standard HTML reporter containing a more in-depth data output and a few helpful extras
|
||||
- [csv](https://github.com/matt-ball/newman-reporter-csv) -
|
||||
This reporter creates a `csv` file containing the high level summary of the Collection run
|
||||
- [json-summary](https://github.com/spenceclark/newman-reporter-json-summary) -
|
||||
A Newman JSON Reporter that strips the results down to a minimum
|
||||
- [teamcity](https://github.com/leafle/newman-reporter-teamcity) -
|
||||
A reporter built to be used with the [Team City](https://www.jetbrains.com/teamcity/) CI server
|
||||
- [testrail](https://github.com/billylam/newman-reporter-testrail) -
|
||||
A reporter built for [Test Rail](https://www.gurock.com/testrail/), the test case management tool
|
||||
- [statsd](https://github.com/gsorry/newman-reporter-statsd) -
|
||||
This reporter can be used to send the Collection run data to `statsd` and used on time series analytic tools like [Grafana](https://grafana.com/)
|
||||
- [confluence](https://github.com/OmbraDiFenice/newman-reporter-confluence) -
|
||||
Confluence reporter for Newman that uploads a Newman report on a Confluence page
|
||||
- [influxdb](https://github.com/vs4vijay/newman-reporter-influxdb) -
|
||||
This reporter sends the test results information to InfluxDB which can be used from [Grafana](https://grafana.com/) to build dashboards
|
||||
|
||||
### Creating Your Own Reporter
|
||||
A custom reporter is a Node module with a name of the form `newman-reporter-<name>`. To create a custom reporter:
|
||||
1. Navigate to a directory of your choice, and create a blank npm package with `npm init`.
|
||||
2. Add an `index.js` file, that exports a function of the following form:
|
||||
```javascript
|
||||
function CustomNewmanReporter (emitter, reporterOptions, collectionRunOptions) {
|
||||
// emitter is an event emitter that triggers the following events: https://github.com/postmanlabs/newman#newmanrunevents
|
||||
// reporterOptions is an object of the reporter specific options. See usage examples below for more details.
|
||||
// collectionRunOptions is an object of all the collection run options: https://github.com/postmanlabs/newman#newmanrunoptions-object--callback-function--run-eventemitter
|
||||
}
|
||||
module.exports = CustomNewmanReporter
|
||||
```
|
||||
3. To use your reporter locally, use the `npm pack` command to create a `.tgz` file. Once created, this can be installed using the `npm i -g newman-reporter-<name>.<version>.tgz` command.
|
||||
|
||||
Once you're happy with your reporter, it can be published to `npm` using `npm publish`. This will then be made available for other people to download.
|
||||
|
||||
Scoped reporter package names like `@myorg/newman-reporter-<name>` are also supported. Working reporter examples can be found in [lib/reporters](lib/reporters).
|
||||
|
||||
[back to top](#table-of-contents)
|
||||
|
||||
## File uploads
|
||||
|
||||
Newman also supports file uploads for request form data. The files must be present in the
|
||||
current working directory. Your collection must also contain the filename in
|
||||
the "src" attribute of the request.
|
||||
|
||||
In this collection, `sample-file.txt` should be present in the current working directory.
|
||||
```json
|
||||
{
|
||||
"info": {
|
||||
"name": "file-upload"
|
||||
},
|
||||
"item": [
|
||||
{
|
||||
"request": {
|
||||
"url": "https://postman-echo.com/post",
|
||||
"method": "POST",
|
||||
"body": {
|
||||
"mode": "formdata",
|
||||
"formdata": [
|
||||
{
|
||||
"key": "file",
|
||||
"type": "file",
|
||||
"enabled": true,
|
||||
"src": "sample-file.txt"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
```console
|
||||
$ ls
|
||||
file-upload.postman_collection.json sample-file.txt
|
||||
|
||||
$ newman run file-upload.postman_collection.json
|
||||
```
|
||||
|
||||
[back to top](#table-of-contents)
|
||||
|
||||
## Using Newman with the Postman API
|
||||
|
||||
1 [Generate an API key](https://app.getpostman.com/dashboard/integrations)<br/>
|
||||
2 Fetch a list of your collections from: `https://api.getpostman.com/collections?apikey=$apiKey`<br/>
|
||||
3 Get the collection link via it's `uid`: `https://api.getpostman.com/collections/$uid?apikey=$apiKey`<br/>
|
||||
4 Obtain the environment URI from: `https://api.getpostman.com/environments?apikey=$apiKey`<br/>
|
||||
5 Using the collection and environment URIs acquired in steps 3 and 4, run the collection as follows:
|
||||
```console
|
||||
$ newman run "https://api.getpostman.com/collections/$uid?apikey=$apiKey" \
|
||||
--environment "https://api.getpostman.com/environments/$uid?apikey=$apiKey"
|
||||
```
|
||||
|
||||
[back to top](#table-of-contents)
|
||||
|
||||
## Using Newman in Docker
|
||||
To use Newman in Docker check our [docker documentation](https://learning.postman.com/docs/postman/collection-runs/newman-with-docker/).
|
||||
|
||||
## Using Socks Proxy
|
||||
|
||||
When using Newman as a library, you can pass a custom HTTP(S) agent which will be used for making the requests. Here's an example of how to setup socks proxy using a custom agent.
|
||||
|
||||
```js
|
||||
const newman = require('newman');
|
||||
const SocksProxyAgent = require('socks-proxy-agent');
|
||||
const requestAgent = new SocksProxyAgent({ host: 'localhost', port: '1080' });
|
||||
|
||||
newman.run({
|
||||
collection: require('./sample-collection.json'),
|
||||
requestAgents: {
|
||||
http: requestAgent, // agent used for HTTP requests
|
||||
https: requestAgent, // agent used for HTTPS requests
|
||||
}
|
||||
}, function (err) {
|
||||
if (err) { throw err; }
|
||||
console.log('collection run complete!');
|
||||
});
|
||||
```
|
||||
|
||||
[back to top](#table-of-contents)
|
||||
|
||||
## Migration Guide
|
||||
|
||||
- [Newman v4 to v5 Migration Guide](MIGRATION.md)
|
||||
- [Newman v4.x Documentation](https://github.com/postmanlabs/newman/blob/release/4.x/README.md)
|
||||
|
||||
|
||||
## Compatibility
|
||||
|
||||
### NodeJS
|
||||
|
||||
| Newman | Node |
|
||||
|:-----------------:|:----------:|
|
||||
| v3.x | >= v4.x |
|
||||
| v4.x | >= v6.x |
|
||||
| v5.x | >= v10.x |
|
||||
|
||||
The current Node version compatibility can also be seen from the `engines.node` property in [package.json](https://github.com/postmanlabs/newman/blob/develop/package.json)
|
||||
|
||||
### File Encoding
|
||||
|
||||
Newman attempts to detect file encoding for files that are provided as
|
||||
command line input. However, it mostly relies on NodeJS and the underlying
|
||||
operating system to do the heavy lifting. Currently, `ASCII`, `UTF-8`, `UTF-16LE`
|
||||
and `ISO-8859-1` are the only ones that are detection assisted.
|
||||
|
||||
[back to top](#table-of-contents)
|
||||
|
||||
## Contributing
|
||||
Please take a moment to read our [contributing guide](.github/CONTRIBUTING.md) to learn about our development process.
|
||||
Open an [issue](https://github.com/postmanlabs/newman/issues) first to discuss potential changes/additions.
|
||||
|
||||
## Community Support
|
||||
|
||||
<img src="https://avatars1.githubusercontent.com/u/3220138?v=3&s=120" align="right" />
|
||||
If you are interested in talking to the Postman team and fellow Newman users, you can find us on our <a href="https://community.postman.com">Postman Community Forum</a>. Feel free to drop by and say hello. You'll find us posting about upcoming features and beta releases, answering technical support questions, and contemplating world peace.
|
||||
|
||||
Sign in using your Postman account to participate in the discussions and don't forget to take advantage of the <a href="https://community.postman.com/search?q=newman">search bar</a> - the answer to your question might already be waiting for you! Don’t want to log in? Then lurk on the sidelines and absorb all the knowledge.
|
||||
|
||||
|
||||
## License
|
||||
This software is licensed under Apache-2.0. Copyright Postdot Technologies, Inc. See the [LICENSE.md](LICENSE.md) file for more information.
|
||||
|
||||
[](https://postman.com)
|
14
node_modules/newman/SECURITY.md
generated
vendored
Normal file
14
node_modules/newman/SECURITY.md
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# Security Policy
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
If you've found a vulnerability in our service or website, or want additional information regarding how we manage security, please send an email to security@postman.com. We will review it and respond to you within 24 hours. Please use our [PGP public key](https://assets.getpostman.com/getpostman/documents/publickey.txt) to encrypt your communications with us.
|
||||
|
||||
If you are a security researcher, please go through the following points for reporting security issues.
|
||||
|
||||
- Mail to security@postman.com and express interest along with a short summary of the nature of issue you want to report.
|
||||
- We will triage and add your email address to our internal security tracker.
|
||||
- Subsequently you can report your security issues directly using the tracker.
|
||||
|
||||
|
||||
> Read our [security reporting guidelines and policy](https://www.postman.com/vulnerability-reporting) for more details.
|
150
node_modules/newman/bin/newman.js
generated
vendored
Normal file
150
node_modules/newman/bin/newman.js
generated
vendored
Normal file
@@ -0,0 +1,150 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('../lib/node-version-check'); // @note that this should not respect CLI --silent
|
||||
|
||||
const _ = require('lodash'),
|
||||
waterfall = require('async/waterfall'),
|
||||
{ Command } = require('commander'),
|
||||
program = new Command(),
|
||||
version = require('../package.json').version,
|
||||
newman = require('../'),
|
||||
util = require('./util');
|
||||
|
||||
program
|
||||
.name('newman')
|
||||
.addHelpCommand(false)
|
||||
.version(version, '-v, --version');
|
||||
|
||||
// The `run` command allows you to specify a collection to be run with the provided options.
|
||||
program
|
||||
.command('run <collection>')
|
||||
.description('Initiate a Postman Collection run from a given URL or path')
|
||||
.usage('<collection> [options]')
|
||||
.option('-e, --environment <path>', 'Specify a URL or path to a Postman Environment')
|
||||
.option('-g, --globals <path>', 'Specify a URL or path to a file containing Postman Globals')
|
||||
.option('-r, --reporters [reporters]', 'Specify the reporters to use for this run', util.cast.csvParse, ['cli'])
|
||||
.option('-n, --iteration-count <n>', 'Define the number of iterations to run', util.cast.integer)
|
||||
.option('-d, --iteration-data <path>', 'Specify a data file to use for iterations (either JSON or CSV)')
|
||||
.option('--folder <path>',
|
||||
'Specify the folder to run from a collection. Can be specified multiple times to run multiple folders',
|
||||
util.cast.memoize, [])
|
||||
.option('--global-var <value>',
|
||||
'Allows the specification of global variables via the command line, in a key=value format',
|
||||
util.cast.memoizeKeyVal, [])
|
||||
.option('--env-var <value>',
|
||||
'Allows the specification of environment variables via the command line, in a key=value format',
|
||||
util.cast.memoizeKeyVal, [])
|
||||
.option('--export-environment <path>', 'Exports the final environment to a file after completing the run')
|
||||
.option('--export-globals <path>', 'Exports the final globals to a file after completing the run')
|
||||
.option('--export-collection <path>', 'Exports the executed collection to a file after completing the run')
|
||||
.option('--postman-api-key <apiKey>', 'API Key used to load the resources from the Postman API')
|
||||
.option('--bail [modifiers]',
|
||||
'Specify whether or not to gracefully stop a collection run on encountering an error' +
|
||||
' and whether to end the run with an error based on the optional modifier', util.cast.csvParse)
|
||||
.option('--ignore-redirects', 'Prevents Newman from automatically following 3XX redirect responses')
|
||||
.option('-x , --suppress-exit-code', 'Specify whether or not to override the default exit code for the current run')
|
||||
.option('--silent', 'Prevents Newman from showing output to CLI')
|
||||
.option('--disable-unicode', 'Forces Unicode compliant symbols to be replaced by their plain text equivalents')
|
||||
.option('--color <value>', 'Enable/Disable colored output (auto|on|off)', util.cast.colorOptions, 'auto')
|
||||
.option('--delay-request [n]', 'Specify the extent of delay between requests (milliseconds)', util.cast.integer, 0)
|
||||
.option('--timeout [n]', 'Specify a timeout for collection run (milliseconds)', util.cast.integer, 0)
|
||||
.option('--timeout-request [n]', 'Specify a timeout for requests (milliseconds)', util.cast.integer, 0)
|
||||
.option('--timeout-script [n]', 'Specify a timeout for scripts (milliseconds)', util.cast.integer, 0)
|
||||
.option('--working-dir <path>', 'Specify the path to the working directory')
|
||||
.option('--no-insecure-file-read', 'Prevents reading the files situated outside of the working directory')
|
||||
.option('-k, --insecure', 'Disables SSL validations')
|
||||
.option('--ssl-client-cert-list <path>', 'Specify the path to a client certificates configurations (JSON)')
|
||||
.option('--ssl-client-cert <path>', 'Specify the path to a client certificate (PEM)')
|
||||
.option('--ssl-client-key <path>', 'Specify the path to a client certificate private key')
|
||||
.option('--ssl-client-passphrase <passphrase>', 'Specify the client certificate passphrase (for protected key)')
|
||||
.option('--ssl-extra-ca-certs <path>', 'Specify additionally trusted CA certificates (PEM)')
|
||||
.option('--cookie-jar <path>', 'Specify the path to a custom cookie jar (serialized tough-cookie JSON) ')
|
||||
.option('--export-cookie-jar <path>', 'Exports the cookie jar to a file after completing the run')
|
||||
.option('--verbose', 'Show detailed information of collection run and each request sent')
|
||||
.action((collection, command) => {
|
||||
let options = util.commanderToObject(command),
|
||||
|
||||
// parse custom reporter options
|
||||
reporterOptions = util.parseNestedOptions(program._originalArgs, '--reporter-', options.reporters);
|
||||
|
||||
// Inject additional properties into the options object
|
||||
options.collection = collection;
|
||||
options.reporterOptions = reporterOptions._generic;
|
||||
options.reporter = _.transform(_.omit(reporterOptions, '_generic'), (acc, value, key) => {
|
||||
acc[key] = _.assignIn(value, reporterOptions._generic); // overrides reporter options with _generic
|
||||
}, {});
|
||||
|
||||
newman.run(options, function (err, summary) {
|
||||
const runError = err || summary.run.error || summary.run.failures.length;
|
||||
|
||||
if (err) {
|
||||
console.error(`error: ${err.message || err}\n`);
|
||||
err.friendly && console.error(` ${err.friendly}\n`);
|
||||
}
|
||||
runError && !_.get(options, 'suppressExitCode') && process.exit(1);
|
||||
});
|
||||
});
|
||||
|
||||
program.addHelpText('after', `
|
||||
To get available options for a command:
|
||||
newman <command> -h`);
|
||||
|
||||
// Warn on invalid command and then exits.
|
||||
program.on('command:*', (command) => {
|
||||
console.error(`error: invalid command \`${command}\`\n`);
|
||||
program.help();
|
||||
});
|
||||
|
||||
/**
|
||||
* Starts the script execution.
|
||||
* callback is required when this is required as a module in tests.
|
||||
*
|
||||
* @param {String[]} argv - Argument vector.
|
||||
* @param {?Function} callback - The callback function invoked on the completion of execution.
|
||||
*/
|
||||
function run (argv, callback) {
|
||||
waterfall([
|
||||
(next) => {
|
||||
// cache original argv, required to parse nested options later.
|
||||
program._originalArgs = argv;
|
||||
// omit custom nested options, otherwise commander will throw unknown options error
|
||||
next(null, util.omitNestedOptions(argv, '--reporter-'));
|
||||
},
|
||||
(args, next) => {
|
||||
let error = null;
|
||||
|
||||
try {
|
||||
program.parse(args);
|
||||
}
|
||||
catch (err) {
|
||||
error = err;
|
||||
}
|
||||
next(error);
|
||||
},
|
||||
(next) => {
|
||||
// throw error if no argument is provided.
|
||||
next(program.args.length ? null : new Error('no arguments provided'));
|
||||
}
|
||||
], (error) => {
|
||||
// invoke callback if this is required as module, used in tests.
|
||||
if (callback) { return callback(error); }
|
||||
|
||||
// in case of an error, log error message and print help message.
|
||||
if (error) {
|
||||
console.error(`error: ${error.message || error}\n`);
|
||||
program.help();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// This hack has been added from https://github.com/nodejs/node/issues/6456#issue-151760275
|
||||
// @todo: remove when https://github.com/nodejs/node/issues/6456 has been fixed
|
||||
(Number(process.version[1]) >= 6) && [process.stdout, process.stderr].forEach((s) => {
|
||||
s && s.isTTY && s._handle && s._handle.setBlocking && s._handle.setBlocking(true);
|
||||
});
|
||||
|
||||
// Run this script if this is a direct stdin.
|
||||
!module.parent && run(process.argv);
|
||||
|
||||
// Export to allow debugging and testing.
|
||||
module.exports = run;
|
203
node_modules/newman/bin/util.js
generated
vendored
Normal file
203
node_modules/newman/bin/util.js
generated
vendored
Normal file
@@ -0,0 +1,203 @@
|
||||
const _ = require('lodash');
|
||||
|
||||
module.exports = {
|
||||
|
||||
cast: {
|
||||
/**
|
||||
* Helper to coerce number like strings into integers.
|
||||
* Perform safety checks, and return the result.
|
||||
*
|
||||
* @param {String} arg - The stringified number argument.
|
||||
* @returns {Number} - The supplied argument, casted to an integer.
|
||||
*/
|
||||
integer: (arg) => {
|
||||
const num = Number(arg);
|
||||
|
||||
if (!_.isSafeInteger(num) || num <= 0) {
|
||||
throw new Error('The value must be a positive integer.');
|
||||
}
|
||||
|
||||
return num.valueOf();
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper for collecting argument passed multiple times.
|
||||
*
|
||||
* --folder f1 --folder f2
|
||||
*
|
||||
* @param {String} val - The argument value.
|
||||
* @param {String[]} memo - The array that is populated by argument values.
|
||||
* @returns {String[]} - The array of argument values collected.
|
||||
*/
|
||||
memoize: (val, memo) => {
|
||||
memo.push(val);
|
||||
|
||||
return memo;
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper for collecting argument passed multiple times as key=value.
|
||||
*
|
||||
* --global-var "foo=bar" --global-var "alpha=beta"
|
||||
*
|
||||
* @param {String} val - The argument value, passed as key=value.
|
||||
* @param {Array} memo - The array that is populated by key value pairs.
|
||||
* @returns {Array} - [{key, value}] - The object representation of the current CLI variable.
|
||||
*/
|
||||
memoizeKeyVal: (val, memo) => {
|
||||
let arg,
|
||||
eqIndex = val.indexOf('=');
|
||||
|
||||
// This is done instead of splitting by `=` to avoid chopping off `=` that could be present in the value
|
||||
arg = eqIndex !== -1 ? {
|
||||
key: val.slice(0, eqIndex),
|
||||
value: val.slice(eqIndex + 1)
|
||||
} : {
|
||||
key: val,
|
||||
value: undefined
|
||||
};
|
||||
|
||||
memo.push(arg);
|
||||
|
||||
return memo;
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper to coerce comma separated string to an array.
|
||||
*
|
||||
* eg. item1,item2
|
||||
*
|
||||
* @param {String} list - The comma separated string.
|
||||
* @returns {String[]} - [item1, item2] - The array representation of the passed string.
|
||||
*/
|
||||
csvParse: (list) => {
|
||||
return _.split(list, ',');
|
||||
},
|
||||
|
||||
colorOptions: (value) => {
|
||||
if (!(/^(auto|on|off)$/).test(value)) {
|
||||
throw new Error(`invalid value \`${value}\` for --color. Expected: auto|on|off`);
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Extract selected options in the provided command.
|
||||
* Omits commander private variables and other objects.
|
||||
*
|
||||
* @param {Object} command - Commander.Command Instance
|
||||
* @returns {Object} - Extracted options from command
|
||||
*/
|
||||
commanderToObject: (command) => {
|
||||
return _.reduce(command, (result, value, key) => {
|
||||
// Exclude command's private `_` variables and other objects
|
||||
const validProp = !_.startsWith(key, '_') && !_.includes(['commands', 'options', 'parent'], key);
|
||||
|
||||
validProp && (result[key] = value);
|
||||
|
||||
return result;
|
||||
}, {});
|
||||
},
|
||||
|
||||
/**
|
||||
* Remove nested options having the provided prefix from `process.argv`.
|
||||
*
|
||||
* @param {String[]} argv - Argument vector.
|
||||
* @param {String} optionPrefix - Argument prefix to search for.
|
||||
* @returns {String[]} - All arguments without prefixed options and their values
|
||||
*/
|
||||
omitNestedOptions: (argv, optionPrefix) => {
|
||||
let args = [],
|
||||
len,
|
||||
i;
|
||||
|
||||
for (i = 0, len = argv.length; i < len; i++) {
|
||||
if (!_.startsWith(argv[i], optionPrefix)) {
|
||||
args.push(argv[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
// For prefixed args also omit its value, --prefix-arg value
|
||||
if (argv[i + 1] && !_.startsWith(argv[i + 1], '-')) {
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
return args;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse nested options having the provided prefix from `process.argv`.
|
||||
*
|
||||
* @param {String[]} argv - Argument vector.
|
||||
* @param {String} optionPrefix - Argument prefix to search for.
|
||||
* @param {String[]} options - Selected options.
|
||||
* @returns {Object} Parsed object with nested options.
|
||||
*
|
||||
* @example
|
||||
* let argv = ['--reporters=json,html', '--reporter-html-template=template.hb', '--reporter-export=path'],
|
||||
* options = ['json', 'html'];
|
||||
* parseNestedOptions(argv, '--reporter-', options);
|
||||
* //returns
|
||||
* {
|
||||
* _generic: { export: path },
|
||||
* html: { template: template.hb },
|
||||
* json: {}
|
||||
* }
|
||||
*
|
||||
*/
|
||||
parseNestedOptions: (argv, optionPrefix, options) => {
|
||||
let args = [],
|
||||
parsed = { _generic: {} },
|
||||
name,
|
||||
path,
|
||||
len,
|
||||
eqIndex,
|
||||
i;
|
||||
|
||||
// Extract prefixed arguments from argv
|
||||
for (i = 0, len = argv.length; i < len; i++) {
|
||||
const arg = argv[i];
|
||||
|
||||
if (!_.startsWith(arg, optionPrefix)) { continue; } // skip non-prefixed args
|
||||
|
||||
eqIndex = arg.indexOf('=');
|
||||
|
||||
if (eqIndex !== -1) {
|
||||
// Split the attribute if its like key=value
|
||||
args.push(arg.slice(0, eqIndex), arg.slice(eqIndex + 1));
|
||||
}
|
||||
else if (argv[i + 1] && !_.startsWith(argv[i + 1], '-')) {
|
||||
// Also push the next parameter if it's not an option.
|
||||
args.push(arg, argv[++i]);
|
||||
}
|
||||
else {
|
||||
args.push(arg);
|
||||
}
|
||||
}
|
||||
|
||||
// ensure that whatever option is provided a blank options object is forwarded
|
||||
_.forEach(options, (option) => { parsed[option] = {}; });
|
||||
// Parse nested options
|
||||
for (i = 0, len = args.length; i < len; i++) {
|
||||
const arg = args[i].replace(optionPrefix, '');
|
||||
|
||||
name = _.split(arg, '-', 1)[0]; // eg. `cli` in --reporter-cli-silent
|
||||
|
||||
// if we have a valid option, the path should be the <name>.camelCaseOfTheRest
|
||||
// otherwise, we add it to the generic options.
|
||||
path = _.includes(options, name) ?
|
||||
[name, _.camelCase(arg.replace(name + '-', ''))].join('.') :
|
||||
['_generic', _.camelCase(arg)].join('.');
|
||||
|
||||
// If the next arg is an option, set the current arg to true,
|
||||
// otherwise set it to the next arg.
|
||||
_.set(parsed, path, (!args[i + 1] || _.startsWith(args[i + 1], '-')) ? true : args[++i]);
|
||||
}
|
||||
|
||||
return parsed;
|
||||
}
|
||||
|
||||
};
|
184
node_modules/newman/docker/README.md
generated
vendored
Normal file
184
node_modules/newman/docker/README.md
generated
vendored
Normal file
@@ -0,0 +1,184 @@
|
||||
<img src="https://s3.amazonaws.com/web-artefacts/cartoon-whale-8.gif+(400%C3%97225).png">
|
||||
|
||||
# newman-docker
|
||||
|
||||
This repository contains docker images for Newman.
|
||||
|
||||
<a href="https://github.com/postmanlabs/newman" target="_blank">Newman</a> is a command-line collection runner for
|
||||
<a href="https://postman.com" target="_blank">Postman</a>. It allows you to effortlessly run and test a
|
||||
<a href="https://learning.postman.com/docs/sending-requests/intro-to-collections" target="_blank">Postman Collections<a/> directly from the
|
||||
command-line. It is built with extensibility in mind so that you can easily integrate it with your continuous
|
||||
integration servers and build systems.
|
||||
|
||||
**New to Docker?** Docker allows you to package an application with all of its dependencies into a standardised unit for
|
||||
software development. Visit
|
||||
<a href="https://www.docker.com/whatisdocker" target="_blank">https://www.docker.com/whatisdocker</a> to read more about
|
||||
how docker can drastically simplify development and deployment.
|
||||
|
||||
## There are four available Docker images for Newman
|
||||
### postman/newman:alpine (lightweight):
|
||||
* <a href="https://hub.docker.com/r/postman/newman/">DockerHub</a>
|
||||
* <a href="https://github.com/postmanlabs/newman/tree/develop/docker/images/alpine">Documentation</a>
|
||||
|
||||
### postman/newman:ubuntu:
|
||||
* <a href="https://hub.docker.com/r/postman/newman/">DockerHub</a>
|
||||
* <a href="https://github.com/postmanlabs/newman/tree/develop/docker/images/ubuntu">Documentation</a>
|
||||
|
||||
### postman/newman_alpine33 (lightweight, deprecated):
|
||||
* <a href="https://hub.docker.com/r/postman/newman_alpine33/">DockerHub</a>
|
||||
* <a href="https://github.com/postmanlabs/newman/tree/develop/docker/images/alpine33">Documentation</a>
|
||||
|
||||
### postman/newman_ubuntu1404 (deprecated):
|
||||
* <a href="https://hub.docker.com/r/postman/newman_ubuntu1404/">DockerHub</a>
|
||||
* <a href="https://github.com/postmanlabs/newman/tree/develop/docker/images/ubuntu1404">Documentation</a>
|
||||
|
||||
### Note:
|
||||
The Docker images postman/newman_alpine33 and postman/newman_ubuntu1404 for Newman are deprecated. It is advised to use [postman/newman](https://hub.docker.com/r/postman/newman/) instead.
|
||||
|
||||
## Using the docker image
|
||||
|
||||
The docker image for Newman is available for download from our docker hub. You must have Docker installed in your
|
||||
system. Docker has extensive <a href="https://docs.docker.com/installation/" target="_blank">installation guideline for
|
||||
popular operating systems</a>. Choose your operating system and follow the instructions.
|
||||
|
||||
> Ensure you that you have docker installed and running in your system before proceeding with next steps. A quick test
|
||||
> to see if docker is installed correctly is to execute the command `docker run hello-world` and it should run without
|
||||
> errors.
|
||||
|
||||
**Step 1:**
|
||||
|
||||
Pull the <a href="https://registry.hub.docker.com/u/postman/newman:ubuntu/" target="_blank">newman docker
|
||||
image</a> from docker hub:
|
||||
|
||||
```terminal
|
||||
docker pull postman/newman:ubuntu
|
||||
```
|
||||
|
||||
**Step 2:**
|
||||
|
||||
Run newman commands on the image:
|
||||
|
||||
```terminal
|
||||
docker run -t postman/newman:ubuntu run https://www.getpostman.com/collections/8a0c9bc08f062d12dcda
|
||||
```
|
||||
|
||||
### Build the docker image from this repository
|
||||
|
||||
|
||||
**Step 1:**
|
||||
|
||||
Clone this repository:
|
||||
|
||||
```terminal
|
||||
git clone https://github.com/postmanlabs/newman.git
|
||||
```
|
||||
|
||||
**Step 2:**
|
||||
|
||||
Build the image:
|
||||
|
||||
```terminal
|
||||
docker build -t postman/newman:ubuntu --build-arg NEWMAN_VERSION="full semver version" .;
|
||||
```
|
||||
|
||||
**Step 3:**
|
||||
|
||||
Run a collection using the newman image:
|
||||
|
||||
```terminal
|
||||
docker run -t postman/newman:ubuntu run https://www.getpostman.com/collections/8a0c9bc08f062d12dcda
|
||||
```
|
||||
|
||||
|
||||
## Running local collection files
|
||||
|
||||
This docker image is designed to pick files from the `/etc/newman` directory within the image. You may mount the
|
||||
directory of your collection files into that location and provide the file references in standard newman parameters.
|
||||
|
||||
|
||||
```terminal
|
||||
# Mount host collections folder ~/collections, onto /etc/newman on the docker image, so that newman
|
||||
# has access to collections
|
||||
docker run -v ~/collections:/etc/newman -t postman/newman:ubuntu run "HTTPBinNewmanTestNoEnv.json.postman_collection"
|
||||
```
|
||||
|
||||
You are not required to mount a volume if you do not need to save newman report to the host, and your collection is
|
||||
available online, unless your collection requires an environment(as environments cannot be passed as URLs).
|
||||
|
||||
To know more about mounting volumes, visit
|
||||
<a href="https://docs.docker.com/userguide/dockervolumes/" target="_blank">docker documentation on shared data volumes</a>.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
Run a local collection, pass an environment to it, and save the JSON report on the host.
|
||||
|
||||
```terminal
|
||||
docker run -v ~/collections:/etc/newman -t postman/newman:ubuntu \
|
||||
run "HTTPBinNewmanTest.json.postman_collection" \
|
||||
--environment="HTTPBinNewmanTestEnv.json.postman_environment" \
|
||||
--reporters="json,cli" --reporter-json-export="newman-results.json"
|
||||
```
|
||||
|
||||
<br />Run a remote collection, pass it a local environment, and save JUnit XML test report on the host
|
||||
|
||||
```terminal
|
||||
docker run -v ~/collections:/etc/newman -t postman/newman:ubuntu \
|
||||
run https://www.getpostman.com/collections/8a0c9bc08f062d12dcda \
|
||||
--environment="HTTPBinNewmanTestEnv.json.postman_environment" \
|
||||
--reporters="junit,cli" --reporter-junit-export="newman-report.xml"
|
||||
```
|
||||
|
||||
<br />Use a script to run a collection and do something, for example deploy the build, if all the tests pass
|
||||
|
||||
```bash
|
||||
#/bin/bash
|
||||
|
||||
# stop on first error
|
||||
set -e;
|
||||
|
||||
function onExit {
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "Tests failed";
|
||||
# build failed, don't deploy
|
||||
exit 1;
|
||||
else
|
||||
echo "Tests passed";
|
||||
# deploy build
|
||||
fi
|
||||
}
|
||||
|
||||
# call onExit when the script exits
|
||||
trap onExit EXIT;
|
||||
|
||||
docker run --entrypoint -t postman/newman:ubuntu run https://www.getpostman.com/collections/8a0c9bc08f062d12dcda --suppress-exit-code;
|
||||
```
|
||||
|
||||
## Using Newman Docker images with custom reporters
|
||||
Newman Docker images can also be used with custom Newman reporters, as follows:
|
||||
```console
|
||||
docker run -v "<collection-directory>:/etc/newman" --entrypoint /bin/<bash-or-sh> <image:tag> -c "npm i -g newman-reporter-<reporter-name>; newman run sample-collection.json -r <reporter-name>"
|
||||
```
|
||||
|
||||
In the above example,
|
||||
* `<collection-directory>` is the source directory for collections. This directory will also be used to write Newman reports.
|
||||
* `<image>` is a combination of the image name (and optional tag). For instance, `postman/newman:ubuntu` or `postman/newman:alpine`
|
||||
* `<reporter-name>` is the reporter that has to be installed and loaded for the `newman run ...`
|
||||
|
||||
### Alpine
|
||||
Note that the entrypoint here is `/bin/sh`, and **not** `/bin/bash`
|
||||
```console
|
||||
docker run -v "~/collections:/etc/newman" --entrypoint /bin/sh postman/newman:alpine -c "npm i -g newman-reporter-html; newman run sample-collection.json -r html"
|
||||
```
|
||||
|
||||
### Ubuntu
|
||||
```console
|
||||
docker run -v "~/collections:/etc/newman" --entrypoint /bin/bash postman/newman:ubuntu -c "npm i -g newman-reporter-html; newman run sample-collection.json -r html"
|
||||
```
|
||||
|
||||
## Node version
|
||||
All official Newman Docker images will be shipped with the current Node LTS (Long Term Support) version. To learn more
|
||||
about the Node release schedule, see https://github.com/nodejs/Release#release-schedule. More details about individual
|
||||
Docker images can be found in their individual READMEs in this folder.
|
||||
|
||||
[](https://postman.com)
|
33
node_modules/newman/docker/images/alpine/Dockerfile
generated
vendored
Normal file
33
node_modules/newman/docker/images/alpine/Dockerfile
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
FROM node:10-alpine
|
||||
LABEL maintainer="Postman Labs <help@postman.com>"
|
||||
|
||||
ARG NEWMAN_VERSION
|
||||
|
||||
# Set environment variables
|
||||
ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8" ALPINE_NODE_REPO="oznu/alpine-node"
|
||||
|
||||
# Bail out early if NODE_VERSION is not provided
|
||||
RUN if [ ! $(echo $NEWMAN_VERSION | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+$") ]; then \
|
||||
echo "\033[0;31mA valid semver Newman version is required in the NEWMAN_VERSION build-arg\033[0m"; \
|
||||
exit 1; \
|
||||
fi && \
|
||||
# Install Newman globally
|
||||
npm install --global newman@${NEWMAN_VERSION};
|
||||
|
||||
# Set workdir to /etc/newman
|
||||
# When running the image, mount the directory containing your collection to this location
|
||||
#
|
||||
# docker run -v <path to collections directory>:/etc/newman ...
|
||||
#
|
||||
# In case you mount your collections directory to a different location, you will need to give absolute paths to any
|
||||
# collection, environment files you want to pass to newman, and if you want newman reports to be saved to your disk.
|
||||
# Or you can change the workdir by using the -w or --workdir flag
|
||||
WORKDIR /etc/newman
|
||||
|
||||
# Set newman as the default container command
|
||||
# Now you can run the container via
|
||||
#
|
||||
# docker run -v /home/collections:/etc/newman -t postman/newman_alpine run YourCollection.json.postman_collection \
|
||||
# -e YourEnvironment.postman_environment \
|
||||
# -H newman_report.html
|
||||
ENTRYPOINT ["newman"]
|
38
node_modules/newman/docker/images/alpine/README.md
generated
vendored
Normal file
38
node_modules/newman/docker/images/alpine/README.md
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# newman:alpine
|
||||
|
||||
This image runs newman on node v10 on Alpine
|
||||
|
||||
Build the image:
|
||||
|
||||
```terminal
|
||||
docker build -t postman/newman:alpine --build-arg NEWMAN_VERSION="full semver version" .
|
||||
```
|
||||
|
||||
Or get it from [Docker Hub](https://registry.hub.docker.com/u/postman/newman/):
|
||||
|
||||
```terminal
|
||||
docker pull postman/newman:alpine
|
||||
```
|
||||
|
||||
Then run it:
|
||||
|
||||
```terminal
|
||||
docker --volume="/home/postman/collections:/etc/newman" -t postman/newman:alpine run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
For newman-docker to be able to use collections and environment files saved on the host machine, and to save reports generated by newman, a directory containing the collection and environment needs to be mounted on to the docker instance on run time, preferably at `/etc/newman`, which is the default working directory. If you mount to a different location, then:
|
||||
- You can pass the full path to your collection and environment files to newman. For instance, if you mount to `/etc/newman`,
|
||||
|
||||
```terminal
|
||||
docker --volume="/home/postman/collection:/etc/newman" -t postman/newman:alpine run JSONBlobCoreAPI.json.postman_collection" -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
- You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag.
|
||||
|
||||
```terminal
|
||||
docker run --volume="/home/postman/collections:/etc/newman" -t postman/newman:alpine run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
|
||||
In case you don't need to save newman's report to the host, and your collection is available online and does not require any environment, then you can forgo mounting your collections directory and directly pass the collection URL to newman:
|
||||
|
||||
```terminal
|
||||
docker run -t postman/newman:alpine run https://www.getpostman.com/collections/8a0c9bc08f062d12dcda
|
||||
```
|
48
node_modules/newman/docker/images/alpine33/Dockerfile
generated
vendored
Normal file
48
node_modules/newman/docker/images/alpine33/Dockerfile
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
FROM alpine:3.3
|
||||
LABEL maintainer="Postman Labs <help@postman.com>"
|
||||
|
||||
ARG NODE_VERSION=10
|
||||
ARG NEWMAN_VERSION
|
||||
|
||||
# Set environment variables
|
||||
ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8" ALPINE_NODE_REPO="oznu/alpine-node"
|
||||
|
||||
# Bail out early if NODE_VERSION is not provided
|
||||
RUN if [ ! $(echo $NEWMAN_VERSION | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+$") ]; then \
|
||||
echo "\033[0;31mA valid semver Newman version is required in the NEWMAN_VERSION build-arg\033[0m"; \
|
||||
exit 1; \
|
||||
fi && \
|
||||
# Add the latest Alpine Linux package to the repositories list
|
||||
echo -e "https://nl.alpinelinux.org/alpine/v3.3/main/\nhttps://nl.alpinelinux.org/alpine/v3.3/community/" > /etc/apk/repositories && \
|
||||
# Update existing packages and install Node dependencies
|
||||
apk add --update --no-cache libgcc libstdc++ jq curl && \
|
||||
# Determine the complete Semver Node version for the provided Node major version in $NODE_VERSION
|
||||
FULL_NODE_VERSION=$(curl --silent "https://api.github.com/repos/${ALPINE_NODE_REPO}/releases" | jq -r '.[].tag_name' | grep -oE "^${NODE_VERSION}\.\d+\.\d+$" | sort -r -t. -k 1,1nr -k 2,2nr -k 3,3nr | head -n1) && \
|
||||
# Download the appropriate Node binary for Alpine Linux
|
||||
curl --silent -L "https://github.com/${ALPINE_NODE_REPO}/releases/download/${FULL_NODE_VERSION}/node-v${FULL_NODE_VERSION}-linux-x86_64-alpine.tar.gz" > /etc/alpine-node-${NODE_VERSION}.tar.gz && \
|
||||
# Extract and install Node from the binary downloaded in the previous step
|
||||
tar -xzf /etc/alpine-node-${NODE_VERSION}.tar.gz -C /usr --no-same-owner && \
|
||||
# Install Newman globally
|
||||
npm install --global newman@${NEWMAN_VERSION} && \
|
||||
# Prune redundant packages
|
||||
apk del jq curl && \
|
||||
# Clear Alpine Node binary
|
||||
rm /etc/alpine-node-${NODE_VERSION}.tar.gz;
|
||||
|
||||
# Set workdir to /etc/newman
|
||||
# When running the image, mount the directory containing your collection to this location
|
||||
#
|
||||
# docker run -v <path to collections directory>:/etc/newman ...
|
||||
#
|
||||
# In case you mount your collections directory to a different location, you will need to give absolute paths to any
|
||||
# collection, environment files you want to pass to newman, and if you want newman reports to be saved to your disk.
|
||||
# Or you can change the workdir by using the -w or --workdir flag
|
||||
WORKDIR /etc/newman
|
||||
|
||||
# Set newman as the default container command
|
||||
# Now you can run the container via
|
||||
#
|
||||
# docker run -v /home/collections:/etc/newman -t postman/newman_alpine33 run YourCollection.json.postman_collection \
|
||||
# -e YourEnvironment.postman_environment \
|
||||
# -H newman_report.html
|
||||
ENTRYPOINT ["newman"]
|
39
node_modules/newman/docker/images/alpine33/README.md
generated
vendored
Normal file
39
node_modules/newman/docker/images/alpine33/README.md
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# newman_alpine33 (deprecated)
|
||||
## Use postman/newman:alpine instead. See https://hub.docker.com/r/postman/newman/ for more available tags
|
||||
|
||||
This image runs newman on node v8 on Alpine 3.3
|
||||
|
||||
Build the image:
|
||||
|
||||
```terminal
|
||||
docker build -t postman/newman_alpine33 --build-arg NEWMAN_VERSION="full semver version" .
|
||||
```
|
||||
|
||||
Or get it from [Docker Hub](https://registry.hub.docker.com/u/postman/newman_alpine33/):
|
||||
|
||||
```terminal
|
||||
docker pull postman/newman_alpine33
|
||||
```
|
||||
|
||||
Then run it:
|
||||
|
||||
```terminal
|
||||
docker --volume="/home/postman/collections:/etc/newman" -t postman/newman_alpine33 run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
For newman-docker to be able to use collections and environment files saved on the host machine, and to save reports generated by newman, a directory containing the collection and environment needs to be mounted on to the docker instance on run time, preferably at `/etc/newman`, which is the default working directory. If you mount to a different location, then:
|
||||
- You can pass the full path to your collection and environment files to newman. For instance, if you mount to `/etc/newman`,
|
||||
|
||||
```terminal
|
||||
docker --volume="/home/postman/collection:/etc/newman" -t postman/newman_alpine33 run JSONBlobCoreAPI.json.postman_collection" -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
- You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag.
|
||||
|
||||
```terminal
|
||||
docker run --volume="/home/postman/collections:/etc/newman" -t postman/newman_alpine33 run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
|
||||
In case you don't need to save newman's report to the host, and your collection is available online and does not require any environment, then you can forgo mounting your collections directory and directly pass the collection URL to newman:
|
||||
|
||||
```terminal
|
||||
docker run -t postman/newman_alpine33 run https://www.getpostman.com/collections/8a0c9bc08f062d12dcda
|
||||
```
|
44
node_modules/newman/docker/images/ubuntu/Dockerfile
generated
vendored
Normal file
44
node_modules/newman/docker/images/ubuntu/Dockerfile
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
FROM ubuntu:18.04
|
||||
LABEL maintainer="Postman Labs <help@postman.com>"
|
||||
|
||||
ARG NODE_VERSION=10
|
||||
ARG NEWMAN_VERSION
|
||||
|
||||
# Bail out early if NODE_VERSION is not provided
|
||||
RUN if [ ! $(echo $NEWMAN_VERSION | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+$") ]; then \
|
||||
echo "\033[0;31mA valid semver Newman version is required in the NEWMAN_VERSION build-arg\033[0m"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# Install node
|
||||
ADD https://deb.nodesource.com/setup_$NODE_VERSION.x /opt/install_node.sh
|
||||
|
||||
RUN apt-get update -y && \
|
||||
apt-get upgrade -y && \
|
||||
apt-get install -y gnupg && \
|
||||
bash /opt/install_node.sh && \
|
||||
apt-get install -y nodejs && \
|
||||
npm install -g newman@${NEWMAN_VERSION} && \
|
||||
rm /opt/install_node.sh && \
|
||||
apt-get purge -y gnupg;
|
||||
|
||||
# Set environment variables
|
||||
ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8"
|
||||
|
||||
# Set workdir to /etc/newman
|
||||
# When running the image, mount the directory containing your collection to this location
|
||||
#
|
||||
# docker run -v <path to collections directory>:/etc/newman ...
|
||||
#
|
||||
# In case you mount your collections directory to a different location, you will need to give absolute paths to any
|
||||
# collection, environment files you want to pass to newman, and if you want newman reports to be saved to your disk.
|
||||
# Or you can change the workdir by using the -w or --workdir flag
|
||||
WORKDIR /etc/newman
|
||||
|
||||
# Set newman as the default container command
|
||||
# Now you can run the container via
|
||||
#
|
||||
# docker run -v /home/collections:/etc/newman -t postman/newman_ubuntu run YourCollection.json.postman_collection \
|
||||
# -e YourEnvironment.postman_environment \
|
||||
# -H newman_report.html
|
||||
ENTRYPOINT ["newman"]
|
38
node_modules/newman/docker/images/ubuntu/README.md
generated
vendored
Normal file
38
node_modules/newman/docker/images/ubuntu/README.md
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# newman:ubuntu
|
||||
|
||||
This image runs newman on node v10 on Ubuntu 18.04
|
||||
|
||||
Build the image,
|
||||
|
||||
```terminal
|
||||
docker build -t postman/newman:ubuntu --build-arg NEWMAN_VERSION="full semver version" .
|
||||
```
|
||||
|
||||
Or get it from [docker hub](https://registry.hub.docker.com/u/postman/newman:ubuntu/)
|
||||
|
||||
```terminal
|
||||
docker pull postman/newman:ubuntu
|
||||
```
|
||||
|
||||
Then run it
|
||||
|
||||
```terminal
|
||||
docker --volume="/home/postman/collections:/etc/newman" -t postman/newman:ubuntu run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
For newman-docker to be able to use collections and environment files saved on the host machine, and to save reports generated by newman, a directory containing the collection and environment needs to be mounted on to the docker instance on run time, preferably at `/etc/newman`, which is the default working directory. If you mount to a different location, then
|
||||
- You can either pass the full path to your collection and environment files to newman. For instance, if you mount to `/etc/newman`,
|
||||
|
||||
```terminal
|
||||
docker --volume="/home/postman/collection:/etc/newman" -t postman/newman:ubuntu run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
- You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag.
|
||||
|
||||
```terminal
|
||||
docker run --volume="/home/postman/collections:/etc/newman" -t postman/newman:ubuntu run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
|
||||
In case you don't need to save newman's report to the host, and your collection is available online and it does not require any environment, then you can forgo mounting your collections directory, and directly pass the collection url to newman
|
||||
|
||||
```terminal
|
||||
docker run -t postman/newman:ubuntu run https://www.getpostman.com/collections/8a0c9bc08f062d12dcda
|
||||
```
|
40
node_modules/newman/docker/images/ubuntu1404/Dockerfile
generated
vendored
Normal file
40
node_modules/newman/docker/images/ubuntu1404/Dockerfile
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
FROM ubuntu:14.04.2
|
||||
LABEL maintainer="Postman Labs <help@postman.com>"
|
||||
|
||||
ARG NODE_VERSION=10
|
||||
ARG NEWMAN_VERSION
|
||||
|
||||
# Bail out early if NODE_VERSION is not provided
|
||||
RUN if [ ! $(echo $NEWMAN_VERSION | grep -oE "^[0-9]+\.[0-9]+\.[0-9]+$") ]; then \
|
||||
echo "\033[0;31mA valid semver Newman version is required in the NEWMAN_VERSION build-arg\033[0m"; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
# Install node
|
||||
ADD https://deb.nodesource.com/setup_$NODE_VERSION.x /opt/install_node.sh
|
||||
|
||||
RUN bash /opt/install_node.sh && \
|
||||
apt-get install -y nodejs && \
|
||||
npm install -g newman@${NEWMAN_VERSION} && \
|
||||
rm /opt/install_node.sh;
|
||||
|
||||
# Set environment variables
|
||||
ENV LC_ALL="en_US.UTF-8" LANG="en_US.UTF-8" LANGUAGE="en_US.UTF-8"
|
||||
|
||||
# Set workdir to /etc/newman
|
||||
# When running the image, mount the directory containing your collection to this location
|
||||
#
|
||||
# docker run -v <path to collections directory>:/etc/newman ...
|
||||
#
|
||||
# In case you mount your collections directory to a different location, you will need to give absolute paths to any
|
||||
# collection, environment files you want to pass to newman, and if you want newman reports to be saved to your disk.
|
||||
# Or you can change the workdir by using the -w or --workdir flag
|
||||
WORKDIR /etc/newman
|
||||
|
||||
# Set newman as the default container command
|
||||
# Now you can run the container via
|
||||
#
|
||||
# docker run -v /home/collections:/etc/newman -t postman/newman_ubuntu1404 run YourCollection.json.postman_collection \
|
||||
# -e YourEnvironment.postman_environment \
|
||||
# -H newman_report.html
|
||||
ENTRYPOINT ["newman"]
|
39
node_modules/newman/docker/images/ubuntu1404/README.md
generated
vendored
Normal file
39
node_modules/newman/docker/images/ubuntu1404/README.md
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# newman_ubuntu1404 (deprecated)
|
||||
## Use postman/newman:ubuntu instead. See https://hub.docker.com/r/postman/newman/ for more available tags
|
||||
|
||||
This image runs newman on node v10 on Ubuntu 14.04.2
|
||||
|
||||
Build the image,
|
||||
|
||||
```terminal
|
||||
docker build -t postman/newman_ubuntu1404 --build-arg NEWMAN_VERSION="full semver version" .
|
||||
```
|
||||
|
||||
Or get it from [docker hub](https://registry.hub.docker.com/u/postman/newman_ubuntu1404/)
|
||||
|
||||
```terminal
|
||||
docker pull postman/newman_ubuntu1404
|
||||
```
|
||||
|
||||
then run it
|
||||
|
||||
```terminal
|
||||
docker --volume="/home/postman/collections:/etc/newman" -t postman/newman_ubuntu1404 run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
For newman-docker to be able to use collections and environment files saved on the host machine, and to save reports generated by newman, a directory containing the collection and environment needs to be mounted on to the docker instance on run time, preferably at `/etc/newman`, which is the default working directory. If you mount to a different location, then
|
||||
- You can either pass the full path to your collection and environment files to newman. For instance, if you mount to `/etc/newman`,
|
||||
|
||||
```terminal
|
||||
docker --volume="/home/postman/collection:/etc/newman" -t postman/newman_ubuntu1404 run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
- You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag.
|
||||
|
||||
```terminal
|
||||
docker run --volume="/home/postman/collections:/etc/newman" -t postman/newman_ubuntu1404 run JSONBlobCoreAPI.json.postman_collection -r json --reporter-json-export newman-report.json
|
||||
```
|
||||
|
||||
In case you don't need to save newman's report to the host, and your collection is available online and it does not require any environment, then you can forgo mounting your collections directory, and directly pass the collection url to newman
|
||||
|
||||
```terminal
|
||||
docker run -t postman/newman_ubuntu1404 run https://www.getpostman.com/collections/8a0c9bc08f062d12dcda
|
||||
```
|
14
node_modules/newman/index.js
generated
vendored
Normal file
14
node_modules/newman/index.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**!
|
||||
* @license Copyright 2016 Postdot Technologies, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
module.exports = require('./lib');
|
64
node_modules/newman/lib/config/index.js
generated
vendored
Normal file
64
node_modules/newman/lib/config/index.js
generated
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
var _ = require('lodash'),
|
||||
async = require('async'),
|
||||
|
||||
env = require('./process-env'),
|
||||
rcfile = require('./rc-file');
|
||||
|
||||
/**
|
||||
* Reads configuration from config file, environment variables and CLI arguments. The CLI arguments override environment
|
||||
* variables and environment variables override the configuration read from a file.
|
||||
*
|
||||
* @param {Object} overrides - Configuration overrides (these usually come from the CLI).
|
||||
* @param {Object} options - The wrapper object of settings used for selective configuration loading.
|
||||
* @param {String} options.command - Command name. Used for loading the required options from the config file.
|
||||
* @param {Boolean=} options.ignoreRcFile - If true, the RC file is ignored.
|
||||
* @param {Boolean=} options.ignoreProcessEnvironment - If true, the process environment variables are ignored.
|
||||
* @param {Object=} options.loaders - Custom loaders for specific configuration options.
|
||||
* @param {Function} callback - Is called after merging values from the overrides with the values from the rc file and
|
||||
* environment variables.
|
||||
* @returns {*}
|
||||
*/
|
||||
module.exports.get = (overrides, options, callback) => {
|
||||
!callback && _.isFunction(options) && (callback = options, options = {});
|
||||
|
||||
var loaders = options.loaders,
|
||||
commonOptions = _.pick(overrides, ['postmanApiKey']);
|
||||
|
||||
async.waterfall([
|
||||
// Load RC Files.
|
||||
!options.ignoreRcFile ? rcfile.load : (cb) => {
|
||||
return cb(null, {});
|
||||
},
|
||||
// Load Process Environment overrides
|
||||
(fileOptions, cb) => {
|
||||
fileOptions[options.command] && (fileOptions = fileOptions[options.command]);
|
||||
|
||||
return cb(null, _.merge(fileOptions, options.ignoreProcessEnvironment ? {} : env));
|
||||
}
|
||||
], (err, options) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
options = _.mergeWith({}, options, overrides, (dest, src) => {
|
||||
// If the newer value is a null, do not override it.
|
||||
return (src === null) ? dest : undefined;
|
||||
});
|
||||
|
||||
if (_.isEmpty(loaders)) {
|
||||
return callback(null, options);
|
||||
}
|
||||
// sanitize environment option
|
||||
if (!options.environment) {
|
||||
options.environment = {};
|
||||
}
|
||||
// sanitize globals option
|
||||
if (!options.globals) {
|
||||
options.globals = {};
|
||||
}
|
||||
|
||||
async.mapValues(options, (value, name, cb) => {
|
||||
return (value && _.isFunction(loaders[name])) ? loaders[name](value, commonOptions, cb) : cb(null, value);
|
||||
}, callback);
|
||||
});
|
||||
};
|
3
node_modules/newman/lib/config/process-env.js
generated
vendored
Normal file
3
node_modules/newman/lib/config/process-env.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
var envConfig = {}; // todo: read NEWMAN_* variables from process.env
|
||||
|
||||
module.exports = envConfig;
|
59
node_modules/newman/lib/config/rc-file.js
generated
vendored
Normal file
59
node_modules/newman/lib/config/rc-file.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/* eslint-disable no-process-env */
|
||||
var _ = require('lodash'),
|
||||
fs = require('fs'),
|
||||
join = require('path').join,
|
||||
async = require('async'),
|
||||
util = require('../util'),
|
||||
liquidJSON = require('liquid-json'),
|
||||
|
||||
/**
|
||||
* Name of the directory that contains the file denoted by FILE_NAME.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
POSTMAN_CONFIG_DIR = 'postman',
|
||||
|
||||
/**
|
||||
* Name of the file that contains Newman compliant confguration information.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
FILE_NAME = 'newmanrc';
|
||||
|
||||
/**
|
||||
* Configuration loader to acquire run settings from a file present in the home directory: POSTMAN_CONFIG_DIR/FILE_NAME.
|
||||
*
|
||||
* @param {Function} callback - The callback function invoked to mark the completion of the config loading routine.
|
||||
* @returns {*}
|
||||
*/
|
||||
module.exports.load = (callback) => {
|
||||
var iswin = (/^win/).test(process.platform),
|
||||
home = iswin ? process.env.USERPROFILE : process.env.HOME,
|
||||
|
||||
configFiles = [];
|
||||
|
||||
!iswin && configFiles.push(join('/etc', POSTMAN_CONFIG_DIR, FILE_NAME));
|
||||
home && configFiles.push(join(home, '.' + POSTMAN_CONFIG_DIR, FILE_NAME));
|
||||
configFiles.push(join(process.cwd(), '.' + FILE_NAME));
|
||||
|
||||
async.mapSeries(configFiles, (path, cb) => {
|
||||
fs.readFile(path, (err, data) => {
|
||||
if (err) {
|
||||
return cb(null, {}); // err masked to avoid overpopulating terminal with missing .newmanrc messages
|
||||
}
|
||||
data && data.toString && (data = data.toString(util.detectEncoding(data)).trim());
|
||||
try {
|
||||
return cb(null, liquidJSON.parse(data));
|
||||
}
|
||||
catch (e) {
|
||||
return cb(_.set(e, 'help', `The file at ${path} contains invalid data.`));
|
||||
}
|
||||
});
|
||||
}, (err, files) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
return callback(null, _.merge.apply(this, files));
|
||||
});
|
||||
};
|
3
node_modules/newman/lib/index.js
generated
vendored
Normal file
3
node_modules/newman/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
run: require('./run')
|
||||
};
|
30
node_modules/newman/lib/node-version-check/index.js
generated
vendored
Normal file
30
node_modules/newman/lib/node-version-check/index.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
var semver = require('semver'),
|
||||
colors = require('colors/safe'),
|
||||
pkg = require('../../package.json'),
|
||||
|
||||
/**
|
||||
* The required node version from package.json.
|
||||
*
|
||||
* @type {String}
|
||||
* @readOnly
|
||||
*/
|
||||
requiredNodeVersion = pkg && pkg.engines && pkg.engines.node,
|
||||
|
||||
/**
|
||||
* The current node version as detected from running process.
|
||||
*
|
||||
* @type {String}
|
||||
* @readOnly
|
||||
*/
|
||||
currentNodeVersion = process && process.version;
|
||||
|
||||
// if either current or required version is not detected, we bail out
|
||||
if (!(requiredNodeVersion && currentNodeVersion)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// we check semver satisfaction and throw error on mismatch
|
||||
if (!semver.satisfies(currentNodeVersion, requiredNodeVersion)) {
|
||||
console.error([colors.red('newman:'), 'required node version', requiredNodeVersion].join(' '));
|
||||
process.exit(1);
|
||||
}
|
149
node_modules/newman/lib/print/index.js
generated
vendored
Normal file
149
node_modules/newman/lib/print/index.js
generated
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
var format = require('util').format,
|
||||
cliUtils = require('../reporters/cli/cli-utils'),
|
||||
SPC = ' ',
|
||||
BS = '\b',
|
||||
LF = '\n',
|
||||
WAIT_FRAMES = (/^win/).test(process.platform) ?
|
||||
['\u2015', '\\', '|', '/'] :
|
||||
['⠄', '⠆', '⠇', '⠋', '⠙', '⠸', '⠰', '⠠', '⠰', '⠸', '⠙', '⠋', '⠇', '⠆'],
|
||||
WAIT_FRAMES_SIZE = WAIT_FRAMES.length - 1,
|
||||
WAIT_FRAMERATE = 100,
|
||||
print;
|
||||
|
||||
/**
|
||||
* Function that prints to stdout using standard NodeJS util.format, without end newline.
|
||||
*
|
||||
* @returns {print} - The result of context bound call to the run context, with all arguments passed.
|
||||
* @chainable
|
||||
*/
|
||||
print = function () {
|
||||
return print.print.apply(this, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Function that prints to stdout using standard NodeJS util.format, without end newline.
|
||||
*
|
||||
* @returns {print} - The updated print module wrapper, with unwait and unbuffer methods invoked.
|
||||
* @chainable
|
||||
*/
|
||||
print.print = function () {
|
||||
print.waiting && print.unwait();
|
||||
print._buffer && print.unbuffer();
|
||||
process.stdout.write(format.apply(this, arguments));
|
||||
|
||||
return print;
|
||||
};
|
||||
|
||||
/**
|
||||
* Print with a line feed at the end.
|
||||
*
|
||||
* @returns {print} - The updated print module wrapper, with unwait and unbuffer methods invoked.
|
||||
* @chainable
|
||||
*/
|
||||
print.lf = function () {
|
||||
print.waiting && print.unwait();
|
||||
print._buffer && print.unbuffer();
|
||||
process.stdout.write(format.apply(this, arguments) + LF);
|
||||
|
||||
return print;
|
||||
};
|
||||
|
||||
// store the starting frame during wait
|
||||
print._waitPosition = 0;
|
||||
|
||||
/**
|
||||
* Draw a spinner until next print statement is received.
|
||||
*
|
||||
* @param {Function=} color - Optional color function from `colors` module.
|
||||
* @returns {print} - The print module wrapper, with a key set as a setInterval label.
|
||||
* @chainable
|
||||
*/
|
||||
print.wait = function (color) {
|
||||
print.unwait();
|
||||
|
||||
if (cliUtils.noTTY()) {
|
||||
return print;
|
||||
}
|
||||
|
||||
process.stdout.write(SPC);
|
||||
print.waiting = setInterval(function () {
|
||||
process.stdout.write(BS +
|
||||
(color ? color(WAIT_FRAMES[print._waitPosition++]) : WAIT_FRAMES[print._waitPosition++]));
|
||||
(print._waitPosition > WAIT_FRAMES_SIZE) && (print._waitPosition = 0); // move frame
|
||||
}, WAIT_FRAMERATE);
|
||||
|
||||
return print;
|
||||
};
|
||||
|
||||
/**
|
||||
* Stops a running spinner on CLI. It is automatically taken care of in most cases.
|
||||
*
|
||||
* @returns {print} - Returns the updated print module wrapper, with the cleared waiting label.
|
||||
* @chainable
|
||||
* @see print.wait
|
||||
*/
|
||||
print.unwait = function () {
|
||||
if (print.waiting) {
|
||||
print.waiting = clearInterval(print.waiting);
|
||||
print._waitPosition = 0;
|
||||
process.stdout.write('\b');
|
||||
}
|
||||
|
||||
return print;
|
||||
};
|
||||
|
||||
print._buffer = undefined;
|
||||
|
||||
/**
|
||||
* Prints a message between start and end text. Consequent buffer calls does not print the start text and any other
|
||||
* unbuffered call or a delay of time prints the end text.
|
||||
*
|
||||
* @param {String} startText - The text to begin printing with.
|
||||
* @param {String} endText - The text that marks the end of the print routine.
|
||||
* @returns {print} - The update print module wrapper with internal buffer and buffering members redefined.
|
||||
* @chainable
|
||||
*/
|
||||
print.buffer = function (startText, endText) {
|
||||
(print._buffer === undefined) && process.stdout.write(startText);
|
||||
print._buffer = endText;
|
||||
|
||||
print._buferring && (print._buferring = clearTimeout(print._buferring));
|
||||
print._buferring = setTimeout(print.unbuffer, 500);
|
||||
|
||||
process.stdout.write(format.apply(this, Array.prototype.splice.call(arguments, 2)));
|
||||
|
||||
return print;
|
||||
};
|
||||
|
||||
/**
|
||||
* Prints text without flushing the buffer.
|
||||
*
|
||||
* @returns {print} - The update print module wrapper with unwait called.
|
||||
* @chainable
|
||||
* @see print.buffer
|
||||
*/
|
||||
print.nobuffer = function () {
|
||||
print.unwait();
|
||||
process.stdout.write(format.apply(this, arguments));
|
||||
|
||||
return print;
|
||||
};
|
||||
|
||||
/**
|
||||
* Flushes the buffer.
|
||||
*
|
||||
* @returns {print} - The print module wrapper with internal private members: buffer, and buffering redefined.
|
||||
* @chainable
|
||||
* @see print.buffer
|
||||
*/
|
||||
print.unbuffer = function () {
|
||||
print._buferring && (print._buferring = clearTimeout(print._buferring));
|
||||
if (print._buffer) {
|
||||
process.stdout.write(print._buffer);
|
||||
print._buffer = undefined;
|
||||
}
|
||||
|
||||
return print;
|
||||
};
|
||||
|
||||
module.exports = print;
|
79
node_modules/newman/lib/reporters/cli/cli-utils-symbols.js
generated
vendored
Normal file
79
node_modules/newman/lib/reporters/cli/cli-utils-symbols.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
var IS_WINDOWS = (/^win/).test(process.platform),
|
||||
subsets,
|
||||
symbols;
|
||||
|
||||
/**
|
||||
* A set of symbol groups for use in different situations: regular, windows friendly unicode, and plain text.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
subsets = {
|
||||
regular: {
|
||||
console: {
|
||||
top: '┌',
|
||||
middle: '│',
|
||||
bottom: '└'
|
||||
},
|
||||
dot: '.',
|
||||
folder: '❏',
|
||||
root: '→',
|
||||
sub: '↳',
|
||||
ok: '✓',
|
||||
error: '✖',
|
||||
star: '★',
|
||||
up: '↑',
|
||||
down: '↓'
|
||||
},
|
||||
encoded: {
|
||||
console: {
|
||||
top: '\u250C',
|
||||
middle: '\u2502',
|
||||
bottom: '\u2514'
|
||||
},
|
||||
dot: '.',
|
||||
folder: '\u25A1',
|
||||
root: '\u2192',
|
||||
sub: '\u2514',
|
||||
ok: '\u221A',
|
||||
error: '\u00D7',
|
||||
star: '\u2605',
|
||||
up: '\u2191',
|
||||
down: '\u2193'
|
||||
},
|
||||
plainText: {
|
||||
console: {
|
||||
top: '-',
|
||||
middle: '|',
|
||||
bottom: '-'
|
||||
},
|
||||
dot: '.',
|
||||
folder: 'Folder',
|
||||
root: 'Root',
|
||||
sub: 'Sub-folder',
|
||||
ok: 'Pass',
|
||||
error: 'Fail',
|
||||
star: '*',
|
||||
up: '^',
|
||||
down: 'v'
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A method that picks the appropriate set of CLI report symbols under a given set of run conditions.
|
||||
*
|
||||
* @param {Boolean} disableUnicode - A flag to force plain text equivalents for CLI symbols if set to true.
|
||||
* @returns {Object} - The right set of symbols from subsets for the given conditions.
|
||||
* @todo Add additional parameter related to temp file read - writes
|
||||
*/
|
||||
symbols = function (disableUnicode) {
|
||||
if (disableUnicode) {
|
||||
return subsets.plainText;
|
||||
}
|
||||
if (IS_WINDOWS) { // modify symbols for windows platforms
|
||||
return subsets.encoded;
|
||||
}
|
||||
|
||||
return subsets.regular;
|
||||
};
|
||||
|
||||
module.exports = symbols;
|
185
node_modules/newman/lib/reporters/cli/cli-utils.js
generated
vendored
Normal file
185
node_modules/newman/lib/reporters/cli/cli-utils.js
generated
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
var inspect = require('util').inspect,
|
||||
wrap = require('word-wrap'),
|
||||
symbols = require('./cli-utils-symbols'),
|
||||
|
||||
cliUtils;
|
||||
|
||||
// set styling for inspect options
|
||||
inspect.styles.string = 'grey';
|
||||
inspect.styles.name = 'white';
|
||||
|
||||
cliUtils = {
|
||||
|
||||
/**
|
||||
* A helper method that picks the right set of symbols for the given set of run conditions.
|
||||
*
|
||||
* @type {Function}
|
||||
*/
|
||||
symbols: symbols,
|
||||
|
||||
/**
|
||||
* A set of blank CLI table symbols (default).
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
cliTableTemplate_Blank: {
|
||||
top: '',
|
||||
'top-mid': '',
|
||||
'top-left': '',
|
||||
'top-right': '',
|
||||
bottom: '',
|
||||
'bottom-mid': '',
|
||||
'bottom-left': '',
|
||||
'bottom-right': '',
|
||||
middle: '',
|
||||
mid: ' ',
|
||||
'mid-mid': '',
|
||||
'mid-left': '',
|
||||
'mid-right': '',
|
||||
left: '',
|
||||
'left-mid': '',
|
||||
'left-left': '',
|
||||
'left-right': '',
|
||||
right: '',
|
||||
'right-mid': '',
|
||||
'right-left': '',
|
||||
'right-right': ''
|
||||
},
|
||||
|
||||
/**
|
||||
* A set of fallback CLI table construction symbols, used when unicode has been disabled.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
cliTableTemplateFallback: {
|
||||
top: '-',
|
||||
'top-mid': '-',
|
||||
'top-left': '-',
|
||||
'top-right': '-',
|
||||
bottom: '-',
|
||||
'bottom-mid': '-',
|
||||
'bottom-left': '-',
|
||||
'bottom-right': '-',
|
||||
middle: '|',
|
||||
mid: '-',
|
||||
'mid-mid': '+',
|
||||
'mid-left': '-',
|
||||
'mid-right': '-',
|
||||
left: '|',
|
||||
'left-mid': '-',
|
||||
'left-left': '-',
|
||||
'left-right': '-',
|
||||
right: '|',
|
||||
'right-mid': '-',
|
||||
'right-left': '-',
|
||||
'right-right': '-'
|
||||
},
|
||||
|
||||
/**
|
||||
* A CLI utility helper method that perfoms left padding on an input string.
|
||||
*
|
||||
* @param {String} nr - The string to be padded.
|
||||
* @param {Number} n - The length of the field, in which to left pad the input string.
|
||||
* @param {String=} str - An optional string used for padding the input string. Defaults to '0'.
|
||||
* @returns {String} - The resultant left padded string.
|
||||
*/
|
||||
padLeft: function (nr, n, str) {
|
||||
return Array(n - String(nr).length + 1).join(str || '0') + nr;
|
||||
},
|
||||
|
||||
/**
|
||||
* A CLI utility helper method that checks for the non TTY compliance of the current run environment.
|
||||
*
|
||||
* color: | noTTY:
|
||||
* 'on' -> false
|
||||
* 'off' -> true
|
||||
* otherwise -> Based on isTTY.
|
||||
*
|
||||
* @param {String} color - A flag to indicate usage of the --color option.
|
||||
* @returns {Boolean} - A boolean value depicting the result of the noTTY check.
|
||||
*/
|
||||
noTTY: function (color) {
|
||||
return (color === 'off') || (color !== 'on') && (!process.stdout.isTTY);
|
||||
},
|
||||
|
||||
/**
|
||||
* A CLI utility helper method that generates a color inspector function for CLI reports.
|
||||
*
|
||||
* @param {Object} runOptions - The set of run options acquired via the runner.
|
||||
* @returns {Function} - A function to perform utils.inspect, given a sample item, under pre-existing options.
|
||||
*/
|
||||
inspector: function (runOptions) {
|
||||
var dimension = cliUtils.dimension(),
|
||||
options = {
|
||||
depth: 25,
|
||||
|
||||
maxArrayLength: 100, // only supported in Node v6.1.0 and up: https://github.com/nodejs/node/pull/6334
|
||||
|
||||
colors: !cliUtils.noTTY(runOptions.color),
|
||||
|
||||
// note that similar dimension calculation is in utils.wrapper
|
||||
// only supported in Node v6.3.0 and above: https://github.com/nodejs/node/pull/7499
|
||||
breakLength: ((dimension.exists && (dimension.width > 20)) ? dimension.width : 60) - 16
|
||||
};
|
||||
|
||||
return function (item) {
|
||||
return inspect(item, options);
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* A CLI utility helper method to provide content wrapping functionality for CLI reports.
|
||||
*
|
||||
* @returns {Function} - A sub-method to wrap content, given a piece of text, and indent value.
|
||||
*/
|
||||
wrapper: function () {
|
||||
var dimension = cliUtils.dimension(),
|
||||
// note that similar dimension calculation is in utils.wrapper
|
||||
width = ((dimension.exists && (dimension.width > 20)) ? dimension.width : 60) - 6;
|
||||
|
||||
return function (text, indent) {
|
||||
return wrap(text, {
|
||||
indent: indent,
|
||||
width: width,
|
||||
cut: true
|
||||
});
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* A CLI utility helper method to compute and scae the size of the CLI table to be displayed.
|
||||
*
|
||||
* @returns {Object} - A set of properties: width, height, and TTY existence.
|
||||
*/
|
||||
dimension: function () {
|
||||
var tty,
|
||||
width,
|
||||
height;
|
||||
|
||||
try { tty = require('tty'); }
|
||||
catch (e) { tty = null; }
|
||||
|
||||
if (tty && tty.isatty(1) && tty.isatty(2)) {
|
||||
if (process.stdout.getWindowSize) {
|
||||
width = process.stdout.getWindowSize(1)[0];
|
||||
height = process.stdout.getWindowSize(1)[1];
|
||||
}
|
||||
else if (tty.getWindowSize) {
|
||||
width = tty.getWindowSize()[1];
|
||||
height = tty.getWindowSize()[0];
|
||||
}
|
||||
else if (process.stdout.columns && process.stdout.rows) {
|
||||
height = process.stdout.rows;
|
||||
width = process.stdout.columns;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
exists: !(Boolean(process.env.CI) || !process.stdout.isTTY), // eslint-disable-line no-process-env
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = cliUtils;
|
566
node_modules/newman/lib/reporters/cli/index.js
generated
vendored
Normal file
566
node_modules/newman/lib/reporters/cli/index.js
generated
vendored
Normal file
@@ -0,0 +1,566 @@
|
||||
var _ = require('lodash'),
|
||||
sdk = require('postman-collection'),
|
||||
colors = require('colors/safe'),
|
||||
Table = require('cli-table3'),
|
||||
format = require('util').format,
|
||||
|
||||
util = require('../../util'),
|
||||
cliUtils = require('./cli-utils'),
|
||||
print = require('../../print'),
|
||||
pad = cliUtils.padLeft,
|
||||
|
||||
LF = '\n',
|
||||
SPC = ' ',
|
||||
DOT = '.',
|
||||
E = '',
|
||||
|
||||
CACHED_TIMING_PHASE = '(cache)',
|
||||
TIMING_TABLE_HEADERS = {
|
||||
prepare: 'prepare',
|
||||
wait: 'wait',
|
||||
dns: 'dns-lookup',
|
||||
tcp: 'tcp-handshake',
|
||||
secureHandshake: 'ssl-handshake',
|
||||
firstByte: 'transfer-start',
|
||||
download: 'download',
|
||||
process: 'process',
|
||||
total: 'total'
|
||||
},
|
||||
BODY_CLIP_SIZE = 2048,
|
||||
|
||||
PostmanCLIReporter,
|
||||
timestamp,
|
||||
extractSNR;
|
||||
|
||||
// sets theme for colors for console logging
|
||||
colors.setTheme({
|
||||
log: 'grey',
|
||||
info: 'cyan',
|
||||
warn: 'yellow',
|
||||
debug: 'blue',
|
||||
error: 'red'
|
||||
});
|
||||
|
||||
extractSNR = function (executions) {
|
||||
var snr;
|
||||
|
||||
// eslint-disable-next-line lodash/collection-method-value
|
||||
_.isArray(executions) && _.forEachRight(executions, function (execution) {
|
||||
var nextReq = _.get(execution, 'result.return.nextRequest');
|
||||
|
||||
if (nextReq) {
|
||||
snr = nextReq;
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return snr;
|
||||
};
|
||||
|
||||
/**
|
||||
* CLI reporter
|
||||
*
|
||||
* @param {EventEmitter} emitter - An EventEmitter instance with event handler attachers to trigger reporting.
|
||||
* @param {Object} reporterOptions - CLI reporter options object.
|
||||
* @param {Boolean=} reporterOptions.silent - Boolean flag to turn off CLI reporting altogether, if set to true.
|
||||
* @param {Boolean=} reporterOptions.noAssertions - Boolean flag to turn off assertion reporting, if set to true.
|
||||
* @param {Boolean=} reporterOptions.noSuccessAssertions - Boolean flag, if true, turn off report successful assertions.
|
||||
* @param {Boolean=} reporterOptions.noSummary - Boolean flag to turn off summary reporting altogether, if set to true.
|
||||
* @param {Boolean=} reporterOptions.noFailures - Boolean flag to turn off failure reporting altogether, if set to true.
|
||||
* @param {Boolean=} reporterOptions.noConsole - Boolean flag to turn off console logging, if set to true.
|
||||
* @param {Boolean=} reporterOptions.noBanner - Boolean flag to turn off newman banner, if set to true.
|
||||
* @param {Object} options - A set of generic collection run options.
|
||||
* @returns {*}
|
||||
*/
|
||||
PostmanCLIReporter = function (emitter, reporterOptions, options) {
|
||||
var currentGroup = options.collection,
|
||||
inspect = cliUtils.inspector(options),
|
||||
wrap = cliUtils.wrapper(),
|
||||
symbols = cliUtils.symbols(options.disableUnicode);
|
||||
|
||||
// respect silent option to not report anything
|
||||
if (reporterOptions.silent || options.silent) {
|
||||
return; // we simply do not register anything!
|
||||
}
|
||||
|
||||
// disable colors based on `noTTY`.
|
||||
cliUtils.noTTY(options.color) && colors.disable();
|
||||
|
||||
// we register the `done` listener first so that in case user does not want to show results of collection run, we
|
||||
// simply do not register the other events
|
||||
emitter.on('done', function () {
|
||||
// for some reason, if there is no run summary, it is unexpected and hence don't validate this
|
||||
var run = this.summary.run;
|
||||
|
||||
// show the summary table (provided option does not say it is not to be shown)
|
||||
if (!reporterOptions.noSummary) {
|
||||
print(LF + PostmanCLIReporter.parseStatistics(run.stats, run.timings, run.transfers, options) + LF);
|
||||
}
|
||||
|
||||
// show the failures table (provided option does not say it is not to be shown)
|
||||
if (!reporterOptions.noFailures && run.failures && run.failures.length) {
|
||||
print(LF + PostmanCLIReporter.parseFailures(run.failures) + LF);
|
||||
}
|
||||
});
|
||||
|
||||
emitter.on('start', function () {
|
||||
var collectionIdentifier = currentGroup && (currentGroup.name || currentGroup.id);
|
||||
|
||||
if (!reporterOptions.noBanner) {
|
||||
// print the newman banner
|
||||
print('%s\n\n', colors.reset('newman'));
|
||||
}
|
||||
|
||||
// print the collection name and newman info line
|
||||
collectionIdentifier && print.lf('%s', colors.reset(collectionIdentifier));
|
||||
});
|
||||
|
||||
emitter.on('beforeIteration', function (err, o) {
|
||||
if (err || o.cursor.cycles <= 1) {
|
||||
return; // do not print iteration banner if it is a single iteration run
|
||||
}
|
||||
|
||||
// print the iteration info line
|
||||
print.lf(LF + colors.gray.underline('Iteration %d/%d'), o.cursor.iteration + 1, o.cursor.cycles);
|
||||
});
|
||||
|
||||
emitter.on('test', function (err, o) {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
var snr = extractSNR(o.executions);
|
||||
|
||||
if (snr) {
|
||||
print.lf(LF + colors.gray('Attempting to set next request to', snr));
|
||||
}
|
||||
});
|
||||
|
||||
emitter.on('beforeItem', function (err, o) {
|
||||
if (err) { return; }
|
||||
|
||||
var itemGroup = o.item.parent(),
|
||||
root = !itemGroup || (itemGroup === options.collection);
|
||||
|
||||
// in case this item belongs to a separate folder, print that folder name
|
||||
if (itemGroup && (currentGroup !== itemGroup)) {
|
||||
!root && print('\n%s %s', symbols.folder, colors.reset(util.getFullName(itemGroup)));
|
||||
|
||||
// set the flag that keeps track of the currently running group
|
||||
currentGroup = itemGroup;
|
||||
}
|
||||
|
||||
// we print the item name. the symbol prefix denotes if the item is in root or under folder.
|
||||
// @todo - when we do indentation, we would not need symbolic representation
|
||||
o.item && print.lf('\n%s %s', (root ?
|
||||
symbols.root : symbols.sub), colors.reset(o.item.name || E));
|
||||
});
|
||||
|
||||
// print out the request name to be executed and start a spinner
|
||||
emitter.on('beforeRequest', function (err, o) {
|
||||
if (err || !o.request) { return; }
|
||||
|
||||
if (reporterOptions.showTimestamps) {
|
||||
var currentTime = new Date();
|
||||
|
||||
timestamp = '[' + currentTime.toLocaleString() + ']';
|
||||
print(' %s %s %s ',
|
||||
colors.gray(timestamp),
|
||||
colors.gray(o.request.method),
|
||||
colors.gray(o.request.url.toString()));
|
||||
}
|
||||
else {
|
||||
print(' %s %s ',
|
||||
colors.gray(o.request.method),
|
||||
colors.gray(o.request.url.toString()));
|
||||
}
|
||||
|
||||
!options.disableUnicode && print().wait(colors.gray);
|
||||
});
|
||||
|
||||
// output the response code, reason and time
|
||||
emitter.on('request', function (err, o) {
|
||||
if (err) {
|
||||
print.lf(colors.red('[errored]'));
|
||||
print.lf(colors.red(' %s'), err.message);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(o.request && o.response)) {
|
||||
print.lf(colors.red('[errored]'));
|
||||
print.lf(colors.red(' %s'), 'Internal error! Could not read response data.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// quickly print out basic non verbose response meta and exit
|
||||
if (!options.verbose) {
|
||||
print.lf(colors.gray('[%d %s, %s, %s]'), o.response.code, o.response.reason(),
|
||||
util.filesize(o.response.size().total), util.prettyms(o.response.responseTime));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// this point onwards the output is verbose. a tonne of variables are created here for
|
||||
// keeping the output clean and readable
|
||||
|
||||
let req = o.request,
|
||||
res = o.response,
|
||||
|
||||
// set values here with abundance of caution to avoid erroring out
|
||||
reqSize = util.filesize(req.size().total),
|
||||
resSize = util.filesize(res.size().total),
|
||||
code = res.code,
|
||||
reason = res.reason(),
|
||||
mime = res.contentInfo() || {},
|
||||
timings = _.last(_.get(o, 'history.execution.data')),
|
||||
|
||||
reqHeadersLen = _.get(req, 'headers.members.length'),
|
||||
resHeadersLen = _.get(res, 'headers.members.length'),
|
||||
|
||||
resTime = util.prettyms(res.responseTime || 0),
|
||||
|
||||
reqText = (options.verbose && req.body) ? req.body.toString() : E,
|
||||
reqTextLen = req.size().body || Buffer.byteLength(reqText),
|
||||
|
||||
resText = options.verbose ? res.text() : E,
|
||||
resTextLen = res.size().body || Buffer.byteLength(resText),
|
||||
|
||||
reqBodyMode = _.get(req, 'body.mode', ''),
|
||||
resSummary = [
|
||||
`${mime.contentType}`,
|
||||
`${mime.mimeType}`,
|
||||
`${mime.mimeFormat}`,
|
||||
`${mime.charset}`
|
||||
].join(` ${colors.gray(symbols.star)} `);
|
||||
|
||||
|
||||
print.lf(SPC); // also flushes out the circling progress icon
|
||||
|
||||
// for clean readability of code. this section compiles the cli string for one line of
|
||||
// req-res combined summary. this looks somewhat like below:
|
||||
// >> 200 OK ★ 979ms time ★ 270B↑ 793B↓ size ★ 7↑ 7↓ headers ★ 0 cookies
|
||||
print.lf(SPC + SPC + [
|
||||
`${code} ${reason}`,
|
||||
`${resTime} ${colors.gray('time')}`,
|
||||
`${reqSize}${colors.gray(symbols.up)} ${resSize}${colors.gray(symbols.down)} ${colors.gray('size')}`,
|
||||
`${reqHeadersLen}${colors.gray(symbols.up)} ` +
|
||||
`${resHeadersLen}${colors.gray(symbols.down)} ${colors.gray('headers')}`,
|
||||
`${_.get(res, 'cookies.members.length')} ${colors.gray('cookies')}`
|
||||
].join(` ${colors.gray(symbols.star)} `));
|
||||
|
||||
// print request body
|
||||
if (reqTextLen) {
|
||||
// truncate very large request (is 2048 large enough?)
|
||||
if (reqTextLen > BODY_CLIP_SIZE) {
|
||||
reqText = reqText.substr(0, BODY_CLIP_SIZE) +
|
||||
colors.brightWhite(`\n(showing ${util.filesize(BODY_CLIP_SIZE)}/${util.filesize(reqTextLen)})`);
|
||||
}
|
||||
|
||||
reqText = wrap(reqText, ` ${colors.white(symbols.console.middle)} `);
|
||||
// eslint-disable-next-line max-len
|
||||
print.buffer(` ${colors.white(symbols.console.top)} ${colors.white(symbols.up)} ${reqBodyMode} ${colors.gray(symbols.star)} ${util.filesize(reqTextLen)}\n`,
|
||||
colors.white(` ${symbols.console.bottom}`))
|
||||
// tweak the message to ensure that its surrounding is not brightly coloured.
|
||||
// also ensure to remove any blank lines generated due to util.inspect
|
||||
.nobuffer(colors.gray(reqText.replace(/\n\s*\n/g, LF) + LF));
|
||||
|
||||
print.lf(SPC); // visual tweak: flushes out the buffer of wrapping body above
|
||||
}
|
||||
|
||||
// print response body
|
||||
if (resTextLen) {
|
||||
// truncate very large response (is 2048 large enough?)
|
||||
if (resTextLen > BODY_CLIP_SIZE) {
|
||||
resText = resText.substr(0, BODY_CLIP_SIZE) +
|
||||
colors.brightWhite(`\n(showing ${util.filesize(BODY_CLIP_SIZE)}/${util.filesize(resTextLen)})`);
|
||||
}
|
||||
|
||||
resText = wrap(resText, ` ${colors.white(symbols.console.middle)} `);
|
||||
// eslint-disable-next-line max-len
|
||||
print.buffer(` ${colors.white(symbols.console.top)} ${colors.white(symbols.down)} ${resSummary} ${colors.gray(symbols.star)} ${util.filesize(resTextLen)}\n`,
|
||||
colors.white(` ${symbols.console.bottom}`))
|
||||
// tweak the message to ensure that its surrounding is not brightly coloured.
|
||||
// also ensure to remove any blank lines generated due to util.inspect
|
||||
.nobuffer(colors.gray(resText.replace(/\n\s*\n/g, LF) + LF));
|
||||
}
|
||||
// print the line of response body meta one liner if there is no response body
|
||||
// if there is one, we would already print it across the body braces above.
|
||||
else {
|
||||
// we need to do some newline related shenanigans here so that the output looks clean
|
||||
// in the absence of the request body block
|
||||
print.lf(` ${symbols.down} ${resSummary}`);
|
||||
}
|
||||
|
||||
// print timing info of the request
|
||||
timings = timings && timings.timings; // if there are redirects, get timings for the last request sent
|
||||
if (timings) {
|
||||
// adds nice units to all time data in the object
|
||||
let timingPhases = util.beautifyTime(sdk.Response.timingPhases(timings)),
|
||||
timingTable = new Table({
|
||||
chars: _.defaults({ mid: '', middle: '' }, cliUtils.cliTableTemplate_Blank),
|
||||
colAligns: _.fill(Array(_.size(timingPhases)), 'left'),
|
||||
style: { 'padding-left': 2 }
|
||||
});
|
||||
|
||||
timingPhases = _.transform(TIMING_TABLE_HEADERS, (result, header, key) => {
|
||||
if (_.has(timingPhases, key)) {
|
||||
result.headers.push(colors.white(header));
|
||||
result.values.push(colors.log(timingPhases[key] || CACHED_TIMING_PHASE));
|
||||
}
|
||||
}, { headers: [], values: [] });
|
||||
|
||||
|
||||
timingTable.push(timingPhases.headers); // add name of phases in the table
|
||||
timingTable.push(timingPhases.values); // add time of phases in the table
|
||||
|
||||
print(LF + timingTable + LF + LF);
|
||||
}
|
||||
});
|
||||
|
||||
// Print script errors in real time
|
||||
emitter.on('script', function (err, o) {
|
||||
err && print.lf(colors.red.bold('%s⠄ %s in %s-script'), pad(this.summary.run.failures.length, 3, SPC), err.name,
|
||||
o.event && o.event.listen || 'unknown');
|
||||
});
|
||||
|
||||
!reporterOptions.noAssertions && emitter.on('assertion', function (err, o) {
|
||||
var passed = !err;
|
||||
|
||||
// handle skipped test display
|
||||
if (o.skipped && !reporterOptions.noSuccessAssertions) {
|
||||
print.lf('%s %s', colors.cyan(' - '), colors.cyan('[skipped] ' + o.assertion));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (passed && reporterOptions.noSuccessAssertions) {
|
||||
return;
|
||||
}
|
||||
|
||||
// print each test assertions
|
||||
if (reporterOptions.showTimestamps) {
|
||||
timestamp = '[' + new Date().toLocaleTimeString() + ']';
|
||||
print.lf(' %s%s %s', colors.gray(timestamp), passed ? colors.green(` ${symbols.ok} `) :
|
||||
colors.red.bold(pad(this.summary.run.failures.length, 2, SPC) + symbols.dot), passed ?
|
||||
colors.gray(o.assertion) : colors.red.bold(o.assertion));
|
||||
}
|
||||
else {
|
||||
print.lf('%s %s', passed ? colors.green(` ${symbols.ok} `) :
|
||||
colors.red.bold(pad(this.summary.run.failures.length, 3, SPC) + symbols.dot), passed ?
|
||||
colors.gray(o.assertion) : colors.red.bold(o.assertion));
|
||||
}
|
||||
});
|
||||
|
||||
// show user console logs in a neatly formatted way (provided user has not disabled the same)
|
||||
!reporterOptions.noConsole && emitter.on('console', function (err, o) {
|
||||
if (err) { return; }
|
||||
|
||||
var color = colors[o.level] || colors.gray,
|
||||
message;
|
||||
|
||||
// we first merge all messages to a string. while merging we run the values to util.inspect to colour code the
|
||||
// messages based on data type
|
||||
message = wrap(_.reduce(o.messages, function (log, message) { // wrap the whole message to the window size
|
||||
return (log += (log ? colors.white(', ') : '') + inspect(message));
|
||||
}, E), ` ${color(symbols.console.middle)} `); // add an indentation line at the beginning
|
||||
|
||||
// print the timestamp if the falg is present
|
||||
if (reporterOptions.showTimestamps) {
|
||||
print(LF + ' %s', colors.gray('[' + new Date().toLocaleTimeString() + ']' + LF));
|
||||
}
|
||||
|
||||
print.buffer(color(` ${symbols.console.top}\n`), color(` ${symbols.console.bottom}\n`))
|
||||
// tweak the message to ensure that its surrounding is not brightly coloured.
|
||||
// also ensure to remove any blank lines generated due to util.inspect
|
||||
.nobuffer(colors.gray(message.replace(/\n\s*\n/g, LF) + LF));
|
||||
});
|
||||
};
|
||||
|
||||
_.assignIn(PostmanCLIReporter, {
|
||||
|
||||
// @todo: change function signature to accept run object and options, thereby reducing parameters
|
||||
/**
|
||||
* A CLI reporter method to parse collection run statistics into a CLI table.
|
||||
*
|
||||
* @param {Object} stats - The cumulative collection run status object.
|
||||
* @param {Object} stats.iterations - A set of values for total, pending, and failed iterations.
|
||||
* @param {Number} stats.iterations.total - Total iterations in the current collection run.
|
||||
* @param {Number} stats.iterations.pending - Pending iterations in the current collection run.
|
||||
* @param {Number} stats.iterations.failed - Failed iterations in the current collection run.
|
||||
* @param {Object} stats.requests - A set of values for total, pending, and failed requests.
|
||||
* @param {Number} stats.requests.total - Total requests in the current collection run.
|
||||
* @param {Number} stats.requests.pending - Pending requests in the current collection run.
|
||||
* @param {Number} stats.requests.failed - Failed requests in the current collection run.
|
||||
* @param {Object} stats.testScripts - A set of values for total, pending, and failed testScripts.
|
||||
* @param {Number} stats.testScripts.total - Total testScripts in the current collection run.
|
||||
* @param {Number} stats.testScripts.pending - Pending testScripts in the current collection run.
|
||||
* @param {Number} stats.testScripts.failed - Failed testScripts in the current collection run.
|
||||
* @param {Object} stats.prerequestScripts - A set of values for total, pending, and failed prerequestScripts.
|
||||
* @param {Number} stats.prerequestScripts.total - Total prerequestScripts in the current collection run.
|
||||
* @param {Number} stats.prerequestScripts.pending - Pending prerequestScripts in the current collection run.
|
||||
* @param {Number} stats.prerequestScripts.failed - Failed prerequestScripts in the current collection run.
|
||||
* @param {Object} stats.assertions - A set of values for total, pending, and failed assertions.
|
||||
* @param {Number} stats.assertions.total - Total assertions in the current collection run.
|
||||
* @param {Number} stats.assertions.pending - Pending assertions in the current collection run.
|
||||
* @param {Number} stats.assertions.failed - Failed assertions in the current collection run.
|
||||
* @param {Object} timings - A set of values for the timings of the current collection run.
|
||||
* @param {Number} timings.completed - The end timestamp for the current collection run.
|
||||
* @param {Number} timings.started - The start timestamp for the current collection run
|
||||
* @param {String} timings.responseAverage - The average response time across all requests
|
||||
* @param {String} timings.responseMin - The minimum response time across all requests
|
||||
* @param {String} timings.responseMax - The maximum response time across all requests
|
||||
* @param {String} timings.responseSd - Standard deviation of response time across all requests
|
||||
* @param {String} timings.dnsAverage - The average DNS lookup time of the run
|
||||
* @param {String} timings.dnsMin - The minimum DNS lookup time of the run
|
||||
* @param {String} timings.dnsMax - The maximum DNS lookup time of the run
|
||||
* @param {String} timings.dnsSd - Standard deviation of DNS lookup time of the run
|
||||
* @param {String} timings.firstByteAverage - The average first byte time of the run
|
||||
* @param {String} timings.firstByteMin - The minimum first byte time of the run
|
||||
* @param {String} timings.firstByteMax - The maximum first byte time of the run
|
||||
* @param {String} timings.firstByteSd - Standard deviation of first byte time of the run
|
||||
* @param {Object} transfers - A set of details on the network usage for the current collection run.
|
||||
* @param {String} transfers.responseTotal - The net extent of the data transfer achieved during the collection run.
|
||||
* @param {Object} options - The set of generic collection run options.
|
||||
* @returns {Table} - The constructed collection run statistics table.
|
||||
*/
|
||||
parseStatistics (stats, timings, transfers, options) {
|
||||
var summaryTable;
|
||||
|
||||
// create the summary table
|
||||
summaryTable = new Table({
|
||||
chars: options.disableUnicode && cliUtils.cliTableTemplateFallback,
|
||||
style: { head: [] },
|
||||
head: [E, 'executed', ' failed'],
|
||||
colAligns: ['right', 'right', 'right'],
|
||||
colWidths: [25]
|
||||
});
|
||||
|
||||
// add specific rows to show in summary
|
||||
stats && _.forEach([{
|
||||
source: 'iterations',
|
||||
label: 'iterations'
|
||||
}, {
|
||||
source: 'requests',
|
||||
label: 'requests'
|
||||
}, {
|
||||
source: 'testScripts',
|
||||
label: 'test-scripts'
|
||||
}, {
|
||||
source: 'prerequestScripts',
|
||||
label: 'prerequest-scripts'
|
||||
}, {
|
||||
source: 'assertions',
|
||||
label: 'assertions'
|
||||
}], function (row) {
|
||||
var metric = stats[row.source],
|
||||
label = row.label;
|
||||
|
||||
// colour the label based on the failure or pending count of the metric
|
||||
label = metric.failed ? colors.red(label) : (metric.pending ? label : colors.green(label));
|
||||
|
||||
// push the statistics
|
||||
summaryTable.push([
|
||||
label,
|
||||
metric.total,
|
||||
(metric.failed ? colors.red(metric.failed) : metric.failed)
|
||||
// @todo - add information of pending scripts
|
||||
// (metric.failed ? colors.red(metric.failed) : metric.failed) +
|
||||
// (metric.pending ? format(' (%d pending)', metric.pending) : E)
|
||||
]);
|
||||
});
|
||||
|
||||
// add the total execution time to summary
|
||||
timings && summaryTable.push([{
|
||||
colSpan: 3,
|
||||
content: format('total run duration: %s', util.prettyms(timings.completed - timings.started)),
|
||||
hAlign: 'left' // since main style was set to right
|
||||
}]);
|
||||
|
||||
// add row to show total data received
|
||||
transfers && summaryTable.push([{
|
||||
colSpan: 3,
|
||||
content: format('total data received: %s (approx)', util.filesize(transfers.responseTotal)),
|
||||
hAlign: 'left'
|
||||
}]);
|
||||
|
||||
// add rows containing average time of different request phases
|
||||
timings && _.forEach({
|
||||
response: 'average response time:',
|
||||
dns: 'average DNS lookup time:',
|
||||
firstByte: 'average first byte time:'
|
||||
}, (value, key) => {
|
||||
timings[`${key}Average`] && summaryTable.push([{
|
||||
colSpan: 3,
|
||||
content: format(`${value} %s [min: %s, max: %s, s.d.: %s]`,
|
||||
util.prettyms(timings[`${key}Average`]),
|
||||
util.prettyms(timings[`${key}Min`]),
|
||||
util.prettyms(timings[`${key}Max`]),
|
||||
util.prettyms(timings[`${key}Sd`])),
|
||||
hAlign: 'left'
|
||||
}]);
|
||||
});
|
||||
|
||||
return summaryTable;
|
||||
},
|
||||
|
||||
/**
|
||||
* A CLI reporter method to parse collection run failure statistics into a CLI table.
|
||||
*
|
||||
* @param {Array} failures - An array of failure objects.
|
||||
* @returns {Table} - The constructed CLI failure Table object.
|
||||
*/
|
||||
parseFailures (failures) {
|
||||
var failureTable = new Table({
|
||||
head: [{
|
||||
hAlign: 'right',
|
||||
content: colors.red.underline('#')
|
||||
}, colors.red.underline('failure'),
|
||||
colors.red.underline('detail')],
|
||||
chars: cliUtils.cliTableTemplate_Blank,
|
||||
wordWrap: true,
|
||||
colAligns: ['right'],
|
||||
colWidths: cliUtils.noTTY() ? [] : (function (size, indexOrder) {
|
||||
var colWidths = [];
|
||||
|
||||
if (size.exists && size.width && (size.width > 20)) {
|
||||
colWidths[0] = indexOrder + 3;
|
||||
colWidths[1] = parseInt((size.width - colWidths[0]) * 0.2, 10);
|
||||
colWidths[2] = parseInt(size.width - (colWidths[0] + colWidths[1] + 5), 10);
|
||||
}
|
||||
|
||||
return colWidths;
|
||||
}(cliUtils.dimension(), Number(failures.length.toString().length)))
|
||||
});
|
||||
|
||||
_.forEach(failures, function (failure, index) {
|
||||
var name = failure.error && failure.error.name || E,
|
||||
message = failure.error && failure.error.test || E;
|
||||
|
||||
// augment name with iteration information
|
||||
failure.cursor && (failure.cursor.cycles > 1) &&
|
||||
(name += LF + colors.gray('iteration: ' + (failure.cursor.iteration + 1)));
|
||||
|
||||
// include the assertion error message in the failure details
|
||||
failure.error && (message += LF + colors.gray(failure.error.message || E));
|
||||
|
||||
// augment the message with stack information
|
||||
failure.at && (message += LF + colors.gray('at ' + failure.at));
|
||||
|
||||
// augment message with item information
|
||||
failure.source &&
|
||||
(message += format(colors.gray('\ninside "%s"'), util.getFullName(failure.source)));
|
||||
|
||||
failureTable.push([pad(Number(index + 1), Number(failures.length.toString().length)).toString() +
|
||||
DOT, name, message]);
|
||||
});
|
||||
|
||||
return failureTable;
|
||||
}
|
||||
});
|
||||
|
||||
// Mark the CLI reporter as dominant, so that no two dominant reporters are together
|
||||
PostmanCLIReporter.prototype.dominant = true;
|
||||
|
||||
module.exports = PostmanCLIReporter;
|
37
node_modules/newman/lib/reporters/emojitrain.js
generated
vendored
Normal file
37
node_modules/newman/lib/reporters/emojitrain.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
var SmileyReporter;
|
||||
|
||||
/**
|
||||
* Fills your collection run (read life) with a bunch of Emojis 😀.
|
||||
*
|
||||
* @param {Object} newman - The collection run object with event handling hooks to enable reporting.
|
||||
* @param {Object} reporterOptions - A set of reporter specific run options.
|
||||
* @param {Object} options - A set of generic collection run options.
|
||||
* @returns {*}
|
||||
*/
|
||||
SmileyReporter = function (newman, reporterOptions, options) {
|
||||
if (options.silent || reporterOptions.silent) {
|
||||
return;
|
||||
}
|
||||
|
||||
var fails = {},
|
||||
noteFailure;
|
||||
|
||||
noteFailure = function (err, args) {
|
||||
err && (fails[args.cursor.ref] = true);
|
||||
};
|
||||
|
||||
newman.on('script', noteFailure);
|
||||
newman.on('request', noteFailure);
|
||||
newman.on('assertion', noteFailure);
|
||||
|
||||
newman.on('item', function (err, args) {
|
||||
process.stdout.write((err || fails[args.cursor.ref]) ? '😢 ' : '😀 ');
|
||||
});
|
||||
|
||||
newman.on('done', function (err) {
|
||||
console.info((err || Object.keys(fails).length) ? ' 😭' : ' 😍');
|
||||
});
|
||||
};
|
||||
|
||||
SmileyReporter.prototype.dominant = true;
|
||||
module.exports = SmileyReporter;
|
22
node_modules/newman/lib/reporters/json/index.js
generated
vendored
Normal file
22
node_modules/newman/lib/reporters/json/index.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
var _ = require('lodash');
|
||||
|
||||
/**
|
||||
* Reporter that simply dumps the summary object to file (default: newman-run-report.json).
|
||||
*
|
||||
* @param {Object} newman - The collection run object, with event hooks for reporting run details.
|
||||
* @param {Object} options - A set of collection run options.
|
||||
* @param {String} options.export - The path to which the summary object must be written.
|
||||
* @returns {*}
|
||||
*/
|
||||
module.exports = function (newman, options) {
|
||||
newman.on('beforeDone', function (err, o) {
|
||||
if (err) { return; }
|
||||
|
||||
newman.exports.push({
|
||||
name: 'json-reporter',
|
||||
default: 'newman-run-report.json',
|
||||
path: options.export,
|
||||
content: JSON.stringify(_.omit(o.summary, 'exports'), 0, 2)
|
||||
});
|
||||
});
|
||||
};
|
164
node_modules/newman/lib/reporters/junit/index.js
generated
vendored
Normal file
164
node_modules/newman/lib/reporters/junit/index.js
generated
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
var _ = require('lodash'),
|
||||
xml = require('xmlbuilder'),
|
||||
|
||||
util = require('../../util'),
|
||||
JunitReporter;
|
||||
|
||||
/**
|
||||
* A function that creates raw XML to be written to Newman JUnit reports.
|
||||
*
|
||||
* @param {Object} newman - The collection run object, with a event handler setter, used to enable event wise reporting.
|
||||
* @param {Object} reporterOptions - A set of JUnit reporter run options.
|
||||
* @param {String=} reporterOptions.export - Optional custom path to create the XML report at.
|
||||
* @returns {*}
|
||||
*/
|
||||
JunitReporter = function (newman, reporterOptions) {
|
||||
newman.on('beforeDone', function () {
|
||||
var report = _.get(newman, 'summary.run.executions'),
|
||||
collection = _.get(newman, 'summary.collection'),
|
||||
cache,
|
||||
root,
|
||||
testSuitesExecutionTime = 0,
|
||||
executionTime = 0,
|
||||
timestamp,
|
||||
classname;
|
||||
|
||||
if (!report) {
|
||||
return;
|
||||
}
|
||||
|
||||
classname = _.upperFirst(_.camelCase(collection.name).replace(/\W/g, ''));
|
||||
|
||||
root = xml.create('testsuites', { version: '1.0', encoding: 'UTF-8' });
|
||||
root.att('name', collection.name);
|
||||
root.att('tests', _.get(newman, 'summary.run.stats.tests.total', 'unknown'));
|
||||
|
||||
cache = _.transform(report, function (accumulator, execution) {
|
||||
accumulator[execution.item.id] = accumulator[execution.id] || [];
|
||||
accumulator[execution.item.id].push(execution);
|
||||
}, {});
|
||||
|
||||
timestamp = new Date(_.get(newman, 'summary.run.timings.started')).toISOString();
|
||||
|
||||
_.forEach(cache, function (executions, itemId) {
|
||||
var suite = root.ele('testsuite'),
|
||||
currentItem,
|
||||
tests = {},
|
||||
errors = 0,
|
||||
failures = 0,
|
||||
errorMessages;
|
||||
|
||||
collection.forEachItem(function (item) {
|
||||
(item.id === itemId) && (currentItem = item);
|
||||
});
|
||||
|
||||
if (!currentItem) { return; }
|
||||
|
||||
suite.att('name', util.getFullName(currentItem));
|
||||
suite.att('id', currentItem.id);
|
||||
|
||||
suite.att('timestamp', timestamp);
|
||||
|
||||
_.forEach(executions, function (execution) {
|
||||
var iteration = execution.cursor.iteration,
|
||||
errored,
|
||||
msg = `Iteration: ${iteration}\n`;
|
||||
|
||||
// Process errors
|
||||
if (execution.requestError) {
|
||||
++errors;
|
||||
errored = true;
|
||||
msg += ('RequestError: ' + (execution.requestError.stack) + '\n');
|
||||
}
|
||||
msg += '\n---\n';
|
||||
_.forEach(['testScript', 'prerequestScript'], function (prop) {
|
||||
_.forEach(execution[prop], function (err) {
|
||||
if (err.error) {
|
||||
++errors;
|
||||
errored = true;
|
||||
msg = (msg + prop + 'Error: ' + (err.error.stack || err.error.message));
|
||||
msg += '\n---\n';
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (errored) {
|
||||
errorMessages = _.isString(errorMessages) ? (errorMessages + msg) : msg;
|
||||
}
|
||||
|
||||
// Process assertions
|
||||
_.forEach(execution.assertions, function (assertion) {
|
||||
var name = assertion.assertion,
|
||||
err = assertion.error;
|
||||
|
||||
if (err) {
|
||||
++failures;
|
||||
(_.isArray(tests[name]) ? tests[name].push(err) : (tests[name] = [err]));
|
||||
}
|
||||
else {
|
||||
tests[name] = [];
|
||||
}
|
||||
});
|
||||
if (execution.assertions) {
|
||||
suite.att('tests', execution.assertions.length);
|
||||
}
|
||||
else {
|
||||
suite.att('tests', 0);
|
||||
}
|
||||
|
||||
suite.att('failures', failures);
|
||||
suite.att('errors', errors);
|
||||
});
|
||||
|
||||
suite.att('time', _.mean(_.map(executions, function (execution) {
|
||||
executionTime = _.get(execution, 'response.responseTime') / 1000 || 0;
|
||||
testSuitesExecutionTime += executionTime;
|
||||
|
||||
return executionTime;
|
||||
})).toFixed(3));
|
||||
errorMessages && suite.ele('system-err').dat(errorMessages);
|
||||
|
||||
_.forOwn(tests, function (failures, name) {
|
||||
var testcase = suite.ele('testcase'),
|
||||
failure;
|
||||
|
||||
testcase.att('name', name);
|
||||
testcase.att('time', executionTime.toFixed(3));
|
||||
|
||||
// Set the same classname for all the tests
|
||||
testcase.att('classname', _.get(testcase.up(), 'attributes.name.value',
|
||||
classname));
|
||||
|
||||
if (failures && failures.length) {
|
||||
failure = testcase.ele('failure');
|
||||
failure.att('type', 'AssertionFailure');
|
||||
failure.dat('Failed ' + failures.length + ' times.');
|
||||
failure.dat('Collection JSON ID: ' + collection.id + '.');
|
||||
failure.dat('Collection name: ' + collection.name + '.');
|
||||
failure.dat('Request name: ' + util.getFullName(currentItem) + '.');
|
||||
failure.dat('Test description: ' + name + '.');
|
||||
if (failures.length !== 0) {
|
||||
failure.att('message', failures[0].message);
|
||||
failure.dat('Error message: ' + failures[0].message + '.');
|
||||
failure.dat('Stacktrace: ' + failures[0].stack + '.');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
root.att('time', testSuitesExecutionTime.toFixed(3));
|
||||
newman.exports.push({
|
||||
name: 'junit-reporter',
|
||||
default: 'newman-run-report.xml',
|
||||
path: reporterOptions.export,
|
||||
content: root.end({
|
||||
pretty: true,
|
||||
indent: ' ',
|
||||
newline: '\n',
|
||||
allowEmpty: false
|
||||
})
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = JunitReporter;
|
36
node_modules/newman/lib/reporters/progress.js
generated
vendored
Normal file
36
node_modules/newman/lib/reporters/progress.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
var progress = require('cli-progress'),
|
||||
ProgressReporter;
|
||||
|
||||
/**
|
||||
* Little reporter that generates a collection progress status bar on CLI.
|
||||
*
|
||||
* @param {Object} newman - A run object with event handler specification methods.
|
||||
* @param {Function} newman.on - An event setter method that provides hooks for reporting collection run progress.
|
||||
* @param {Object} reporterOptions - A set of reporter specific run options.
|
||||
* @param {Object} options - A set of generic collection run options.
|
||||
* @returns {*}
|
||||
*/
|
||||
ProgressReporter = function (newman, reporterOptions, options) {
|
||||
if (options.silent || reporterOptions.silent) {
|
||||
return;
|
||||
}
|
||||
|
||||
var bar = new progress.Bar({});
|
||||
|
||||
newman.on('start', function (err, o) {
|
||||
if (err) { return; }
|
||||
|
||||
bar.start(o.cursor.length * o.cursor.cycles, 0);
|
||||
});
|
||||
|
||||
newman.on('item', function () {
|
||||
bar.increment();
|
||||
});
|
||||
|
||||
newman.on('done', function () {
|
||||
bar.stop();
|
||||
});
|
||||
};
|
||||
|
||||
ProgressReporter.prototype.dominant = true;
|
||||
module.exports = ProgressReporter;
|
136
node_modules/newman/lib/run/export-file.js
generated
vendored
Normal file
136
node_modules/newman/lib/run/export-file.js
generated
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
var fs = require('fs'),
|
||||
nodePath = require('path'),
|
||||
|
||||
_ = require('lodash'),
|
||||
async = require('async'),
|
||||
mkdirp = require('mkdirp'),
|
||||
|
||||
// @todo: ES6: Change the sequence below to use object destructuring when Node v4 support is dropped
|
||||
joinPath = nodePath.join,
|
||||
parsePath = nodePath.parse,
|
||||
resolvePath = nodePath.resolve,
|
||||
|
||||
/**
|
||||
* The root path specifier
|
||||
*
|
||||
* @const
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
E = '',
|
||||
|
||||
/**
|
||||
* Default timestamp separator.
|
||||
*
|
||||
* @const
|
||||
* @private
|
||||
* @type {string}
|
||||
*/
|
||||
TS_SEP = '-',
|
||||
|
||||
/**
|
||||
* Writes the specified content to a file at the provided path.
|
||||
*
|
||||
* @param {Object} path - A set of path details for file writing.
|
||||
* @param {String|Buffer} content - The content to be written to the file.
|
||||
* @param {Object} options - A set of options for the current file write.
|
||||
* @param {Function} cb - The callback invoked when the file writing operation has completed, with/without errors.
|
||||
*/
|
||||
writeFile = function (path, content, options, cb) {
|
||||
fs.writeFile(path.unparsed, content, function (err) {
|
||||
cb(_.set(err, 'help',
|
||||
`error writing file "${path.unparsed}" for ${options.name || 'unknown-source'}`), path);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate a timestamp from date
|
||||
*
|
||||
* @param {Date=} date - The timestamp used to mark the exported file.
|
||||
* @param {String=} separator - The optional string with which to separate different sections of the timestamp,
|
||||
* defaults to TS_SEP
|
||||
* @returns {String} - yyyy-mm-dd-HH-MM-SS-MS-0
|
||||
*/
|
||||
timestamp = function (date, separator) {
|
||||
// use the iso string to ensure left padding and other stuff is taken care of
|
||||
return (date || new Date()).toISOString().replace(/[^\d]+/g, _.isString(separator) ? separator : TS_SEP);
|
||||
};
|
||||
|
||||
/**
|
||||
* Module whose job is to export a file which is in an export format.
|
||||
*
|
||||
* @param {Object} options - The set of file export options.
|
||||
* @param {String} options.path - The path to the exported file.
|
||||
* @param {String|Object} options.content - The JSON / stringified content that is to be written to the file.
|
||||
* @param {Function} done - The callback whose invocation marks the end of the file export routine.
|
||||
* @returns {*}
|
||||
*/
|
||||
module.exports = function (options, done) {
|
||||
// parse the path if one is available as string
|
||||
var path = _.isString(options.path) && parsePath(resolvePath(options.path)),
|
||||
content = _.isPlainObject(options.content) ? JSON.stringify(options.content, 0, 2) : (options.content || E);
|
||||
|
||||
// if a path was not provided by user, we need to prepare the default path. but create the default path only if one
|
||||
// is provided.
|
||||
if (!path && _.isString(options.default)) {
|
||||
path = parsePath(options.default);
|
||||
// delete the path and directory if one is detected when parsing defaults
|
||||
path.root = E;
|
||||
path.dir = 'newman';
|
||||
|
||||
// append timestamp
|
||||
path.name = `${path.name}-${timestamp()}0`; // @todo make -0 become incremental if file name exists
|
||||
path.base = path.name + path.ext;
|
||||
}
|
||||
// final check that path is valid
|
||||
if (!(path && path.base)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// now sore the unparsed result back for quick re-use during writing and a single place for unparsing
|
||||
path.unparsed = joinPath(path.dir, path.base);
|
||||
|
||||
// in case the path has a directory, ensure that the directory is available
|
||||
if (path.dir) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
mkdirp(path.dir)
|
||||
.then(() => {
|
||||
return next();
|
||||
})
|
||||
.catch((err) => {
|
||||
return next(_.set(err, 'help',
|
||||
`error creating path for file "${path.unparsed}" for ${options.name || 'unknown-source'}`));
|
||||
});
|
||||
},
|
||||
function (next) {
|
||||
fs.stat(path.unparsed, function (err, stat) { // eslint-disable-line handle-callback-err
|
||||
next(null, stat);
|
||||
});
|
||||
},
|
||||
function (stat, next) {
|
||||
var target;
|
||||
|
||||
// handle cases where the specified export path is a pre-existing directory
|
||||
if (stat && stat.isDirectory()) {
|
||||
target = parsePath(options.default);
|
||||
|
||||
// append timestamp
|
||||
// @todo make -0 become incremental if file name exists
|
||||
target.name += '-' + timestamp() + '0';
|
||||
target.base = target.name + target.ext;
|
||||
|
||||
path.unparsed = joinPath(path.unparsed, target.base);
|
||||
}
|
||||
|
||||
next(null, path);
|
||||
},
|
||||
function (path, next) {
|
||||
writeFile(path, content, options, next);
|
||||
}
|
||||
], done);
|
||||
}
|
||||
else {
|
||||
writeFile(path, content, options, done);
|
||||
}
|
||||
};
|
441
node_modules/newman/lib/run/index.js
generated
vendored
Normal file
441
node_modules/newman/lib/run/index.js
generated
vendored
Normal file
@@ -0,0 +1,441 @@
|
||||
var _ = require('lodash'),
|
||||
asyncEach = require('async/each'),
|
||||
sdk = require('postman-collection'),
|
||||
runtime = require('postman-runtime'),
|
||||
request = require('postman-request'),
|
||||
EventEmitter = require('eventemitter3'),
|
||||
SecureFS = require('./secure-fs'),
|
||||
RunSummary = require('./summary'),
|
||||
getOptions = require('./options'),
|
||||
exportFile = require('./export-file'),
|
||||
util = require('../util'),
|
||||
|
||||
/**
|
||||
* This object describes the various events raised by Newman, and what each event argument contains.
|
||||
* Error and cursor are present in all events.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
runtimeEvents = {
|
||||
beforeIteration: [],
|
||||
beforeItem: ['item'],
|
||||
beforePrerequest: ['events', 'item'],
|
||||
prerequest: ['executions', 'item'],
|
||||
beforeRequest: ['request', 'item'],
|
||||
request: ['response', 'request', 'item', 'cookies', 'history'],
|
||||
beforeTest: ['events', 'item'],
|
||||
test: ['executions', 'item'],
|
||||
item: ['item'],
|
||||
iteration: [],
|
||||
beforeScript: ['script', 'event', 'item'],
|
||||
script: ['execution', 'script', 'event', 'item']
|
||||
},
|
||||
|
||||
/**
|
||||
* load all the default reporters here. if you have new reporter, add it to this list
|
||||
* we know someone, who does not like dynamic requires
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
defaultReporters = {
|
||||
cli: require('../reporters/cli'),
|
||||
json: require('../reporters/json'),
|
||||
junit: require('../reporters/junit'),
|
||||
progress: require('../reporters/progress'),
|
||||
emojitrain: require('../reporters/emojitrain')
|
||||
},
|
||||
|
||||
/**
|
||||
* The object of known reporters and their install instruction in case the reporter is not loaded.
|
||||
* Pad message with two spaces since its a follow-up message for reporter warning.
|
||||
*
|
||||
* @private
|
||||
* @type {Object}
|
||||
*/
|
||||
knownReporterErrorMessages = {
|
||||
html: ' run `npm install newman-reporter-html`\n',
|
||||
teamcity: ' run `npm install newman-reporter-teamcity`\n'
|
||||
},
|
||||
|
||||
/**
|
||||
* Multiple ids or names entrypoint lookup strategy.
|
||||
*
|
||||
* @private
|
||||
* @type {String}
|
||||
*/
|
||||
MULTIENTRY_LOOKUP_STRATEGY = 'multipleIdOrName';
|
||||
|
||||
/**
|
||||
* Runs the collection, with all the provided options, returning an EventEmitter.
|
||||
*
|
||||
* @param {Object} options - The set of wrapped options, passed by the CLI parser.
|
||||
* @param {Collection|Object|String} options.collection - A JSON / Collection / String representing the collection.
|
||||
* @param {Object|String} options.environment - An environment JSON / file path for the current collection run.
|
||||
* @param {Object|String} options.globals - A globals JSON / file path for the current collection run.
|
||||
* @param {String} options.workingDir - Path of working directory that contains files needed for the collection run.
|
||||
* @param {String} options.insecureFileRead - If true, allow reading files outside of working directory.
|
||||
* @param {Object|String} options.iterationData - An iterationData JSON / file path for the current collection run.
|
||||
* @param {Object|String} options.reporters - A set of reporter names and their associated options for the current run.
|
||||
* @param {Object|String} options.cookieJar - A tough-cookie cookieJar / file path for the current collection run.
|
||||
* @param {String} options.exportGlobals - The relative path to export the globals file from the current run to.
|
||||
* @param {String} options.exportEnvironment - The relative path to export the environment file from the current run to.
|
||||
* @param {String} options.exportCollection - The relative path to export the collection from the current run to.
|
||||
* @param {String} options.exportCookieJar - The relative path to export the cookie jar from the current run to.
|
||||
* @param {Function} callback - The callback function invoked to mark the end of the collection run.
|
||||
* @returns {EventEmitter} - An EventEmitter instance with done and error event attachments.
|
||||
*/
|
||||
module.exports = function (options, callback) {
|
||||
// validate all options. it is to be noted that `options` parameter is option and is polymorphic
|
||||
(!callback && _.isFunction(options)) && (
|
||||
(callback = options),
|
||||
(options = {})
|
||||
);
|
||||
!_.isFunction(callback) && (callback = _.noop);
|
||||
|
||||
var emitter = new EventEmitter(), // @todo: create a new inherited constructor
|
||||
runner = new runtime.Runner(),
|
||||
stopOnFailure,
|
||||
entrypoint;
|
||||
|
||||
// get the configuration from various sources
|
||||
getOptions(options, function (err, options) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
// ensure that the collection option is present before starting a run
|
||||
if (!_.isObject(options.collection)) {
|
||||
return callback(new Error('expecting a collection to run'));
|
||||
}
|
||||
|
||||
// use client certificate list to allow different ssl certificates for
|
||||
// different URLs
|
||||
var sslClientCertList = options.sslClientCertList || [],
|
||||
// allow providing custom cookieJar
|
||||
cookieJar = options.cookieJar || request.jar();
|
||||
|
||||
// if sslClientCert option is set, put it at the end of the list to
|
||||
// match all URLs that didn't match in the list
|
||||
if (options.sslClientCert) {
|
||||
sslClientCertList.push({
|
||||
name: 'client-cert',
|
||||
matches: [sdk.UrlMatchPattern.MATCH_ALL_URLS],
|
||||
key: { src: options.sslClientKey },
|
||||
cert: { src: options.sslClientCert },
|
||||
passphrase: options.sslClientPassphrase
|
||||
});
|
||||
}
|
||||
|
||||
// iterates over the bail array and sets each item as an obj key with a value of boolean true
|
||||
// [item1, item2] => {item1: true, item2: true}
|
||||
if (_.isArray(options.bail)) {
|
||||
options.bail = _.transform(options.bail, function (result, value) {
|
||||
result[value] = true;
|
||||
}, {});
|
||||
}
|
||||
|
||||
// sets entrypoint to execute if options.folder is specified.
|
||||
if (options.folder) {
|
||||
entrypoint = { execute: options.folder };
|
||||
|
||||
// uses `multipleIdOrName` lookupStrategy in case of multiple folders.
|
||||
_.isArray(entrypoint.execute) && (entrypoint.lookupStrategy = MULTIENTRY_LOOKUP_STRATEGY);
|
||||
}
|
||||
|
||||
// sets stopOnFailure to true in case bail is used without any modifiers or with failure
|
||||
// --bail => stopOnFailure = true
|
||||
// --bail failure => stopOnFailure = true
|
||||
(typeof options.bail !== 'undefined' &&
|
||||
(options.bail === true || (_.isObject(options.bail) && options.bail.failure))) ?
|
||||
stopOnFailure = true : stopOnFailure = false;
|
||||
|
||||
// store summary object and other relevant information inside the emitter
|
||||
emitter.summary = new RunSummary(emitter, options);
|
||||
|
||||
// to store the exported content from reporters
|
||||
emitter.exports = [];
|
||||
|
||||
// expose the runner object for reporter and programmatic use
|
||||
emitter.runner = runner;
|
||||
|
||||
// now start the run!
|
||||
runner.run(options.collection, {
|
||||
stopOnFailure: stopOnFailure, // LOL, you just got trolled ¯\_(ツ)_/¯
|
||||
abortOnFailure: options.abortOnFailure, // used in integration tests, to be considered for a future release
|
||||
abortOnError: _.get(options, 'bail.folder'),
|
||||
iterationCount: options.iterationCount,
|
||||
environment: options.environment,
|
||||
globals: options.globals,
|
||||
entrypoint: entrypoint,
|
||||
data: options.iterationData,
|
||||
delay: {
|
||||
item: options.delayRequest
|
||||
},
|
||||
timeout: {
|
||||
global: options.timeout || 0,
|
||||
request: options.timeoutRequest || 0,
|
||||
script: options.timeoutScript || 0
|
||||
},
|
||||
fileResolver: new SecureFS(options.workingDir, options.insecureFileRead),
|
||||
requester: {
|
||||
useWhatWGUrlParser: true,
|
||||
cookieJar: cookieJar,
|
||||
followRedirects: _.has(options, 'ignoreRedirects') ? !options.ignoreRedirects : undefined,
|
||||
strictSSL: _.has(options, 'insecure') ? !options.insecure : undefined,
|
||||
timings: Boolean(options.verbose),
|
||||
extendedRootCA: options.sslExtraCaCerts,
|
||||
agents: _.isObject(options.requestAgents) ? options.requestAgents : undefined
|
||||
},
|
||||
certificates: sslClientCertList.length && new sdk.CertificateList({}, sslClientCertList)
|
||||
}, function (err, run) {
|
||||
if (err) { return callback(err); }
|
||||
|
||||
var callbacks = {},
|
||||
// ensure that the reporter option type polymorphism is handled
|
||||
reporters = _.isString(options.reporters) ? [options.reporters] : options.reporters,
|
||||
// keep a track of start assertion indices of legacy assertions
|
||||
legacyAssertionIndices = {};
|
||||
|
||||
// emit events for all the callbacks triggered by the runtime
|
||||
_.forEach(runtimeEvents, function (definition, eventName) {
|
||||
// intercept each runtime.* callback and expose a global object based event
|
||||
callbacks[eventName] = function (err, cursor) {
|
||||
var args = arguments,
|
||||
obj = { cursor };
|
||||
|
||||
// convert the arguments into an object by taking the key name reference from the definition
|
||||
// object
|
||||
_.forEach(definition, function (key, index) {
|
||||
obj[key] = args[index + 2]; // first two are err, cursor
|
||||
});
|
||||
|
||||
args = [eventName, err, obj];
|
||||
emitter.emit.apply(emitter, args); // eslint-disable-line prefer-spread
|
||||
};
|
||||
});
|
||||
|
||||
// add non generic callback handling
|
||||
_.assignIn(callbacks, {
|
||||
|
||||
/**
|
||||
* Emits event for start of the run. It injects/exposes additional objects useful for
|
||||
* programmatic usage and reporters
|
||||
*
|
||||
* @param {?Error} err - An Error instance / null object.
|
||||
* @param {Object} cursor - The run cursor instance.
|
||||
* @returns {*}
|
||||
*/
|
||||
start (err, cursor) {
|
||||
emitter.emit('start', err, {
|
||||
cursor,
|
||||
run
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Bubbles up console messages.
|
||||
*
|
||||
* @param {Object} cursor - The run cursor instance.
|
||||
* @param {String} level - The level of console logging [error, silent, etc].
|
||||
* @returns {*}
|
||||
*/
|
||||
console (cursor, level) {
|
||||
emitter.emit('console', null, {
|
||||
cursor: cursor,
|
||||
level: level,
|
||||
messages: _.slice(arguments, 2)
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* The exception handler for the current run instance.
|
||||
*
|
||||
* @todo Fix bug of arg order in runtime.
|
||||
* @param {Object} cursor - The run cursor.
|
||||
* @param {?Error} err - An Error instance / null object.
|
||||
* @returns {*}
|
||||
*/
|
||||
exception (cursor, err) {
|
||||
emitter.emit('exception', null, {
|
||||
cursor: cursor,
|
||||
error: err
|
||||
});
|
||||
},
|
||||
|
||||
assertion (cursor, assertions) {
|
||||
_.forEach(assertions, function (assertion) {
|
||||
var errorName = _.get(assertion, 'error.name', 'AssertionError');
|
||||
|
||||
!assertion && (assertion = {});
|
||||
|
||||
// store the legacy assertion index
|
||||
assertion.index && (legacyAssertionIndices[cursor.ref] = assertion.index);
|
||||
|
||||
emitter.emit('assertion', (assertion.passed ? null : {
|
||||
name: errorName,
|
||||
index: assertion.index,
|
||||
test: assertion.name,
|
||||
message: _.get(assertion, 'error.message', assertion.name || ''),
|
||||
|
||||
stack: errorName + ': ' + _.get(assertion, 'error.message', '') + '\n' +
|
||||
' at Object.eval sandbox-script.js:' + (assertion.index + 1) + ':' +
|
||||
((cursor && cursor.position || 0) + 1) + ')'
|
||||
}), {
|
||||
cursor: cursor,
|
||||
assertion: assertion.name,
|
||||
skipped: assertion.skipped,
|
||||
error: assertion.error,
|
||||
item: run.resolveCursor(cursor)
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Custom callback to override the `done` event to fire the end callback.
|
||||
*
|
||||
* @todo Do some memory cleanup here?
|
||||
* @param {?Error} err - An error instance / null passed from the done event handler.
|
||||
* @param {Object} cursor - The run instance cursor.
|
||||
* @returns {*}
|
||||
*/
|
||||
done (err, cursor) {
|
||||
// in case runtime faced an error during run, we do not process any other event and emit `done`.
|
||||
// we do it this way since, an error in `done` callback would have anyway skipped any intermediate
|
||||
// events or callbacks
|
||||
if (err) {
|
||||
emitter.emit('done', err, emitter.summary);
|
||||
callback(err, emitter.summary);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// we emit a `beforeDone` event so that reporters and other such addons can do computation before
|
||||
// the run is marked as done
|
||||
emitter.emit('beforeDone', null, {
|
||||
cursor: cursor,
|
||||
summary: emitter.summary
|
||||
});
|
||||
|
||||
_.forEach(['environment', 'globals', 'collection', 'cookie-jar'], function (item) {
|
||||
// fetch the path name from options if one is provided
|
||||
var path = _.get(options, _.camelCase(`export-${item}`));
|
||||
|
||||
// if the options have an export path, then add the item to export queue
|
||||
path && emitter.exports.push({
|
||||
name: item,
|
||||
default: `newman-${item}.json`,
|
||||
path: path,
|
||||
content: item === 'cookie-jar' ?
|
||||
cookieJar.toJSON() :
|
||||
_(emitter.summary[item].toJSON())
|
||||
.defaults({
|
||||
name: item
|
||||
})
|
||||
.merge({
|
||||
_postman_variable_scope: item,
|
||||
_postman_exported_at: (new Date()).toISOString(),
|
||||
_postman_exported_using: util.userAgent
|
||||
})
|
||||
.value()
|
||||
});
|
||||
});
|
||||
|
||||
asyncEach(emitter.exports, exportFile, function (err) {
|
||||
// we now trigger actual done event which we had overridden
|
||||
emitter.emit('done', err, emitter.summary);
|
||||
callback(err, emitter.summary);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
emitter.on('script', function (err, o) {
|
||||
// bubble special script name based events
|
||||
o && o.event && emitter.emit(o.event.listen + 'Script', err, o);
|
||||
});
|
||||
|
||||
emitter.on('beforeScript', function (err, o) {
|
||||
// bubble special script name based events
|
||||
o && o.event && emitter.emit(_.camelCase('before-' + o.event.listen + 'Script'), err, o);
|
||||
});
|
||||
|
||||
// initialise all the reporters
|
||||
!emitter.reporters && (emitter.reporters = {});
|
||||
_.isArray(reporters) && _.forEach(reporters, function (reporterName) {
|
||||
// disallow duplicate reporter initialisation
|
||||
if (_.has(emitter.reporters, reporterName)) { return; }
|
||||
|
||||
var Reporter;
|
||||
|
||||
try {
|
||||
// check if the reporter is an external reporter
|
||||
Reporter = require((function (name) { // ensure scoped packages are loaded
|
||||
var prefix = '',
|
||||
scope = (name.charAt(0) === '@') && name.substr(0, name.indexOf('/') + 1);
|
||||
|
||||
if (scope) {
|
||||
prefix = scope;
|
||||
name = name.substr(scope.length);
|
||||
}
|
||||
|
||||
return prefix + 'newman-reporter-' + name;
|
||||
}(reporterName)));
|
||||
}
|
||||
// @todo - maybe have a debug mode and log error there
|
||||
catch (error) {
|
||||
if (!defaultReporters[reporterName]) {
|
||||
// @todo: route this via print module to respect silent flags
|
||||
console.warn(`newman: could not find "${reporterName}" reporter`);
|
||||
console.warn(' ensure that the reporter is installed in the same directory as newman');
|
||||
|
||||
// print install instruction in case a known reporter is missing
|
||||
if (knownReporterErrorMessages[reporterName]) {
|
||||
console.warn(knownReporterErrorMessages[reporterName]);
|
||||
}
|
||||
else {
|
||||
console.warn(' please install reporter using npm\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// load local reporter if its not an external reporter
|
||||
!Reporter && (Reporter = defaultReporters[reporterName]);
|
||||
|
||||
try {
|
||||
// we could have checked _.isFunction(Reporter), here, but we do not do that so that the nature of
|
||||
// reporter error can be bubbled up
|
||||
Reporter && (emitter.reporters[reporterName] = new Reporter(emitter,
|
||||
_.get(options, ['reporter', reporterName], {}), options));
|
||||
}
|
||||
catch (error) {
|
||||
// if the reporter errored out during initialisation, we should not stop the run simply log
|
||||
// the error stack trace for debugging
|
||||
console.warn(`newman: could not load "${reporterName}" reporter`);
|
||||
|
||||
if (!defaultReporters[reporterName]) {
|
||||
// @todo: route this via print module to respect silent flags
|
||||
console.warn(` this seems to be a problem in the "${reporterName}" reporter.\n`);
|
||||
}
|
||||
console.warn(error);
|
||||
}
|
||||
});
|
||||
|
||||
// raise warning when more than one dominant reporters are used
|
||||
(function (reporters) {
|
||||
// find all reporters whose `dominant` key is set to true
|
||||
var conflicts = _.keys(_.transform(reporters, function (conflicts, reporter, name) {
|
||||
reporter.dominant && (conflicts[name] = true);
|
||||
}));
|
||||
|
||||
(conflicts.length > 1) && // if more than one dominant, raise a warning
|
||||
console.warn(`newman: ${conflicts.join(', ')} reporters might not work well together.`);
|
||||
}(emitter.reporters));
|
||||
|
||||
// we ensure that everything is async to comply with event paradigm and start the run
|
||||
setImmediate(function () {
|
||||
run.start(callbacks);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return emitter;
|
||||
};
|
396
node_modules/newman/lib/run/options.js
generated
vendored
Normal file
396
node_modules/newman/lib/run/options.js
generated
vendored
Normal file
@@ -0,0 +1,396 @@
|
||||
var _ = require('lodash'),
|
||||
fs = require('fs'),
|
||||
async = require('async'),
|
||||
Collection = require('postman-collection').Collection,
|
||||
VariableScope = require('postman-collection').VariableScope,
|
||||
CookieJar = require('tough-cookie').CookieJar,
|
||||
transformer = require('postman-collection-transformer'),
|
||||
liquidJSON = require('liquid-json'),
|
||||
parseCsv = require('csv-parse'),
|
||||
util = require('../util'),
|
||||
config = require('../config'),
|
||||
|
||||
/**
|
||||
* The message displayed when the specified collection file can't be loaded.
|
||||
*
|
||||
* @const
|
||||
* @type {String}
|
||||
*/
|
||||
COLLECTION_LOAD_ERROR_MESSAGE = 'collection could not be loaded',
|
||||
|
||||
/**
|
||||
* The message displayed when the specified iteration data file can't be loaded.
|
||||
*
|
||||
* @const
|
||||
* @type {String}
|
||||
*/
|
||||
ITERATION_DATA_LOAD_ERROR_MESSAGE = 'iteration data could not be loaded',
|
||||
|
||||
/**
|
||||
* The message displayed when the specified environment or globals file can't be loaded.
|
||||
*
|
||||
* @const
|
||||
* @type {String}
|
||||
*/
|
||||
LOAD_ERROR_MESSAGE = 'could not load ',
|
||||
|
||||
/**
|
||||
* The set of postman collection transformer options, to convert collection v1 to collection v2.
|
||||
*
|
||||
* @const
|
||||
* @type {Object}
|
||||
*/
|
||||
COLLECTION_TRANSFORMER_OPTION = { inputVersion: '1.0.0', outputVersion: '2.1.0' },
|
||||
|
||||
/**
|
||||
* Accepts an object, and extracts the property inside an object which is supposed to contain the required data.
|
||||
* In case of variables, it also extracts them into plain JS objects.
|
||||
*
|
||||
* @param {Object} source - The source wrapper object that may or may not contain inner wrapped properties.
|
||||
* @param {String} type - "environment" or "globals", etc.
|
||||
* @returns {Object} - The object representation of the current extracted property.
|
||||
*/
|
||||
extractModel = function (source, type) {
|
||||
source = source[type] || source; // extract object that holds variable. these usually come from cloud API
|
||||
if (!_.isObject(source)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// ensure we un-box the JSON if it comes from cloud-api or similar sources
|
||||
!source.values && _.isObject(source[type]) && (source = source[type]);
|
||||
|
||||
// we ensure that environment passed as array is converted to plain object. runtime does this too, but we do it
|
||||
// here for consistency of options passed to reporters
|
||||
return source;
|
||||
},
|
||||
|
||||
/**
|
||||
* Loads the given data of type from a specified external location
|
||||
*
|
||||
* @param {String} type - The type of data to load.
|
||||
* @param {String} location - The location to load from (file path or URL).
|
||||
* @param {Object} options - The set of wrapped options.
|
||||
* @param {function} cb - The callback function whose invocation marks the end of the external load routine.
|
||||
* @returns {*}
|
||||
*/
|
||||
externalLoader = function (type, location, options, cb) {
|
||||
return _.isString(location) ? util.fetchJson(type, location, options, function (err, data) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
return cb(null, extractModel(data, type));
|
||||
}) : cb(null, extractModel(location, type));
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method to process a collection and convert it to a V2 equivalent if necessary, and return it.
|
||||
*
|
||||
* @todo Drop support for the v1 collection format in Newman v5.
|
||||
* Reference: https://github.com/postmanlabs/newman/pull/1660
|
||||
*
|
||||
* @param {Object} collection The input collection, specified as a JSON object.
|
||||
* @param {Function} callback A handler function that consumes an error object and the processed collection.
|
||||
* @returns {*}
|
||||
*/
|
||||
processCollection = function (collection, callback) {
|
||||
if (util.isV1Collection(collection)) {
|
||||
// @todo: route this via print module to respect silent flags
|
||||
console.warn('newman: Newman v4 deprecates support for the v1 collection format');
|
||||
console.warn(' Use the Postman Native app to export collections in the v2 format\n');
|
||||
|
||||
return transformer.convert(collection, COLLECTION_TRANSFORMER_OPTION, callback);
|
||||
}
|
||||
|
||||
callback(null, collection);
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper function that manages the load of environments and globals
|
||||
*
|
||||
* @private
|
||||
* @param {String} type - The type of resource to load: collection, environment, etc.
|
||||
* @param {String|Object} value - The value derived from the CLI or run command.
|
||||
* @param {Object} options - The set of wrapped options.
|
||||
* @param {Function} callback - The function invoked when the scope has been loaded.
|
||||
*/
|
||||
loadScopes = function (type, value, options, callback) {
|
||||
var done = function (err, scope) {
|
||||
if (err) { return callback(new Error(LOAD_ERROR_MESSAGE + `${type}\n ${err.message || err}`)); }
|
||||
|
||||
if (!_.isObject(scope)) {
|
||||
return done(new Error(LOAD_ERROR_MESSAGE + type));
|
||||
}
|
||||
|
||||
callback(null, new VariableScope(VariableScope.isVariableScope(scope) ? scope.toJSON() : scope));
|
||||
};
|
||||
|
||||
if (_.isObject(value)) {
|
||||
return done(null, value);
|
||||
}
|
||||
|
||||
externalLoader(type, value, options, done);
|
||||
},
|
||||
|
||||
/**
|
||||
* Custom method to auto parse CSV values
|
||||
*
|
||||
* @private
|
||||
* @param {String} value - CSV field value
|
||||
* @param {Object} context - Context of field value
|
||||
* @param {Boolean} context.quoting - A boolean indicating if the field was surrounded by quotes.
|
||||
* @returns {String|Number|Date}
|
||||
*/
|
||||
csvAutoParse = function (value, context) {
|
||||
if (context.quoting) {
|
||||
// avoid parsing quoted values
|
||||
return value;
|
||||
}
|
||||
|
||||
if (util.isInt(value)) {
|
||||
return parseInt(value, 10);
|
||||
}
|
||||
|
||||
if (util.isFloat(value)) {
|
||||
return parseFloat(value);
|
||||
}
|
||||
|
||||
return value;
|
||||
},
|
||||
|
||||
/**
|
||||
* Custom configuration loaders for the required configuration keys.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
configLoaders = {
|
||||
|
||||
/**
|
||||
* The collection file load helper for the current run.
|
||||
*
|
||||
* @param {Object|String} value - The collection, specified as a JSON object, or the path to it's file.
|
||||
* @param {Object} options - The set of wrapped options.
|
||||
* @param {Function} callback - The callback function invoked to mark the end of the collection load routine.
|
||||
* @returns {*}
|
||||
*/
|
||||
collection: function (value, options, callback) {
|
||||
/**
|
||||
* The post collection load handler.
|
||||
*
|
||||
* @param {?Error} err - An Error instance / null, passed from the collection loader.
|
||||
* @param {Object} collection - The collection / raw JSON object, passed from the collection loader.
|
||||
* @returns {*}
|
||||
*/
|
||||
var done = function (err, collection) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
// ensure that the collection option is present before starting a run
|
||||
if (!_.isObject(collection)) {
|
||||
return callback(new Error(COLLECTION_LOAD_ERROR_MESSAGE));
|
||||
}
|
||||
|
||||
// ensure that the collection reference is an SDK instance
|
||||
// @todo - should this be handled by config loaders?
|
||||
collection = new Collection(Collection.isCollection(collection) ?
|
||||
// if the option contain an instance of collection, we simply clone it for future use
|
||||
// create a collection in case it is not one. user can send v2 JSON as a source and that will be
|
||||
// converted to a collection
|
||||
collection.toJSON() : collection);
|
||||
|
||||
callback(null, collection);
|
||||
};
|
||||
|
||||
// if the collection has been specified as an object, convert to V2 if necessary and return the result
|
||||
if (_.isObject(value)) {
|
||||
return processCollection(value, done);
|
||||
}
|
||||
|
||||
externalLoader('collection', value, options, function (err, data) {
|
||||
if (err) {
|
||||
return done(new Error(COLLECTION_LOAD_ERROR_MESSAGE +
|
||||
(err.help ? `\n ${err.help}` : '') +
|
||||
`\n ${err.message || err}`));
|
||||
}
|
||||
if (!_.isObject(data)) {
|
||||
return done(new Error(COLLECTION_LOAD_ERROR_MESSAGE));
|
||||
}
|
||||
|
||||
return processCollection(data, done);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* The environment configuration object, loaded for the current collection run.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
environment: loadScopes.bind(this, 'environment'),
|
||||
|
||||
/**
|
||||
* The object of globals, loaded for the collection run.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
globals: loadScopes.bind(this, 'globals'),
|
||||
|
||||
/**
|
||||
* Helper function to sanitize folder option.
|
||||
*
|
||||
* @param {String[]|String} value - The list of folders to execute
|
||||
* @param {Object} options - The set of wrapped options.
|
||||
* @param {Function} callback - The callback function invoked to mark the end of the folder load routine.
|
||||
* @returns {*}
|
||||
*/
|
||||
folder: function (value, options, callback) {
|
||||
if (!value.length) {
|
||||
return callback(); // avoids empty string or array
|
||||
}
|
||||
|
||||
if (Array.isArray(value) && value.length === 1) {
|
||||
return callback(null, value[0]); // avoids using multipleIdOrName strategy for a single item array
|
||||
}
|
||||
|
||||
callback(null, value);
|
||||
},
|
||||
|
||||
/**
|
||||
* The iterationData loader module, with support for JSON or CSV data files.
|
||||
*
|
||||
* @param {String|Object[]} location - The path to the iteration data file for the current collection run, or
|
||||
* the array of iteration data objects.
|
||||
* @param {Object} options - The set of wrapped options.
|
||||
* @param {Function} callback - The function invoked to indicate the end of the iteration data loading routine.
|
||||
* @returns {*}
|
||||
*/
|
||||
iterationData: function (location, options, callback) {
|
||||
if (_.isArray(location)) { return callback(null, location); }
|
||||
|
||||
util.fetch(location, function (err, data) {
|
||||
if (err) {
|
||||
return callback(new Error(ITERATION_DATA_LOAD_ERROR_MESSAGE + `\n ${err.message || err}`));
|
||||
}
|
||||
|
||||
// Try loading as a JSON, fall-back to CSV.
|
||||
async.waterfall([
|
||||
(cb) => {
|
||||
try {
|
||||
return cb(null, liquidJSON.parse(data.trim()));
|
||||
}
|
||||
catch (e) {
|
||||
return cb(null, undefined); // e masked to avoid displaying JSON parse errors for CSV files
|
||||
}
|
||||
},
|
||||
(json, cb) => {
|
||||
if (json) {
|
||||
return cb(null, json);
|
||||
}
|
||||
// Wasn't JSON
|
||||
parseCsv(data, {
|
||||
columns: true, // infer the columns names from the first row
|
||||
escape: '"', // escape character
|
||||
cast: csvAutoParse, // function to cast values of individual fields
|
||||
trim: true, // ignore whitespace immediately around the delimiter
|
||||
relax: true, // allow using quotes without escaping inside unquoted string
|
||||
relax_column_count: true, // ignore inconsistent columns count
|
||||
bom: true // strip the byte order mark (BOM) from the input string
|
||||
}, cb);
|
||||
}
|
||||
], (err, parsed) => {
|
||||
if (err) {
|
||||
return callback(new Error(ITERATION_DATA_LOAD_ERROR_MESSAGE + `\n ${err.message || err}`));
|
||||
}
|
||||
|
||||
callback(null, parsed);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
sslClientCertList: function (location, options, callback) {
|
||||
if (Array.isArray(location)) {
|
||||
return callback(null, location);
|
||||
}
|
||||
|
||||
if (typeof location !== 'string') {
|
||||
return callback(new Error('path for ssl client certificates list file must be a string'));
|
||||
}
|
||||
|
||||
fs.readFile(location, function (err, value) {
|
||||
if (err) {
|
||||
return callback(new Error(`unable to read the ssl client certificates file "${location}"`));
|
||||
}
|
||||
|
||||
try {
|
||||
value = liquidJSON.parse(value.toString(util.detectEncoding(value)).trim());
|
||||
}
|
||||
catch (e) {
|
||||
return callback(new Error(`the file at ${location} does not contain valid JSON data.`));
|
||||
}
|
||||
|
||||
// ensure that `sslClientCertList` is an array
|
||||
if (!Array.isArray(value)) {
|
||||
return callback(new Error('expected ssl client certificates list to be an array.'));
|
||||
}
|
||||
|
||||
return callback(null, value);
|
||||
});
|
||||
},
|
||||
|
||||
cookieJar: function (location, options, callback) {
|
||||
if (_.isObject(location) && location.constructor.name === 'CookieJar') {
|
||||
return callback(null, location);
|
||||
}
|
||||
|
||||
if (typeof location !== 'string') {
|
||||
return callback(new Error('cookieJar must be a path to a JSON file or a CookieJar instance'));
|
||||
}
|
||||
|
||||
fs.readFile(location, function (err, value) {
|
||||
if (err) {
|
||||
return callback(new Error(`unable to read the cookie jar file "${location}"`));
|
||||
}
|
||||
|
||||
try {
|
||||
value = CookieJar.fromJSON(value.toString());
|
||||
}
|
||||
catch (e) {
|
||||
return callback(new Error(`the file at ${location} does not contain valid JSON data.`));
|
||||
}
|
||||
|
||||
return callback(null, value);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* The helper function to load all file based information for the current collection run.
|
||||
*
|
||||
* @param {Object} options - The set of generic collection run options.
|
||||
* @param {Function} callback - The function called to mark the completion of the configuration load routine.
|
||||
* @returns {*}
|
||||
*/
|
||||
module.exports = function (options, callback) {
|
||||
// set newman version used for collection run
|
||||
options.newmanVersion = util.version;
|
||||
|
||||
// set working directory if not provided
|
||||
options.workingDir = options.workingDir || process.cwd();
|
||||
|
||||
// allow insecure file read by default
|
||||
options.insecureFileRead = Boolean(_.get(options, 'insecureFileRead', true));
|
||||
|
||||
config.get(options, { loaders: configLoaders, command: 'run' }, function (err, result) {
|
||||
if (err) { return callback(err); }
|
||||
|
||||
!_.isEmpty(options.globalVar) && _.forEach(options.globalVar, function (variable) {
|
||||
variable && (result.globals.set(variable.key, variable.value));
|
||||
});
|
||||
|
||||
!_.isEmpty(options.envVar) && _.forEach(options.envVar, function (variable) {
|
||||
variable && (result.environment.set(variable.key, variable.value));
|
||||
});
|
||||
|
||||
callback(null, result);
|
||||
});
|
||||
};
|
187
node_modules/newman/lib/run/secure-fs.js
generated
vendored
Normal file
187
node_modules/newman/lib/run/secure-fs.js
generated
vendored
Normal file
@@ -0,0 +1,187 @@
|
||||
const fs = require('fs'),
|
||||
_ = require('lodash'),
|
||||
path = require('path'),
|
||||
util = require('util'),
|
||||
Readable = require('stream').Readable,
|
||||
|
||||
PPERM_ERR = 'PPERM: insecure file access outside working directory',
|
||||
FUNCTION = 'function',
|
||||
DEPRECATED_SYNC_WRITE_STREAM = 'SyncWriteStream',
|
||||
EXPERIMENTAL_PROMISE = 'promises',
|
||||
|
||||
// Use simple character check instead of regex to prevent regex attack
|
||||
/*
|
||||
* Windows root directory can be of the following from
|
||||
*
|
||||
* | File System | Actual | Modified |
|
||||
* |-------------|------------------|-------------------|
|
||||
* | LFS (Local) | C:\Program | /C:/Program |
|
||||
* | UNC | \\Server\Program | ///Server/Program |
|
||||
*/
|
||||
isWindowsRoot = function (path) {
|
||||
const drive = path.charAt(1);
|
||||
|
||||
return ((path.charAt(0) === '/') &&
|
||||
((drive >= 'A' && drive <= 'Z') || (drive >= 'a' && drive <= 'z')) &&
|
||||
(path.charAt(2) === ':')) ||
|
||||
path.slice(0, 3) === '///'; // Modified UNC path
|
||||
},
|
||||
|
||||
stripTrailingSep = function (thePath) {
|
||||
if (thePath[thePath.length - 1] === path.sep) {
|
||||
return thePath.slice(0, -1);
|
||||
}
|
||||
|
||||
return thePath;
|
||||
},
|
||||
|
||||
pathIsInside = function (thePath, potentialParent) {
|
||||
// For inside-directory checking, we want to allow trailing slashes, so normalize.
|
||||
thePath = stripTrailingSep(thePath);
|
||||
potentialParent = stripTrailingSep(potentialParent);
|
||||
|
||||
// Node treats only Windows as case-insensitive in its path module; we follow those conventions.
|
||||
if (global.process.platform === 'win32') {
|
||||
thePath = thePath.toLowerCase();
|
||||
potentialParent = potentialParent.toLowerCase();
|
||||
}
|
||||
|
||||
return thePath.lastIndexOf(potentialParent, 0) === 0 &&
|
||||
(
|
||||
thePath[potentialParent.length] === path.sep ||
|
||||
thePath[potentialParent.length] === undefined
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Secure file resolver wrapper over fs. It only allow access to files inside working directory unless specified.
|
||||
*
|
||||
* @param {*} workingDir - Path of working directory
|
||||
* @param {*} [insecureFileRead=false] - If true, allow reading files outside working directory
|
||||
* @param {*} [fileWhitelist=[]] - List of allowed files outside of working directory
|
||||
*/
|
||||
function SecureFS (workingDir, insecureFileRead = false, fileWhitelist = []) {
|
||||
this._fs = fs;
|
||||
this._path = path;
|
||||
this.constants = this._fs.constants;
|
||||
|
||||
this.workingDir = workingDir;
|
||||
this.insecureFileRead = insecureFileRead;
|
||||
this.fileWhitelist = fileWhitelist;
|
||||
|
||||
this.isWindows = global.process.platform === 'win32';
|
||||
}
|
||||
|
||||
/**
|
||||
* Private method to resole the path based based on working directory
|
||||
*
|
||||
* @param {String} relOrAbsPath - Relative or absolute path to resolve
|
||||
* @param {Array} whiteList - A list of absolute path to whitelist
|
||||
*
|
||||
* @returns {String} The resolved path
|
||||
*/
|
||||
SecureFS.prototype._resolve = function (relOrAbsPath, whiteList) {
|
||||
// Special handling for windows absolute paths to work cross platform
|
||||
this.isWindows && isWindowsRoot(relOrAbsPath) && (relOrAbsPath = relOrAbsPath.substring(1));
|
||||
|
||||
// Resolve the path from the working directory. The file should always be resolved so that
|
||||
// cross os variations are mitigated
|
||||
let resolvedPath = this._path.resolve(this.workingDir, relOrAbsPath);
|
||||
|
||||
// Check file is within working directory
|
||||
if (!this.insecureFileRead && // insecureFile read disabled
|
||||
!pathIsInside(resolvedPath, this.workingDir) && // File not inside working directory
|
||||
!_.includes(whiteList, resolvedPath)) { // File not in whitelist
|
||||
// Exit
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return resolvedPath;
|
||||
};
|
||||
|
||||
/**
|
||||
* Asynchronous path resolver function
|
||||
*
|
||||
* @param {String} relOrAbsPath - Relative or absolute path to resolve
|
||||
* @param {Array} [whiteList] - A optional list of additional absolute path to whitelist
|
||||
* @param {Function} callback -
|
||||
*/
|
||||
SecureFS.prototype.resolvePath = function (relOrAbsPath, whiteList, callback) {
|
||||
if (!callback && typeof whiteList === FUNCTION) {
|
||||
callback = whiteList;
|
||||
whiteList = [];
|
||||
}
|
||||
|
||||
let resolvedPath = this._resolve(relOrAbsPath, _.concat(this.fileWhitelist, whiteList));
|
||||
|
||||
if (!resolvedPath) {
|
||||
return callback(new Error(PPERM_ERR));
|
||||
}
|
||||
|
||||
return callback(null, resolvedPath);
|
||||
};
|
||||
|
||||
/**
|
||||
* Synchronous path resolver function
|
||||
*
|
||||
* @param {String} relOrAbsPath - Relative or absolute path to resolve
|
||||
* @param {Array} [whiteList] - A optional list of additional absolute path to whitelist
|
||||
*
|
||||
* @returns {String} The resolved path
|
||||
*/
|
||||
SecureFS.prototype.resolvePathSync = function (relOrAbsPath, whiteList) {
|
||||
// Resolve the path from the working directory
|
||||
const resolvedPath = this._resolve(relOrAbsPath, _.concat(this.fileWhitelist, whiteList));
|
||||
|
||||
if (!resolvedPath) {
|
||||
throw new Error(PPERM_ERR);
|
||||
}
|
||||
|
||||
return resolvedPath;
|
||||
};
|
||||
|
||||
// Attach all functions in fs to postman-fs
|
||||
Object.getOwnPropertyNames(fs).map((prop) => {
|
||||
// Bail-out early to prevent fs module from logging warning for deprecated and experimental methods
|
||||
if (prop === DEPRECATED_SYNC_WRITE_STREAM || prop === EXPERIMENTAL_PROMISE || typeof fs[prop] !== FUNCTION) {
|
||||
return;
|
||||
}
|
||||
|
||||
SecureFS.prototype[prop] = fs[prop];
|
||||
});
|
||||
|
||||
// Override the required functions
|
||||
SecureFS.prototype.stat = function (path, callback) {
|
||||
this.resolvePath(path, (err, resolvedPath) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
return this._fs.stat(resolvedPath, callback);
|
||||
});
|
||||
};
|
||||
|
||||
SecureFS.prototype.createReadStream = function (path, options) {
|
||||
try {
|
||||
return this._fs.createReadStream(this.resolvePathSync(path), options);
|
||||
}
|
||||
catch (err) {
|
||||
// Create a fake read steam that emits and error and
|
||||
const ErrorReadStream = function () {
|
||||
// Replicating behavior of fs module of disabling emitClose on destroy
|
||||
Readable.call(this, { emitClose: false });
|
||||
|
||||
// Emit the error event with insure file access error
|
||||
this.emit('error', new Error(PPERM_ERR));
|
||||
|
||||
// Options exists and disables autoClose then don't destroy
|
||||
(options && !options.autoClose) || this.destroy();
|
||||
};
|
||||
|
||||
util.inherits(ErrorReadStream, Readable);
|
||||
|
||||
return new ErrorReadStream();
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = SecureFS;
|
408
node_modules/newman/lib/run/summary.js
generated
vendored
Normal file
408
node_modules/newman/lib/run/summary.js
generated
vendored
Normal file
@@ -0,0 +1,408 @@
|
||||
var _ = require('lodash'),
|
||||
sdk = require('postman-collection'),
|
||||
SerialiseError = require('serialised-error'),
|
||||
RunSummary;
|
||||
|
||||
/**
|
||||
* Creates and returns a RunSummary instance for the current collection run.
|
||||
*
|
||||
* @constructor
|
||||
* @param {EventEmitter} emitter - An EventEmitter instance with event handler attachments to add run information to.
|
||||
* @param {Object} options - A set of run summary creation options.
|
||||
*/
|
||||
RunSummary = function RunSummary (emitter, options) {
|
||||
// keep a copy of this instance since, we need to refer to this from various events
|
||||
var summary = this;
|
||||
|
||||
// and store the trackers and failures in the summary object itself
|
||||
_.assign(summary, /** @lends RunSummary.prototype */ {
|
||||
/**
|
||||
* The collection that is being executed.
|
||||
*
|
||||
* @type {Collection}
|
||||
*/
|
||||
collection: _.get(options, 'collection'),
|
||||
|
||||
/**
|
||||
* The environment that is being used during the run
|
||||
*
|
||||
* @type {VariableScope}
|
||||
*
|
||||
*/
|
||||
environment: _.get(options, 'environment'),
|
||||
|
||||
/**
|
||||
* Global variables being used during the run
|
||||
*
|
||||
* @type {VariableScope}
|
||||
*/
|
||||
globals: _.get(options, 'globals'),
|
||||
|
||||
/**
|
||||
* Holds information related to the run.
|
||||
*/
|
||||
run: {
|
||||
/**
|
||||
* Holds the statistics of the run. Each property in it is the item being tracked and has three numeric
|
||||
* properties - total, failed, pending
|
||||
*
|
||||
* @type {Object.<Object>}
|
||||
*/
|
||||
stats: {
|
||||
iterations: {},
|
||||
items: {},
|
||||
scripts: {},
|
||||
prerequests: {},
|
||||
requests: {},
|
||||
tests: {},
|
||||
assertions: {},
|
||||
testScripts: {},
|
||||
prerequestScripts: {}
|
||||
},
|
||||
|
||||
/**
|
||||
* Stores all generic timing information
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
timings: {
|
||||
/**
|
||||
* The average response time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
responseAverage: 0,
|
||||
|
||||
/**
|
||||
* The miminum response time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
responseMin: 0,
|
||||
|
||||
/**
|
||||
* The maximum response time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
responseMax: 0,
|
||||
|
||||
/**
|
||||
* Standard deviation of response time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
responseSd: 0,
|
||||
|
||||
/**
|
||||
* The average DNS lookup time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
dnsAverage: 0,
|
||||
|
||||
/**
|
||||
* The minimum DNS lookup time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
dnsMin: 0,
|
||||
|
||||
/**
|
||||
* The maximum DNS lookup time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
dnsMax: 0,
|
||||
|
||||
/**
|
||||
* Standard deviation of DNS lookup time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
dnsSd: 0,
|
||||
|
||||
/**
|
||||
* The average first byte time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
firstByteAverage: 0,
|
||||
|
||||
/**
|
||||
* The minimum first byte time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
firstByteMin: 0,
|
||||
|
||||
/**
|
||||
* The maximum first byte time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
firstByteMax: 0,
|
||||
|
||||
/**
|
||||
* Standard deviation of first byte time of the run
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
firstByteSd: 0
|
||||
},
|
||||
|
||||
/**
|
||||
* Stores detailed information about the order of execution, request, response and assertions
|
||||
*
|
||||
* @type {Array<Object>}
|
||||
*/
|
||||
executions: [],
|
||||
|
||||
/**
|
||||
* Stores information on data transfer made during the collection
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
transfers: {
|
||||
/**
|
||||
* The total data received as response to every request
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
responseTotal: 0
|
||||
},
|
||||
|
||||
/**
|
||||
* An array of all errors encountered during the run
|
||||
*
|
||||
* @type {Array.<Error>}
|
||||
*/
|
||||
failures: [],
|
||||
|
||||
/**
|
||||
* This stores any fatal error during the run that caused the run to abort prematurely.
|
||||
*
|
||||
* @type {Error}
|
||||
*/
|
||||
error: null
|
||||
}
|
||||
});
|
||||
|
||||
// track run timings (start and end)
|
||||
RunSummary.attachTimingTrackers(this, emitter);
|
||||
|
||||
// accumulate statistics on all event
|
||||
// for all types of events track the counters for the event and its corresponding "before" counterpart
|
||||
RunSummary.attachStatisticTrackers(this, emitter);
|
||||
|
||||
// accumulate statistics on requests - such as size and time
|
||||
RunSummary.attachRequestTracker(this, emitter);
|
||||
|
||||
// accumulate errors (failures) from all events
|
||||
RunSummary.attachFailureTrackers(this, emitter);
|
||||
|
||||
// accumulate all execution specific data in collection
|
||||
RunSummary.attachReportingTrackers(this, emitter);
|
||||
};
|
||||
|
||||
_.assign(RunSummary, {
|
||||
attachReportingTrackers (summary, emitter) {
|
||||
var cache = {},
|
||||
executions = summary.run.executions;
|
||||
|
||||
emitter.on('beforeItem', function (err, o) {
|
||||
if (err || !_.get(o, 'cursor.ref')) { return; }
|
||||
|
||||
cache[o.cursor.ref] = _.assignIn(cache[o.cursor.ref] || {}, {
|
||||
cursor: o.cursor,
|
||||
item: o.item
|
||||
});
|
||||
});
|
||||
|
||||
// save all responses in executions array
|
||||
emitter.on('request', function (err, o) {
|
||||
if (!_.get(o, 'cursor.ref')) { return; }
|
||||
|
||||
var execution = cache[o.cursor.ref] = (cache[o.cursor.ref] || {});
|
||||
|
||||
executions.push(_.assignIn(execution, {
|
||||
cursor: o.cursor,
|
||||
request: o.request,
|
||||
response: o.response,
|
||||
id: _.get(o, 'item.id')
|
||||
}, err && {
|
||||
requestError: err || undefined
|
||||
}));
|
||||
});
|
||||
|
||||
// save all script execution errors in each execution
|
||||
emitter.on('script', function (err, o) {
|
||||
if (!_.get(o, 'cursor.ref')) { return; }
|
||||
|
||||
var execution = cache[o.cursor.ref] = (cache[o.cursor.ref] || {}),
|
||||
eventName = o && o.event && (o.event.listen + 'Script');
|
||||
|
||||
// store the script error corresponding to the script event name
|
||||
err && (execution && eventName) && (execution[eventName] || (execution[eventName] = [])).push({
|
||||
error: err
|
||||
});
|
||||
});
|
||||
|
||||
// save all assertions in each execution
|
||||
emitter.on('assertion', function (err, o) {
|
||||
if (!_.get(o, 'cursor.ref')) { return; }
|
||||
|
||||
var execution = cache[o.cursor.ref] = (cache[o.cursor.ref] || {});
|
||||
|
||||
if (!execution) { return; }
|
||||
|
||||
(execution.assertions || (execution.assertions = [])).push({
|
||||
assertion: o.assertion,
|
||||
skipped: o.skipped,
|
||||
error: err || undefined
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
attachTimingTrackers (summary, emitter) {
|
||||
// mark the point when the run started
|
||||
// also mark the point when run completed and also store error if needed
|
||||
emitter.on('start', function () { summary.run.timings.started = Date.now(); });
|
||||
emitter.on('beforeDone', function () {
|
||||
summary.run.timings.completed = Date.now();
|
||||
});
|
||||
emitter.on('done', function (err) {
|
||||
err && (summary.error = err);
|
||||
});
|
||||
},
|
||||
attachStatisticTrackers (summary, emitter) {
|
||||
// accumulate statistics on all event
|
||||
// for all types of events track the counters for the event and its corresponding "before" counterpart
|
||||
_.forEach(summary.run.stats, function (tracker, name) {
|
||||
// the actual event names are singular than their plural trackers, so we make the name singular
|
||||
name = name.slice(0, -1); // remove last character
|
||||
|
||||
// populate initial values of trackers
|
||||
_.assign(tracker, { total: 0, pending: 0, failed: 0 });
|
||||
|
||||
// Set up common listeners for a set of events, which tracks how many times they were executed and records
|
||||
// the ones which had an error passed as first argument
|
||||
emitter.on(_.camelCase('before-' + name), function () {
|
||||
tracker.pending += 1;
|
||||
});
|
||||
|
||||
emitter.on(name, function (err) {
|
||||
// check pending so that, it does not negate for items that do not have a `before` counterpart
|
||||
tracker.pending && (tracker.pending -= 1);
|
||||
err && (tracker.failed += 1);
|
||||
tracker.total += 1;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
attachRequestTracker (summary, emitter) {
|
||||
// accumulate statistics on requests
|
||||
emitter.on('request', function (err, o) {
|
||||
if (err || !(o && o.response)) { return; }
|
||||
|
||||
var size = _.isFunction(o.response.size) && o.response.size(),
|
||||
time = o.response.responseTime,
|
||||
requestCount = summary.run.stats.requests.total,
|
||||
timings,
|
||||
timingPhases;
|
||||
|
||||
// compute the response size total
|
||||
size && (summary.run.transfers.responseTotal += (size.body || 0 + size.headers || 0));
|
||||
|
||||
// if there are redirects, get timings for the last request sent
|
||||
timings = _.last(_.get(o, 'history.execution.data'));
|
||||
timings = timings && timings.timings;
|
||||
timingPhases = timings && sdk.Response.timingPhases(timings);
|
||||
|
||||
(timingPhases || time) && _.forEach([
|
||||
'dns',
|
||||
'firstByte',
|
||||
'response'
|
||||
], (value) => {
|
||||
var currentValue = (value === 'response') ? time : (timingPhases && timingPhases[value]),
|
||||
previousAverage = summary.run.timings[`${value}Average`],
|
||||
previousVariance = Math.pow(summary.run.timings[`${value}Sd`], 2),
|
||||
delta1 = currentValue - previousAverage,
|
||||
delta2,
|
||||
currentVariance;
|
||||
|
||||
if (!currentValue) { return; }
|
||||
|
||||
// compute average time for the given phase of request
|
||||
summary.run.timings[`${value}Average`] =
|
||||
(previousAverage * (requestCount - 1) + currentValue) / requestCount;
|
||||
|
||||
// compute minimum time for the given phase of request
|
||||
if (!summary.run.timings[`${value}Min`]) {
|
||||
summary.run.timings[`${value}Min`] = currentValue;
|
||||
}
|
||||
else {
|
||||
summary.run.timings[`${value}Min`] =
|
||||
Math.min(summary.run.timings[`${value}Min`], currentValue);
|
||||
}
|
||||
|
||||
// compute maximum time the given phase of request
|
||||
summary.run.timings[`${value}Max`] = Math.max(summary.run.timings[`${value}Max`], currentValue);
|
||||
|
||||
// compute standard deviation for the given phase of request
|
||||
// refer Welford's online algorithm from
|
||||
// https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
|
||||
delta2 = currentValue - summary.run.timings[`${value}Average`];
|
||||
currentVariance = (previousVariance * (requestCount - 1) + (delta1 * delta2)) / requestCount;
|
||||
summary.run.timings[`${value}Sd`] = Math.sqrt(currentVariance);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
attachFailureTrackers (summary, emitter) {
|
||||
var eventsToTrack = ['beforeIteration', 'iteration', 'beforeItem', 'item', 'beforeScript', 'script',
|
||||
'beforePrerequest', 'prerequest', 'beforeRequest', 'request', 'beforeTest', 'test', 'beforeAssertion',
|
||||
'assertion'];
|
||||
|
||||
// accumulate failures of all events
|
||||
// NOTE that surrogate events (which throw duplicate arguments) are not recorded
|
||||
_.forEach(eventsToTrack, function (event) {
|
||||
// push failures sent from "before" events
|
||||
emitter.on(event, function (err, o) {
|
||||
if (!err) { return; }
|
||||
|
||||
var item = o && o.item,
|
||||
source = event;
|
||||
|
||||
// in case of user script error, point to the line and column of the script and its type
|
||||
if (event === 'script') {
|
||||
o.event && (source = o.event.listen + '-script');
|
||||
if (err.stacktrace && err.stacktrace[0] && err.stacktrace[0].lineNumber) {
|
||||
source += (':' + (err.stacktrace[0].lineNumber - 2));
|
||||
err.stacktrace[0].columnNumber && (source += (':' + err.stacktrace[0].columnNumber));
|
||||
}
|
||||
}
|
||||
// assertion errors need to know which assertion in the test was this
|
||||
else if (event === 'assertion') {
|
||||
_.has(err, 'index') && (source += (':' + err.index));
|
||||
source += ' in test-script';
|
||||
}
|
||||
|
||||
// if this is a plain error, convert it to serialised error
|
||||
if (err.stack && !err.stacktrace) {
|
||||
err = new SerialiseError(err, true);
|
||||
}
|
||||
|
||||
summary.run.failures.push({
|
||||
error: err,
|
||||
at: source,
|
||||
source: item || undefined,
|
||||
parent: item && item.__parent && item.__parent.__parent || undefined,
|
||||
cursor: o.cursor || {}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = RunSummary;
|
290
node_modules/newman/lib/util.js
generated
vendored
Normal file
290
node_modules/newman/lib/util.js
generated
vendored
Normal file
@@ -0,0 +1,290 @@
|
||||
var fs = require('fs'),
|
||||
{ URL } = require('url'),
|
||||
|
||||
_ = require('lodash'),
|
||||
chardet = require('chardet'),
|
||||
filesize = require('filesize'),
|
||||
prettyms = require('pretty-ms'),
|
||||
liquidJSON = require('liquid-json'),
|
||||
request = require('postman-request'),
|
||||
|
||||
util,
|
||||
version = require('../package.json').version,
|
||||
|
||||
SEP = ' / ',
|
||||
|
||||
/**
|
||||
* The auxiliary character used to prettify file sizes from raw byte counts.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
FILESIZE_OPTIONS = { spacer: '' },
|
||||
|
||||
/**
|
||||
* Maps the charset returned by chardet to node buffer ones
|
||||
*
|
||||
* @constant
|
||||
* @type {Object}
|
||||
*/
|
||||
CHARDET_BUFF_MAP = {
|
||||
ASCII: 'ascii',
|
||||
'UTF-8': 'utf8',
|
||||
'UTF-16LE': 'utf16le',
|
||||
'ISO-8859-1': 'latin1'
|
||||
},
|
||||
|
||||
POSTMAN_API_HOST = 'api.getpostman.com',
|
||||
|
||||
POSTMAN_API_URL = 'https://' + POSTMAN_API_HOST,
|
||||
|
||||
/**
|
||||
* Map of resource type and its equivalent API pathname.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
POSTMAN_API_PATH_MAP = {
|
||||
collection: 'collections',
|
||||
environment: 'environments'
|
||||
},
|
||||
|
||||
API_KEY_HEADER = 'X-Api-Key',
|
||||
|
||||
USER_AGENT_VALUE = 'Newman/' + version,
|
||||
|
||||
// Matches valid Postman UID, case insensitive.
|
||||
// Same used for validation on the Postman API side.
|
||||
UID_REGEX = /^[0-9A-Z]+-[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i;
|
||||
|
||||
util = {
|
||||
|
||||
/**
|
||||
* The raw newman version, taken from package.json in the root directory
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
version: version,
|
||||
|
||||
/**
|
||||
* The user agent that this newman identifies as.
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
userAgent: USER_AGENT_VALUE,
|
||||
|
||||
/**
|
||||
* A utility helper method that prettifies and returns raw millisecond counts.
|
||||
*
|
||||
* @param {Number} ms - The raw millisecond count, usually from response times.
|
||||
* @returns {String} - The prettified time, scaled to units of time, depending on the input value.
|
||||
*/
|
||||
prettyms: function (ms) {
|
||||
if (ms < 1) {
|
||||
return `${parseInt(ms * 1000, 10)}µs`;
|
||||
}
|
||||
|
||||
return (ms < 1998) ? `${parseInt(ms, 10)}ms` : prettyms(ms || 0);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the time object with all values in largest time unit possible as strings.
|
||||
*
|
||||
* @param {Object} obj - {event1: time1, event2: time2, ...} (time in milliseconds)
|
||||
* @returns {Object} - {event1: time1, event2: time2, ...} (time in string with appropriate unit)
|
||||
*/
|
||||
beautifyTime: function (obj) {
|
||||
return _.forEach(obj, (value, key) => {
|
||||
// convert only non-zero values
|
||||
value && (obj[key] = this.prettyms(value));
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* A utility helper method to prettify byte counts into human readable strings.
|
||||
*
|
||||
* @param {Number} bytes - The raw byte count, usually from computed response sizes.
|
||||
* @returns {String} - The prettified size, suffixed with scaled units, depending on the actual value provided.
|
||||
*/
|
||||
filesize: function (bytes) {
|
||||
return filesize(bytes || 0, FILESIZE_OPTIONS);
|
||||
},
|
||||
|
||||
/**
|
||||
* Resolves the fully qualified name for the provided item
|
||||
*
|
||||
* @param {PostmanItem|PostmanItemGroup} item The item for which to resolve the full name
|
||||
* @param {?String} [separator=SEP] The separator symbol to join path name entries with
|
||||
* @returns {String} The full name of the provided item, including prepended parent item names
|
||||
* @private
|
||||
*/
|
||||
getFullName: function (item, separator) {
|
||||
if (_.isEmpty(item) || !_.isFunction(item.parent) || !_.isFunction(item.forEachParent)) { return; }
|
||||
|
||||
var chain = [];
|
||||
|
||||
item.forEachParent(function (parent) { chain.unshift(parent.name || parent.id); });
|
||||
|
||||
item.parent() && chain.push(item.name || item.id); // Add the current item only if it is not the collection
|
||||
|
||||
return chain.join(_.isString(separator) ? separator : SEP);
|
||||
},
|
||||
|
||||
/**
|
||||
* Given a buffer, it tries to match relevant encoding of the buffer.
|
||||
*
|
||||
* @param {Buffer} buff - Buffer for which encoding needs to be determined
|
||||
* @returns {String|undefined} - Detected encoding of the given buffer
|
||||
*/
|
||||
detectEncoding: function (buff) {
|
||||
return CHARDET_BUFF_MAP[chardet.detect(buff)];
|
||||
},
|
||||
|
||||
/**
|
||||
* Loads JSON data from the given location.
|
||||
*
|
||||
* @param {String} type - The type of data to load.
|
||||
* @param {String} location - Can be an HTTP URL, a local file path or an UID.
|
||||
* @param {Object=} options - A set of options for JSON data loading.
|
||||
* @param {Object} options.postmanApiKey - API Key used to load the resources via UID from the Postman API.
|
||||
* @param {Function} callback - The function whose invocation marks the end of the JSON fetch routine.
|
||||
* @returns {*}
|
||||
*/
|
||||
|
||||
fetchJson: function (type, location, options, callback) {
|
||||
!callback && _.isFunction(options) && (callback = options, options = {});
|
||||
|
||||
var postmanApiKey = _.get(options, 'postmanApiKey'),
|
||||
headers = { 'User-Agent': USER_AGENT_VALUE };
|
||||
|
||||
// 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.
|
||||
if (!fs.existsSync(location) && POSTMAN_API_PATH_MAP[type] && postmanApiKey && UID_REGEX.test(location)) {
|
||||
location = `${POSTMAN_API_URL}/${POSTMAN_API_PATH_MAP[type]}/${location}`;
|
||||
headers[API_KEY_HEADER] = postmanApiKey;
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}, (err, response, body) => {
|
||||
if (err) {
|
||||
return callback(_.set(err, 'help', `unable to fetch data from url "${location}"`));
|
||||
}
|
||||
|
||||
try {
|
||||
_.isString(body) && (body = liquidJSON.parse(body.trim()));
|
||||
}
|
||||
catch (e) {
|
||||
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}`));
|
||||
|
||||
return callback(_.assign(error, {
|
||||
name: _.get(body, 'error.name', _.capitalize(resource) + 'FetchError'),
|
||||
help: `Error fetching the ${resource} from the provided URL. Ensure that the URL is valid.`
|
||||
}));
|
||||
}
|
||||
|
||||
return callback(null, body);
|
||||
}) :
|
||||
fs.readFile(location, function (err, value) {
|
||||
if (err) {
|
||||
return callback(_.set(err, 'help', `unable to read data from file "${location}"`));
|
||||
}
|
||||
|
||||
try {
|
||||
value = liquidJSON.parse(value.toString(util.detectEncoding(value)).trim());
|
||||
}
|
||||
catch (e) {
|
||||
return callback(_.set(e, 'help', `the file at "${location}" does not contain valid JSON data`));
|
||||
}
|
||||
|
||||
return callback(null, value);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Loads raw data from a location, useful for working with non JSON data such as CSV files.
|
||||
*
|
||||
* @param {String} location - The relative path / URL to the raw data file.
|
||||
* @param {Object=} options - A set of load options for the raw data file.
|
||||
* @param {Function} callback - The callback function whose invocation marks the end of the fetch routine.
|
||||
* @returns {*}
|
||||
*/
|
||||
fetch: function (location, options, callback) {
|
||||
!callback && _.isFunction(options) && (callback = options, options = {});
|
||||
|
||||
return (/^https?:\/\/.*/).test(location) ?
|
||||
// Load from URL
|
||||
request.get({ url: location }, (err, response, body) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
return callback(null, body);
|
||||
}) :
|
||||
fs.readFile(String(location), function (err, value) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
return callback(null, value.toString(util.detectEncoding(value)));
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks whether the given object is a v1 collection
|
||||
*
|
||||
* Reference: https://github.com/postmanlabs/postman-collection-transformer/blob/v2.6.2/lib/index.js#L44
|
||||
*
|
||||
* @param {Object} object - The Object to check for v1 collection compliance.
|
||||
* @returns {Boolean} - A boolean result indicating whether or not the passed object was a v1 collection.
|
||||
*/
|
||||
isV1Collection: function (object) {
|
||||
return Boolean(object && object.name && object.order && object.requests);
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper function to test if a given string is an integer.
|
||||
* Reference: [node-csv-parse]: https://github.com/adaltas/node-csv-parse/blob/v2.5.0/lib/index.js#L207
|
||||
*
|
||||
* @param {String} value - The string to test for.
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
isInt: function (value) {
|
||||
return (/^(-|\+)?([1-9]+[0-9]*)$/).test(value);
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper function to test if a given string is a float.
|
||||
* Reference: [node-csv-parse]: https://github.com/adaltas/node-csv-parse/blob/v2.5.0/lib/index.js#L210
|
||||
*
|
||||
* @param {String} value - The string to test for.
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
isFloat: function (value) {
|
||||
return (value - parseFloat(value) + 1) >= 0;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = util;
|
91
node_modules/newman/package.json
generated
vendored
Normal file
91
node_modules/newman/package.json
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"name": "newman",
|
||||
"version": "5.3.0",
|
||||
"description": "Command-line companion utility for Postman",
|
||||
"homepage": "https://github.com/postmanlabs/newman",
|
||||
"bugs": "https://github.com/postmanlabs/newman/issues",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/postmanlabs/newman.git"
|
||||
},
|
||||
"keywords": [
|
||||
"newman",
|
||||
"postman",
|
||||
"api",
|
||||
"testing",
|
||||
"ci",
|
||||
"rest-client",
|
||||
"rest"
|
||||
],
|
||||
"main": "index.js",
|
||||
"bin": {
|
||||
"newman": "./bin/newman.js"
|
||||
},
|
||||
"preferGlobal": true,
|
||||
"scripts": {
|
||||
"test": "npm run test-lint && npm run test-system && npm run test-unit && npm run test-integration && npm run test-cli && npm run test-library",
|
||||
"test-system": "node npm/test-system.js",
|
||||
"test-lint": "node npm/test-lint.js",
|
||||
"test-unit": "nyc --nycrc-path=.nycrc.js node npm/test-unit.js",
|
||||
"test-integration": "nyc --nycrc-path=.nycrc.js node npm/test-integration.js",
|
||||
"test-cli": "nyc --nycrc-path=.nycrc.js node npm/test-cli.js",
|
||||
"test-library": "nyc --nycrc-path=.nycrc.js node npm/test-library.js",
|
||||
"build-docs": "node npm/build-docs.js",
|
||||
"build-wiki": "node npm/build-wiki.js",
|
||||
"publish-docs": "node npm/publish-docs.js",
|
||||
"postpublish": "./npm/postpublish.sh",
|
||||
"publish-wiki": "node npm/publish-wiki.js"
|
||||
},
|
||||
"author": "Postman Labs <help@postman.com> (=)",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"async": "3.2.1",
|
||||
"chardet": "1.3.0",
|
||||
"cli-progress": "3.9.0",
|
||||
"cli-table3": "0.6.0",
|
||||
"colors": "1.4.0",
|
||||
"commander": "7.2.0",
|
||||
"csv-parse": "4.16.3",
|
||||
"eventemitter3": "4.0.7",
|
||||
"filesize": "8.0.0",
|
||||
"lodash": "4.17.21",
|
||||
"mkdirp": "1.0.4",
|
||||
"postman-collection": "4.1.0",
|
||||
"postman-collection-transformer": "4.1.3",
|
||||
"postman-request": "2.88.1-postman.30",
|
||||
"postman-runtime": "7.28.4",
|
||||
"pretty-ms": "7.0.1",
|
||||
"semver": "7.3.5",
|
||||
"serialised-error": "1.1.3",
|
||||
"tough-cookie": "3.0.1",
|
||||
"word-wrap": "1.2.3",
|
||||
"xmlbuilder": "15.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"chai": "^4.2.0",
|
||||
"dockerfile_lint": "^0.3.4",
|
||||
"editorconfig": "^0.15.3",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-plugin-jsdoc": "^36.1.0",
|
||||
"eslint-plugin-lodash": "^7.3.0",
|
||||
"eslint-plugin-mocha": "^9.0.0",
|
||||
"eslint-plugin-security": "^1.4.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"jsdoc": "^3.6.7",
|
||||
"jsdoc-to-markdown": "^7.0.0",
|
||||
"mocha": "^9.1.1",
|
||||
"nock": "^13.1.3",
|
||||
"nyc": "^15.1.0",
|
||||
"packity": "^0.3.2",
|
||||
"parse-gitignore": "^1.0.1",
|
||||
"postman-jsdoc-theme": "^0.0.3",
|
||||
"recursive-readdir": "^2.2.2",
|
||||
"server-destroy": "^1.0.1",
|
||||
"shelljs": "^0.8.4",
|
||||
"sinon": "^11.1.2",
|
||||
"xml2js": "^0.4.23"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user