From 582a24a2a3e75d8f7eeba2a6c522053de7821344 Mon Sep 17 00:00:00 2001 From: elssar Date: Wed, 22 Jul 2015 16:05:42 +0530 Subject: [PATCH 01/34] Created a basic Dockerfile - The docker image installs node version 0.12.6 and newman version 1.2.17 - Pass the collection url an environment variable ("COLLECTION_URL") while running docker and newman will run that collection --- LICENSE.md | 202 ++++++++++++++++++++++++++++++++++++++++ ubuntu_14_04/Dockerfile | 21 +++++ ubuntu_14_04/README.md | 9 ++ 3 files changed, 232 insertions(+) create mode 100644 LICENSE.md create mode 100644 ubuntu_14_04/Dockerfile create mode 100644 ubuntu_14_04/README.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e9dfe34 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,202 @@ + 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 2015 Postdot Technologies Pvt. Ltd. + + 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. + diff --git a/ubuntu_14_04/Dockerfile b/ubuntu_14_04/Dockerfile new file mode 100644 index 0000000..8e4ca4e --- /dev/null +++ b/ubuntu_14_04/Dockerfile @@ -0,0 +1,21 @@ +FROM ubuntu:14.04.2 + +MAINTAINER Postman Labs + +RUN apt-get update && apt-get install -y \ + curl \ + git \ + npm; + +ENV NODE_VERSION="0.12.6" \ + NEWMAN_VERSION="1.2.17" + +RUN npm install -g n && \ + n ${NODE_VERSION} && \ + npm install -g newman@${NEWMAN_VERSION}; + +WORKDIR /var/newman-docker + +VOLUME /tmp:/var/results + +CMD newman -u ${COLLECTION_URL} -H /var/results/newman-run.html diff --git a/ubuntu_14_04/README.md b/ubuntu_14_04/README.md new file mode 100644 index 0000000..2f8aa49 --- /dev/null +++ b/ubuntu_14_04/README.md @@ -0,0 +1,9 @@ +# Ubuntu 14.04 + + - To build, run + +`docker build . -t newman` +` + - To run, + + `docker -e "COLLECTION_URL=" -t newman From 56f3b212f3292036dc78d18194c61c36736d2e1f Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Wed, 22 Jul 2015 18:22:53 +0530 Subject: [PATCH 02/34] Added tests, package.json and travis configuration --- .gitignore | 2 ++ .travis.yml | 9 +++++++++ package.json | 30 ++++++++++++++++++++++++++++++ tests/dockerfiles-spec.js | 24 ++++++++++++++++++++++++ ubuntu_14_04/README.md | 6 +++--- 5 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 .travis.yml create mode 100644 package.json create mode 100644 tests/dockerfiles-spec.js diff --git a/.gitignore b/.gitignore index 9dbb58a..606f56e 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,5 @@ man/man1 man/man5 pyenv vendor/pkg/ +.idea +node_modules diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..a9afa71 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +node_js: + - "0.12" +before_install: + - npm install +script: + - npm test +after_success: + - echo "All done!" diff --git a/package.json b/package.json new file mode 100644 index 0000000..c288baa --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "newman-docker", + "version": "0.0.1", + "description": "This repository contains the Dockerfiles and tests for the Newman Docker images.", + "scripts": { + "test": "mocha tests/*-spec.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/postmanlabs/newman-docker.git" + }, + "keywords": [ + "postman", + "newman", + "docker", + "image" + ], + "author": "Postman Labs ", + "license": "Apache-2.0", + "bugs": { + "url": "https://github.com/postmanlabs/newman-docker/issues" + }, + "homepage": "https://github.com/postmanlabs/newman-docker#readme", + "devDependencies": { + "dockerode": "^2.2.2", + "expect.js": "0.3.1", + "mocha": "2.2.5", + "validate-dockerfile": "^1.6.0" + } +} diff --git a/tests/dockerfiles-spec.js b/tests/dockerfiles-spec.js new file mode 100644 index 0000000..194e989 --- /dev/null +++ b/tests/dockerfiles-spec.js @@ -0,0 +1,24 @@ +/** + * @fileoverview This test suite runs tests on the various versions of newman-docker. + */ + +var expect = require('expect.js'), + fs = require('fs'), + path = require('path'), + validateDockerfile = require('validate-dockerfile'); + +/* global describe, it */ +describe('Validate Dockerfiles', function () { + var versions = ['ubuntu_14_04']; // TODO: Decide how we want to automatically load versions. + versions.map(function (version) { + var dockerFilePath = path.join(__dirname, '..', version, 'Dockerfile'), + dockerFileContent = fs.readFileSync(dockerFilePath); + it('Docker file for "' + version + '" must be valid', function () { + var result = validateDockerfile(dockerFileContent.toString()); + if (!result.valid) { + console.log(JSON.stringify(result, null, 4)); // Helps debugging on the CI + } + expect(result.valid).to.be(true); + }); + }); +}); diff --git a/ubuntu_14_04/README.md b/ubuntu_14_04/README.md index 2f8aa49..6fb320c 100644 --- a/ubuntu_14_04/README.md +++ b/ubuntu_14_04/README.md @@ -2,8 +2,8 @@ - To build, run -`docker build . -t newman` -` +``docker build . -t newman`` + - To run, - `docker -e "COLLECTION_URL=" -t newman +``docker -e "COLLECTION_URL=" -t newman`` From 48613ad25323556f40788d09ba2b862d9a5a92b2 Mon Sep 17 00:00:00 2001 From: elssar Date: Thu, 23 Jul 2015 11:27:21 +0530 Subject: [PATCH 03/34] Changes to the Dockerfile - Changed node version to 0.10.6, so that none of newmans dependencies error out - Changed how newman is being run. Setup newman as the entrypoint, so the end user can pass arguments to newman directly, rather than set environment variables --- ubuntu_14_04/Dockerfile | 10 ++++------ ubuntu_14_04/README.md | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ubuntu_14_04/Dockerfile b/ubuntu_14_04/Dockerfile index 8e4ca4e..71e046e 100644 --- a/ubuntu_14_04/Dockerfile +++ b/ubuntu_14_04/Dockerfile @@ -7,15 +7,13 @@ RUN apt-get update && apt-get install -y \ git \ npm; -ENV NODE_VERSION="0.12.6" \ - NEWMAN_VERSION="1.2.17" +ENV NODE_VERSION "0.10.6" \ + NEWMAN_VERSION "1.2.17" RUN npm install -g n && \ n ${NODE_VERSION} && \ npm install -g newman@${NEWMAN_VERSION}; -WORKDIR /var/newman-docker +WORKDIR /etc/newman -VOLUME /tmp:/var/results - -CMD newman -u ${COLLECTION_URL} -H /var/results/newman-run.html +ENTRYPOINT ["newman"] diff --git a/ubuntu_14_04/README.md b/ubuntu_14_04/README.md index 6fb320c..5a2e700 100644 --- a/ubuntu_14_04/README.md +++ b/ubuntu_14_04/README.md @@ -6,4 +6,4 @@ - To run, -``docker -e "COLLECTION_URL=" -t newman`` +``docker -v :/etc/newman -t newman [args to newman]`` From 5dd8a83dba45badbf40e76f9470b849c2a8eaa1c Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Thu, 23 Jul 2015 13:54:35 +0530 Subject: [PATCH 04/34] use a better validator that is more configurable --- package.json | 4 +- tests/dockerfile_rules.yml | 141 +++++++++++++++++++++++++++++++++++++ tests/dockerfiles-spec.js | 15 ++-- 3 files changed, 153 insertions(+), 7 deletions(-) create mode 100644 tests/dockerfile_rules.yml diff --git a/package.json b/package.json index c288baa..8d7214c 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,9 @@ }, "homepage": "https://github.com/postmanlabs/newman-docker#readme", "devDependencies": { + "dockerfile_lint": "0.0.8", "dockerode": "^2.2.2", "expect.js": "0.3.1", - "mocha": "2.2.5", - "validate-dockerfile": "^1.6.0" + "mocha": "2.2.5" } } diff --git a/tests/dockerfile_rules.yml b/tests/dockerfile_rules.yml new file mode 100644 index 0000000..505820c --- /dev/null +++ b/tests/dockerfile_rules.yml @@ -0,0 +1,141 @@ +--- + profile: + name: "Default" + description: "Default Profile. Checks basic syntax." + general: + ref_url_base: "https://docs.docker.com/reference/builder/" + valid_instructions: + - "FROM" + - "MAINTAINER" + - "RUN" + - "CMD" + - "EXPOSE" + - "ENV" + - "ADD" + - "COPY" + - "ENTRYPOINT" + - "VOLUME" + - "USER" + - "WORKDIR" + - "ONBUILD" + instruction_regex: /(\\w+)\\s(.+$)/ + valid_instruction_regex: /^(CMD|FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD)(\s)?/i + ignore_regex: /^#/ + multiline_regex: /\\$/ + line_rules: + FROM: + paramSyntaxRegex: /^[a-z0-9./-]+(:[a-z0-9.]+)?$/ + rules: + - + label: "is_latest_tag" + regex: /latest/ + level: "info" + message: "base image uses 'latest' tag" + description: "using the 'latest' tag may cause unpredictable builds. It is recommended that a specific tag is used in the FROM line." + reference_url: + - "https://docs.docker.com/reference/builder/" + - "#from" + - + label: "no_tag" + regex: /^[:]/ + level: "warn" + message: "No tag is used" + description: "lorem ipsum tar" + reference_url: + - "https://docs.docker.com/reference/builder/" + - "#from" + MAINTAINER: + paramSyntaxRegex: /.+/ + rules: [] + RUN: + paramSyntaxRegex: /.+/ + rules: + - + label: "no_yum_clean_all" + regex: /yum ((?!clean all).)* .+/ + level: "warn" + message: "yum clean all is not used" + description: "the yum cache will remain in this layer making the layer unnecessarily large" + reference_url: "None" + - + label: "installing_ssh" + regex: /ssh/ + level: "warn" + message: "installing SSH in a container is not recommended" + description: "Do you really need SSH in this image?" + reference_url: "https://github.com/jpetazzo/nsenter" + CMD: + paramSyntaxRegex: /.+/ + rules: [] + EXPOSE: + paramSyntaxRegex: /^[0-9]+([0-9\s]+)?$/ + rules: [] + ENV: + paramSyntaxRegex: /^[a-zA-Z_]+[a-zA-Z0-9_]* .+$/ + rules: [] + ADD: + paramSyntaxRegex: /^(~?[A-z0-9\/_.-]+|https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&\/\/=]*))\s~?[A-z0-9\/_.-]+$/ + COPY: + paramSyntaxRegex: /.+/ + rules: [] + ENTRYPOINT: + paramSyntaxRegex: /.+/ + rules: [] + VOLUME: + paramSyntaxRegex: /^~?([A-z0-9\/_.-]+|\["[A-z0-9\/_.-]+"\])$/ + rules: [] + USER: + paramSyntaxRegex: /^[a-z_][a-z0-9_]{0,30}$/ + rules: [] + WORKDIR: + paramSyntaxRegex: /^~?[A-z0-9\/_.-]+$/ + rules: [] + ONBUILD: + paramSyntaxRegex: /.+/ + rules: [] + required_instructions: + - + instruction: "MAINTAINER" + count: 1 + level: "info" + message: "Maintainer is not defined" + description: "The MAINTAINER line is useful for identifying the author in the form of MAINTAINER Joe Smith " + reference_url: + - "https://docs.docker.com/reference/builder/" + - "#maintainer" + - + instruction: "EXPOSE" + count: 1 + level: "info" + message: "There is no 'EXPOSE' instruction" + description: "Without exposed ports how will the service of the container be accessed?" + reference_url: + - "https://docs.docker.com/reference/builder/" + - "#expose" + - + instruction: "ENTRYPOINT" + count: 1 + level: "info" + message: "There is no 'ENTRYPOINT' instruction" + description: "None" + reference_url: + - "https://docs.docker.com/reference/builder/" + - "#entrypoint" + - + instruction: "CMD" + count: 1 + level: "info" + message: "There is no 'CMD' instruction" + description: "None" + reference_url: + - "https://docs.docker.com/reference/builder/" + - "#cmd" + - + instruction: "USER" + count: 1 + level: "warn" + message: "No 'USER' instruction" + description: "The process(es) within the container may run as root and RUN instructions my be run as root" + reference_url: + - "https://docs.docker.com/reference/builder/" + - "#user" diff --git a/tests/dockerfiles-spec.js b/tests/dockerfiles-spec.js index 194e989..27c8014 100644 --- a/tests/dockerfiles-spec.js +++ b/tests/dockerfiles-spec.js @@ -5,20 +5,25 @@ var expect = require('expect.js'), fs = require('fs'), path = require('path'), - validateDockerfile = require('validate-dockerfile'); + DockerFileValidator = require('dockerfile_lint'); /* global describe, it */ describe('Validate Dockerfiles', function () { - var versions = ['ubuntu_14_04']; // TODO: Decide how we want to automatically load versions. + var versions = ['ubuntu_14_04'], + rules = fs.readFileSync(path.join(__dirname, 'dockerfile_rules.yml')), + validator = new DockerFileValidator(rules); // TODO: Decide how we want to automatically load versions. + versions.map(function (version) { var dockerFilePath = path.join(__dirname, '..', version, 'Dockerfile'), dockerFileContent = fs.readFileSync(dockerFilePath); + it('Docker file for "' + version + '" must be valid', function () { - var result = validateDockerfile(dockerFileContent.toString()); - if (!result.valid) { + var result = validator.validate(dockerFileContent.toString()), + numBadThings = result.error.count + result.warn.count; + if (!(numBadThings == 0)) { console.log(JSON.stringify(result, null, 4)); // Helps debugging on the CI } - expect(result.valid).to.be(true); + expect(numBadThings).to.be(0); }); }); }); From f859dd85de316872f5e82edea42a91fcaf534e9e Mon Sep 17 00:00:00 2001 From: elssar Date: Thu, 23 Jul 2015 14:05:55 +0530 Subject: [PATCH 05/34] Updated dockerfile linting rules --- tests/dockerfile_rules.yml | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/tests/dockerfile_rules.yml b/tests/dockerfile_rules.yml index 505820c..79199d7 100644 --- a/tests/dockerfile_rules.yml +++ b/tests/dockerfile_rules.yml @@ -103,15 +103,6 @@ reference_url: - "https://docs.docker.com/reference/builder/" - "#maintainer" - - - instruction: "EXPOSE" - count: 1 - level: "info" - message: "There is no 'EXPOSE' instruction" - description: "Without exposed ports how will the service of the container be accessed?" - reference_url: - - "https://docs.docker.com/reference/builder/" - - "#expose" - instruction: "ENTRYPOINT" count: 1 @@ -121,21 +112,3 @@ reference_url: - "https://docs.docker.com/reference/builder/" - "#entrypoint" - - - instruction: "CMD" - count: 1 - level: "info" - message: "There is no 'CMD' instruction" - description: "None" - reference_url: - - "https://docs.docker.com/reference/builder/" - - "#cmd" - - - instruction: "USER" - count: 1 - level: "warn" - message: "No 'USER' instruction" - description: "The process(es) within the container may run as root and RUN instructions my be run as root" - reference_url: - - "https://docs.docker.com/reference/builder/" - - "#user" From 5eb1cbdd86c71c92e601e4c92a15233e0dc9c6c0 Mon Sep 17 00:00:00 2001 From: elssar Date: Thu, 23 Jul 2015 14:06:42 +0530 Subject: [PATCH 06/34] Commented the ubuntu Dockerfile Also made a few changes - No longer installing curl and git - Using multiple ENV and CMD statements --- ubuntu_14_04/.dockerignore | 1 + ubuntu_14_04/Dockerfile | 37 ++++++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 ubuntu_14_04/.dockerignore diff --git a/ubuntu_14_04/.dockerignore b/ubuntu_14_04/.dockerignore new file mode 100644 index 0000000..b43bf86 --- /dev/null +++ b/ubuntu_14_04/.dockerignore @@ -0,0 +1 @@ +README.md diff --git a/ubuntu_14_04/Dockerfile b/ubuntu_14_04/Dockerfile index 71e046e..b893cf4 100644 --- a/ubuntu_14_04/Dockerfile +++ b/ubuntu_14_04/Dockerfile @@ -2,18 +2,37 @@ FROM ubuntu:14.04.2 MAINTAINER Postman Labs -RUN apt-get update && apt-get install -y \ - curl \ - git \ - npm; +# Set node version +ENV NODE_VERSION 0.10.6 -ENV NODE_VERSION "0.10.6" \ - NEWMAN_VERSION "1.2.17" +# Set newman version +ENV NEWMAN_VERSION 1.2.17 -RUN npm install -g n && \ - n ${NODE_VERSION} && \ - npm install -g newman@${NEWMAN_VERSION}; +# Install npm +RUN apt-get update && apt-get install -y npm; + +# Install node +RUN npm install -g n && n ${NODE_VERSION}; + +# Install newman +RUN npm install -g newman@${NEWMAN_VERSION}; + +# Set workdir to /etc/newman +# When running the image, mount the directory containing your collection to this location +# +# docker run -v :/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 newman_ubuntu1404 -c YourCollection.json.postman_collection \ +# -e YourEnvironment.postman_environment \ +# -H newman_report.html + ENTRYPOINT ["newman"] From c971bf0c595afddc9b84c5b46597f7c3123b70c1 Mon Sep 17 00:00:00 2001 From: elssar Date: Thu, 23 Jul 2015 17:38:29 +0530 Subject: [PATCH 07/34] Fixed a bug in the ubuntu Dockerfile - n requires curl, which was removed earlier - Docker somehow causes problems if node and newman are installed in separate RUN statements --- ubuntu_14_04/Dockerfile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ubuntu_14_04/Dockerfile b/ubuntu_14_04/Dockerfile index b893cf4..94d19f1 100644 --- a/ubuntu_14_04/Dockerfile +++ b/ubuntu_14_04/Dockerfile @@ -2,20 +2,21 @@ FROM ubuntu:14.04.2 MAINTAINER Postman Labs +# Install curl and npm +RUN apt-get update && apt-get install -y \ + curl \ + npm; + # Set node version ENV NODE_VERSION 0.10.6 # Set newman version ENV NEWMAN_VERSION 1.2.17 -# Install npm -RUN apt-get update && apt-get install -y npm; - -# Install node -RUN npm install -g n && n ${NODE_VERSION}; - -# Install newman -RUN npm install -g newman@${NEWMAN_VERSION}; +# Install node and newman +RUN npm install -g n && \ + n ${NODE_VERSION} && \ + npm install -g newman@${NEWMAN_VERSION}; # Set workdir to /etc/newman # When running the image, mount the directory containing your collection to this location From d4d92eb8cd11c5c0e591ff92d3c03c7d02ab903a Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Thu, 23 Jul 2015 14:45:36 +0530 Subject: [PATCH 08/34] try a basic docker build --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index a9afa71..cdf8c6c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,6 @@ before_install: script: - npm test after_success: + - cd ubuntu_14_04 + - docker build -t newman-docker-ubuntu-14_04 . - echo "All done!" From f2ba75ff426ec44f3d26e2d35946eed85c1accf0 Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Thu, 23 Jul 2015 15:45:08 +0530 Subject: [PATCH 09/34] manually install docker on travis --- .travis.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.travis.yml b/.travis.yml index cdf8c6c..6b58cb9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,26 @@ language: node_js node_js: - "0.12" +env: + global: + - "HOST_IP=$(/sbin/ifconfig venet0:0 | grep 'inet addr' | awk -F: '{print $2}' | awk '{print $1}')" + - DOCKER_HOST=tcp://$HOST_IP:2375 + - DOCKER_PORT_RANGE=2400:2500 + - SLIRP_PORTS=$(seq 2375 2500) before_install: + - sudo sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -" + - sudo sh -c "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" + - echo exit 101 | sudo tee /usr/sbin/policy-rc.d + - sudo chmod +x /usr/sbin/policy-rc.d - npm install +install: + - sudo apt-get -qqy update + - sudo apt-get -qqy install lxc lxc-docker-1.2.0 slirp + - sudo sudo usermod -aG docker "$USER" + - git clone git://github.com/cptactionhank/sekexe +before_script: + - "sekexe/run 'mount -t tmpfs -o size=8g tmpfs /var/lib/docker && docker -d -H tcp://0.0.0.0:2375' &" + - "while ! docker info &> /dev/null ; do sleep 1; done" script: - npm test after_success: From 5a7e0b65a8f076bf611741fc3dde4a7ae36d9ca1 Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Thu, 23 Jul 2015 15:51:21 +0530 Subject: [PATCH 10/34] use https to download docker --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6b58cb9..21f0a74 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ env: - SLIRP_PORTS=$(seq 2375 2500) before_install: - sudo sh -c "wget -qO- https://get.docker.io/gpg | apt-key add -" - - sudo sh -c "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" + - sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" - echo exit 101 | sudo tee /usr/sbin/policy-rc.d - sudo chmod +x /usr/sbin/policy-rc.d - npm install From c400a038e8f3b53cbc1c35e2df5a1d71cf8d407b Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Thu, 23 Jul 2015 18:15:44 +0530 Subject: [PATCH 11/34] adding tests to actually run newman docker --- .travis.yml | 7 +++++-- tests/data/collection.json | 35 +++++++++++++++++++++++++++++++++++ tests/data/env.json | 16 ++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/data/collection.json create mode 100644 tests/data/env.json diff --git a/.travis.yml b/.travis.yml index 21f0a74..6ebe34e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,9 +21,12 @@ install: before_script: - "sekexe/run 'mount -t tmpfs -o size=8g tmpfs /var/lib/docker && docker -d -H tcp://0.0.0.0:2375' &" - "while ! docker info &> /dev/null ; do sleep 1; done" + - "CWD=`pwd`" + - cd ubuntu_14_04 + - docker build -t newman-docker-ubuntu-14_04 . + - cd $CWD script: - npm test + - docker -v tests/data:/tmp -t newman -c /tmp/collection.json -e /tmp/env.json after_success: - - cd ubuntu_14_04 - - docker build -t newman-docker-ubuntu-14_04 . - echo "All done!" diff --git a/tests/data/collection.json b/tests/data/collection.json new file mode 100644 index 0000000..8d1fcde --- /dev/null +++ b/tests/data/collection.json @@ -0,0 +1,35 @@ +{ + "id": "4aaffd8a-c1d7-5a22-3bf0-79ecfbe5fbf0", + "name": "test issue #233", + "description": "Trying to reproduce https://github.com/postmanlabs/newman/issues/233", + "order": [ + "f53d5219-6036-31ca-bb44-1cea9c11bd42" + ], + "folders": [], + "timestamp": 1437633900852, + "owner": "61671", + "remoteLink": "", + "public": false, + "requests": [ + { + "id": "f53d5219-6036-31ca-bb44-1cea9c11bd42", + "headers": "", + "url": "http://{{serverloc}}", + "pathVariables": {}, + "preRequestScript": "", + "method": "GET", + "collectionId": "4aaffd8a-c1d7-5a22-3bf0-79ecfbe5fbf0", + "data": [], + "dataMode": "params", + "name": "http://{{serverloc}}", + "description": "", + "descriptionFormat": "html", + "time": 1437635444925, + "version": 2, + "responses": [], + "tests": "", + "currentHelper": "normal", + "helperAttributes": {} + } + ] +} \ No newline at end of file diff --git a/tests/data/env.json b/tests/data/env.json new file mode 100644 index 0000000..847d824 --- /dev/null +++ b/tests/data/env.json @@ -0,0 +1,16 @@ +{ + "id": "25c52d73-03ce-0305-ab32-3c50f9795895", + "name": "test_233", + "values": [ + { + "key": "serverloc", + "value": "httpbin.org", + "type": "text", + "name": "serverloc", + "enabled": true + } + ], + "timestamp": 1437635065317, + "synced": false, + "syncedFilename": "" +} From 44a251830723fc68b0369e81d69741ba080fb814 Mon Sep 17 00:00:00 2001 From: elssar Date: Thu, 23 Jul 2015 16:02:05 +0530 Subject: [PATCH 12/34] Wrote documentation --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ ubuntu_14_04/README.md | 33 ++++++++++++++++++++++++++++----- 2 files changed, 67 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 33ebee2..45b9ef2 100644 --- a/README.md +++ b/README.md @@ -1 +1,40 @@ # newman-docker + +[Newman](https://github.com/postmanlabs/newman) is a command-line collection runner for [Postman](http://getpostman.com). 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. + +This repository contains docker images for Newman + +Current images are + + - [Ubuntu 14.04, Newman 1.2.17](ubuntu_14_04) + +# Instructions + +Build the image, + +``` +docker build -t newman . +``` + +then run it + +``` +docker --volume="/home/elssar/collections:/etc/newman" -t newman --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" +``` +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 `/var/newman`, + +``` +docker --volume="/home/elssar/collection:/var/newman" -t newman --collection="/var/newman/Github.json.postman_collection" --environment="Github.postman_environment" --html="/var/newman/newman-report.html" +``` + - You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag. + +``` +docker --volume="/home/elssar/collections:/var/newman" --workdir="/var/newman" -t newman --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" +``` + +In case you don't need to save newmans 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 + +``` +docker -t newman --url="https://example.com/Github.json.postman_collection" +``` diff --git a/ubuntu_14_04/README.md b/ubuntu_14_04/README.md index 5a2e700..bf46678 100644 --- a/ubuntu_14_04/README.md +++ b/ubuntu_14_04/README.md @@ -1,9 +1,32 @@ -# Ubuntu 14.04 +# newman-docker Ubuntu 14.04 - - To build, run +This image runs newman 1.2.17 on node 0.10.6 on Ubuntu 14.04.2 -``docker build . -t newman`` +Build the image, - - To run, +``` +docker build -t newman_ubuntu1404 . +``` -``docker -v :/etc/newman -t newman [args to newman]`` +then run it + +``` +docker --volume="/home/elssar/collections:/etc/newman" -t newman_ubuntu1404 --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" +``` +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 `/var/newman`, + +``` +docker --volume="/home/elssar/collection:/var/newman" -t newman_ubuntu1404 --collection="/var/newman/Github.json.postman_collection" --environment="Github.postman_environment" --html="/var/newman/newman-report.html" +``` + - You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag. + +``` +docker --volume="/home/elssar/collections:/var/newman" --workdir="/var/newman" -t newman_ubuntu1404 --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" +``` + +In case you don't need to save newmans 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 + +``` +docker -t newman_ubuntu1404 --url="https://example.com/Github.json.postman_collection" +``` From f20db7437ffde9bae209d7d98eced5e73c94c3ff Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Thu, 23 Jul 2015 19:20:07 +0530 Subject: [PATCH 13/34] moved tests around, and added a test to run a sample collection --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6ebe34e..e28469a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,12 +21,9 @@ install: before_script: - "sekexe/run 'mount -t tmpfs -o size=8g tmpfs /var/lib/docker && docker -d -H tcp://0.0.0.0:2375' &" - "while ! docker info &> /dev/null ; do sleep 1; done" - - "CWD=`pwd`" - - cd ubuntu_14_04 - - docker build -t newman-docker-ubuntu-14_04 . - - cd $CWD + - docker build -t newman-docker-ubuntu-14_04 ./ubuntu_14_04 script: - npm test - - docker -v tests/data:/tmp -t newman -c /tmp/collection.json -e /tmp/env.json + - docker run -v $PWD/tests/data:/tmp/test_data -t newman-docker -c /tmp/test_data/collection.json -e -e /tmp/test_data/env.json after_success: - echo "All done!" From eda5acf97c0a099a605e2b473ff125778a8c4d65 Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Thu, 23 Jul 2015 19:31:53 +0530 Subject: [PATCH 14/34] correcting image tag x-O --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e28469a..e75a6ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,6 @@ before_script: - docker build -t newman-docker-ubuntu-14_04 ./ubuntu_14_04 script: - npm test - - docker run -v $PWD/tests/data:/tmp/test_data -t newman-docker -c /tmp/test_data/collection.json -e -e /tmp/test_data/env.json + - docker run -v $PWD/tests/data:/tmp/test_data -t newman-docker-ubuntu-14_04 -c /tmp/test_data/collection.json -e -e /tmp/test_data/env.json after_success: - echo "All done!" From 8c725539717a73391dd9c1c9dee91284d06bbc26 Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Thu, 23 Jul 2015 19:56:20 +0530 Subject: [PATCH 15/34] renamed the test collection and environment --- tests/data/collection.json | 6 +++--- tests/data/env.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/data/collection.json b/tests/data/collection.json index 8d1fcde..ce8947e 100644 --- a/tests/data/collection.json +++ b/tests/data/collection.json @@ -1,7 +1,7 @@ { "id": "4aaffd8a-c1d7-5a22-3bf0-79ecfbe5fbf0", - "name": "test issue #233", - "description": "Trying to reproduce https://github.com/postmanlabs/newman/issues/233", + "name": "Simple HTTPBin Collection", + "description": "Single GET", "order": [ "f53d5219-6036-31ca-bb44-1cea9c11bd42" ], @@ -32,4 +32,4 @@ "helperAttributes": {} } ] -} \ No newline at end of file +} diff --git a/tests/data/env.json b/tests/data/env.json index 847d824..5010b44 100644 --- a/tests/data/env.json +++ b/tests/data/env.json @@ -1,6 +1,6 @@ { "id": "25c52d73-03ce-0305-ab32-3c50f9795895", - "name": "test_233", + "name": "HttpBin Env", "values": [ { "key": "serverloc", From 80eeda9879adaf4a985e40b1bf27dec39d5cc354 Mon Sep 17 00:00:00 2001 From: elssar Date: Thu, 23 Jul 2015 20:29:12 +0530 Subject: [PATCH 16/34] Updated documentation with links to image on docker hub --- README.md | 8 ++++---- ubuntu_14_04/README.md | 14 ++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 45b9ef2..62de7bf 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This repository contains docker images for Newman Current images are - - [Ubuntu 14.04, Newman 1.2.17](ubuntu_14_04) + - [Ubuntu 14.04, Newman 1.2.17](ubuntu_14_04) - [postman/newman_ubuntu1404](https://registry.hub.docker.com/u/postman/newman_ubuntu1404/) # Instructions @@ -19,18 +19,18 @@ docker build -t newman . then run it ``` -docker --volume="/home/elssar/collections:/etc/newman" -t newman --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" +docker --volume="/home/postman/collections:/etc/newman" -t newman --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" ``` 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 `/var/newman`, ``` -docker --volume="/home/elssar/collection:/var/newman" -t newman --collection="/var/newman/Github.json.postman_collection" --environment="Github.postman_environment" --html="/var/newman/newman-report.html" +docker --volume="/home/postman/collection:/var/newman" -t newman --collection="/var/newman/Github.json.postman_collection" --environment="Github.postman_environment" --html="/var/newman/newman-report.html" ``` - You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag. ``` -docker --volume="/home/elssar/collections:/var/newman" --workdir="/var/newman" -t newman --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" +docker --volume="/home/postman/collections:/var/newman" --workdir="/var/newman" -t newman --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" ``` In case you don't need to save newmans 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 diff --git a/ubuntu_14_04/README.md b/ubuntu_14_04/README.md index bf46678..299f2c2 100644 --- a/ubuntu_14_04/README.md +++ b/ubuntu_14_04/README.md @@ -1,4 +1,4 @@ -# newman-docker Ubuntu 14.04 +# newman_ubuntu1404 This image runs newman 1.2.17 on node 0.10.6 on Ubuntu 14.04.2 @@ -8,21 +8,27 @@ Build the image, docker build -t newman_ubuntu1404 . ``` +Or get it from [docker hub](https://registry.hub.docker.com/u/postman/newman_ubuntu1404/) + +``` +docker pull postman/newman_ubuntu1404 +``` + then run it ``` -docker --volume="/home/elssar/collections:/etc/newman" -t newman_ubuntu1404 --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" +docker --volume="/home/postman/collections:/etc/newman" -t newman_ubuntu1404 --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" ``` 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 `/var/newman`, ``` -docker --volume="/home/elssar/collection:/var/newman" -t newman_ubuntu1404 --collection="/var/newman/Github.json.postman_collection" --environment="Github.postman_environment" --html="/var/newman/newman-report.html" +docker --volume="/home/postman/collection:/var/newman" -t newman_ubuntu1404 --collection="/var/newman/Github.json.postman_collection" --environment="Github.postman_environment" --html="/var/newman/newman-report.html" ``` - You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag. ``` -docker --volume="/home/elssar/collections:/var/newman" --workdir="/var/newman" -t newman_ubuntu1404 --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" +docker --volume="/home/postman/collections:/var/newman" --workdir="/var/newman" -t newman_ubuntu1404 --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" ``` In case you don't need to save newmans 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 From b83f5e790ba55e03003b2540d994eb0c49cd00c5 Mon Sep 17 00:00:00 2001 From: elssar Date: Sat, 25 Jul 2015 17:00:46 +0530 Subject: [PATCH 17/34] Renamed directory ubuntu_14_04 to ubuntu_1404 to conform with docker hub image name --- README.md | 2 +- {ubuntu_14_04 => ubuntu_1404}/.dockerignore | 0 {ubuntu_14_04 => ubuntu_1404}/Dockerfile | 0 {ubuntu_14_04 => ubuntu_1404}/README.md | 0 4 files changed, 1 insertion(+), 1 deletion(-) rename {ubuntu_14_04 => ubuntu_1404}/.dockerignore (100%) rename {ubuntu_14_04 => ubuntu_1404}/Dockerfile (100%) rename {ubuntu_14_04 => ubuntu_1404}/README.md (100%) diff --git a/README.md b/README.md index 62de7bf..eccc78e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This repository contains docker images for Newman Current images are - - [Ubuntu 14.04, Newman 1.2.17](ubuntu_14_04) - [postman/newman_ubuntu1404](https://registry.hub.docker.com/u/postman/newman_ubuntu1404/) + - [Ubuntu 14.04, Newman 1.2.17](ubuntu_1404) - [postman/newman_ubuntu1404](https://registry.hub.docker.com/u/postman/newman_ubuntu1404/) # Instructions diff --git a/ubuntu_14_04/.dockerignore b/ubuntu_1404/.dockerignore similarity index 100% rename from ubuntu_14_04/.dockerignore rename to ubuntu_1404/.dockerignore diff --git a/ubuntu_14_04/Dockerfile b/ubuntu_1404/Dockerfile similarity index 100% rename from ubuntu_14_04/Dockerfile rename to ubuntu_1404/Dockerfile diff --git a/ubuntu_14_04/README.md b/ubuntu_1404/README.md similarity index 100% rename from ubuntu_14_04/README.md rename to ubuntu_1404/README.md From 3804e397b74581af77d36cdd3818f5762315ff6a Mon Sep 17 00:00:00 2001 From: elssar Date: Sat, 25 Jul 2015 17:02:39 +0530 Subject: [PATCH 18/34] Fix tests --- tests/dockerfiles-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dockerfiles-spec.js b/tests/dockerfiles-spec.js index 27c8014..de50c24 100644 --- a/tests/dockerfiles-spec.js +++ b/tests/dockerfiles-spec.js @@ -9,7 +9,7 @@ var expect = require('expect.js'), /* global describe, it */ describe('Validate Dockerfiles', function () { - var versions = ['ubuntu_14_04'], + var versions = ['ubuntu_1404'], rules = fs.readFileSync(path.join(__dirname, 'dockerfile_rules.yml')), validator = new DockerFileValidator(rules); // TODO: Decide how we want to automatically load versions. From 604e09ae59b264d0cef4c9818d41079572191dfc Mon Sep 17 00:00:00 2001 From: elssar Date: Sat, 25 Jul 2015 17:06:19 +0530 Subject: [PATCH 19/34] Fix travis tests --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e75a6ec..091b26d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,9 +21,9 @@ install: before_script: - "sekexe/run 'mount -t tmpfs -o size=8g tmpfs /var/lib/docker && docker -d -H tcp://0.0.0.0:2375' &" - "while ! docker info &> /dev/null ; do sleep 1; done" - - docker build -t newman-docker-ubuntu-14_04 ./ubuntu_14_04 + - docker build -t newman-docker-ubuntu-1404 ./ubuntu_1404 script: - npm test - - docker run -v $PWD/tests/data:/tmp/test_data -t newman-docker-ubuntu-14_04 -c /tmp/test_data/collection.json -e -e /tmp/test_data/env.json + - docker run -v $PWD/tests/data:/tmp/test_data -t newman-docker-ubuntu-1404 -c /tmp/test_data/collection.json -e -e /tmp/test_data/env.json after_success: - echo "All done!" From a01918c92351f1ba2914cbf9b6cc05a2775f6eae Mon Sep 17 00:00:00 2001 From: elssar Date: Mon, 27 Jul 2015 14:06:22 +0530 Subject: [PATCH 20/34] Update docker tag used on travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 091b26d..6813670 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,9 +21,9 @@ install: before_script: - "sekexe/run 'mount -t tmpfs -o size=8g tmpfs /var/lib/docker && docker -d -H tcp://0.0.0.0:2375' &" - "while ! docker info &> /dev/null ; do sleep 1; done" - - docker build -t newman-docker-ubuntu-1404 ./ubuntu_1404 + - docker build -t newman_ubuntu1404 ./ubuntu_1404 script: - npm test - - docker run -v $PWD/tests/data:/tmp/test_data -t newman-docker-ubuntu-1404 -c /tmp/test_data/collection.json -e -e /tmp/test_data/env.json + - docker run -v $PWD/tests/data:/tmp/test_data -t newman_ubuntu1404 -c /tmp/test_data/collection.json -e -e /tmp/test_data/env.json after_success: - echo "All done!" From 45859ba75c541fdd1c6b8e5f5e7d786b58609da9 Mon Sep 17 00:00:00 2001 From: elssar Date: Mon, 27 Jul 2015 14:06:51 +0530 Subject: [PATCH 21/34] Now following semantic headings --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eccc78e..a4ea28a 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Current images are - [Ubuntu 14.04, Newman 1.2.17](ubuntu_1404) - [postman/newman_ubuntu1404](https://registry.hub.docker.com/u/postman/newman_ubuntu1404/) -# Instructions +#### Instructions Build the image, From 6c45c0834ddf2a16f840f7cf5e3c1ea07956cecf Mon Sep 17 00:00:00 2001 From: Shamasis Bhattacharya Date: Tue, 28 Jul 2015 02:21:04 +0530 Subject: [PATCH 22/34] Restructured README. Content pending. --- README.md | 71 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index a4ea28a..d641724 100644 --- a/README.md +++ b/README.md @@ -1,40 +1,63 @@ + + # newman-docker -[Newman](https://github.com/postmanlabs/newman) is a command-line collection runner for [Postman](http://getpostman.com). 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. + -This repository contains docker images for Newman +This repository contains docker images for Newman. -Current images are +Newman is a command-line collection runner for +Postman. It allows you to effortlessly run and test a +Postman Collections 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. - - [Ubuntu 14.04, Newman 1.2.17](ubuntu_1404) - [postman/newman_ubuntu1404](https://registry.hub.docker.com/u/postman/newman_ubuntu1404/) +**New to Docker?** Docker allows you to package an application with all of its dependencies into a standardised unit for +software development. Visit +https://www.docker.com/whatisdocker to read more about +how docker can drastically simplify development and deployment. -#### Instructions +## Using the docker image -Build the 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 installation guideline for +popular operating systems. Choose your operating system and follow the instructions. -``` -docker build -t newman . -``` +> 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. -then run it -``` -docker --volume="/home/postman/collections:/etc/newman" -t newman --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" -``` -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 `/var/newman`, +**Step 1:** -``` -docker --volume="/home/postman/collection:/var/newman" -t newman --collection="/var/newman/Github.json.postman_collection" --environment="Github.postman_environment" --html="/var/newman/newman-report.html" -``` - - You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag. +Pull the newman docker +image from docker hub: -``` -docker --volume="/home/postman/collections:/var/newman" --workdir="/var/newman" -t newman --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" +```terminal +docker pull postman/newman_ubuntu1404; ``` -In case you don't need to save newmans 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 +**Step 2:** +Run newman commands on the image: + +```terminal +docker -t postman/newman_ubuntu1404 --url="https://example.com/Github.json.postman_collection" ``` -docker -t newman --url="https://example.com/Github.json.postman_collection" -``` + +### Build the docker image from this repository + +- ensure docker is installed +- git clone this repository +- build the image +- run the image with a sample collection url + +## 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. + + +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. To know more about mounting volumes, visit +docker documentation on shared data volumes. \ No newline at end of file From 21cb357bc15746daecfd17d15ba08ee5fd902c2b Mon Sep 17 00:00:00 2001 From: elssar Date: Tue, 28 Jul 2015 19:58:54 +0530 Subject: [PATCH 23/34] Updated documentation with improved instructions --- README.md | 93 +++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 74 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index d641724..f9568e9 100644 --- a/README.md +++ b/README.md @@ -6,31 +6,60 @@ This repository contains docker images for Newman. -Newman is a command-line collection runner for -Postman. It allows you to effortlessly run and test a -Postman Collections directly from the -command-line. It is built with extensibility in mind so that you can easily integrate it with your continuous +Newman is a command-line collection runner for +Postman. It allows you to effortlessly run and test a +Postman Collections 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 +software development. Visit https://www.docker.com/whatisdocker to read more about how docker can drastically simplify development and deployment. ## Using the docker image -The docker image for Newman is available for download from our docker hub. You must have Docker installed in your +The docker image for Newman is available for download from our docker hub. You must have Docker installed in your system. Docker has extensive installation guideline for popular operating systems. 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 +> 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. +```terminal +docker run hello-world +``` + +You should get an output like this + +```terminal +Hello from Docker. +This message shows that your installation appears to be working correctly. + +To generate this message, Docker took the following steps: + 1. The Docker client contacted the Docker daemon. + 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. + (Assuming it was not already locally available.) + 3. The Docker daemon created a new container from that image which runs the + executable that produces the output you are currently reading. + 4. The Docker daemon streamed that output to the Docker client, which sent it + to your terminal. + +To try something more ambitious, you can run an Ubuntu container with: + $ docker run -it ubuntu bash + +For more examples and ideas, visit: + http://docs.docker.com/userguide/ +``` + +If instead you get any errors, then you need to either install, or fix your installation of docker. Docker has +extensive installation guidelines for popular +operating systems **Step 1:** -Pull the newman docker +Pull the newman docker image from docker hub: ```terminal @@ -42,22 +71,48 @@ docker pull postman/newman_ubuntu1404; Run newman commands on the image: ```terminal -docker -t postman/newman_ubuntu1404 --url="https://example.com/Github.json.postman_collection" +docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/4a287759fe7efe6b0f20" ``` ### Build the docker image from this repository -- ensure docker is installed -- git clone this repository -- build the image -- run the image with a sample collection url + +**Step 1:** + +Clone this repository: + +```terminal +git clone https://github.com/postmanlabs/newman-docker.git +``` + +**Step 2:** + +Build the image: + +```terminal +cd newman-docker/newman_ubuntu1404 +docker build -t newman_ubuntu1404 . +``` + +**Step 3:** + +Run a collection using the newman image: + +```terminal +docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/4a287759fe7efe6b0f20" +``` + ## 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. +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. -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. To know more about mounting volumes, visit -docker documentation on shared data volumes. \ No newline at end of file +```terminal +docker run -v /etc/collections:/etc/newman -t postman/newman_ubuntu1404:1.2.17 -c PostmanDemoServer.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). To know more about mounting volumes, visit +docker documentation on shared data volumes. From 0461755303059011e2e3b891db6f79d9f63ef929 Mon Sep 17 00:00:00 2001 From: Akshay Bist Date: Wed, 29 Jul 2015 11:56:59 +0530 Subject: [PATCH 24/34] Add examples to README Added a few examples to showcase how the docker image can be used. Also removed the huge "how to check whether docker is installed" section. --- README.md | 99 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index f9568e9..88ab304 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ - +# newman-docker -# newman-docker - - + This repository contains docker images for Newman. @@ -27,36 +25,6 @@ popular operating systems. Choose your operating system and follow the instr > to see if docker is installed correctly is to execute the command `docker run hello-world` and it should run without > errors. -```terminal -docker run hello-world -``` - -You should get an output like this - -```terminal -Hello from Docker. -This message shows that your installation appears to be working correctly. - -To generate this message, Docker took the following steps: - 1. The Docker client contacted the Docker daemon. - 2. The Docker daemon pulled the "hello-world" image from the Docker Hub. - (Assuming it was not already locally available.) - 3. The Docker daemon created a new container from that image which runs the - executable that produces the output you are currently reading. - 4. The Docker daemon streamed that output to the Docker client, which sent it - to your terminal. - -To try something more ambitious, you can run an Ubuntu container with: - $ docker run -it ubuntu bash - -For more examples and ideas, visit: - http://docs.docker.com/userguide/ -``` - -If instead you get any errors, then you need to either install, or fix your installation of docker. Docker has -extensive installation guidelines for popular -operating systems - **Step 1:** Pull the newman docker @@ -90,8 +58,7 @@ git clone https://github.com/postmanlabs/newman-docker.git Build the image: ```terminal -cd newman-docker/newman_ubuntu1404 -docker build -t newman_ubuntu1404 . +docker build -t postman/newman_ubuntu1404 docker-newman/newman_ubuntu1404 ``` **Step 3:** @@ -110,9 +77,65 @@ directory of your collection files into that location and provide the file refer ```terminal -docker run -v /etc/collections:/etc/newman -t postman/newman_ubuntu1404:1.2.17 -c PostmanDemoServer.json.postman_collection +# 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_ubuntu1404 --collection="PostmanDemoServer.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). To know more about mounting volumes, visit +available online, unless your collection requires an environment(as environments cannot be passed as URLs). + +To know more about mounting volumes, visit docker documentation on shared data volumes. + + +## Examples + +Run a local collection, pass an environment to it, and save the HTML report on the host. + +```terminal +docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ + --collection="PostmanDemoServer.json.postman_collection" \ + --environment="PostmanBin.postman_environment" \ + --html="newman-results.html" +``` + +Run a remote collection, pass it a local environment, and save JUnit XML test report on the host + +```terminal +docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ + --url="https://www.getpostman.com/collections/4a287759fe7efe6b0f20" \ + --environment="PostmanBin.postman_environment" \ + --testReportFile="newman-report.xml" +``` + + Import a Postman backup file, and save collections, environments, and globals + + ```terminal +docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 --import="Backup.postman_dump" --pretty +``` + +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 +} + +# +trap onExit EXIT; + +docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/4a287759fe7efe6b0f20" --exitCode; +``` From ecb74916d0ba2ec6db3fa6f78caf8e79324f23c6 Mon Sep 17 00:00:00 2001 From: Akshay Bist Date: Wed, 29 Jul 2015 12:01:11 +0530 Subject: [PATCH 25/34] Fixed a typo in the build example --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 88ab304..7b1c201 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,7 @@ directory of your collection files into that location and provide the file refer ```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_ubuntu1404 --collection="PostmanDemoServer.json.postman_collection" +docker run -v ~/collections:/etc/newman -t postman/ubuntu_1404 --collection="PostmanDemoServer.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 @@ -112,7 +112,7 @@ docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ Import a Postman backup file, and save collections, environments, and globals ```terminal -docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 --import="Backup.postman_dump" --pretty +docker run -v ~/collections:/etc/postman -t postman/ubuntu_1404 --import="Backup.postman_dump" --pretty ``` Use a script to run a collection and do something, for example deploy the build, if all the tests pass From 1cd692f32dd87ea8cc7e2e8ce3afd1f3a2bd58c2 Mon Sep 17 00:00:00 2001 From: Shamasis Bhattacharya Date: Wed, 29 Jul 2015 14:56:48 +0530 Subject: [PATCH 26/34] Formatted the examples in README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7b1c201..d588b42 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ --html="newman-results.html" ``` -Run a remote collection, pass it a local environment, and save JUnit XML test report on the host +
Run a remote collection, pass it a local environment, and save JUnit XML test report on the host ```terminal docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ @@ -109,13 +109,13 @@ docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ --testReportFile="newman-report.xml" ``` - Import a Postman backup file, and save collections, environments, and globals +
Import a Postman backup file, and save collections, environments, and globals ```terminal docker run -v ~/collections:/etc/postman -t postman/ubuntu_1404 --import="Backup.postman_dump" --pretty ``` -Use a script to run a collection and do something, for example deploy the build, if all the tests pass +
Use a script to run a collection and do something, for example deploy the build, if all the tests pass ```bash #/bin/bash From 60d2c4f1abc909f385799c143a5ad4b44b4b26c4 Mon Sep 17 00:00:00 2001 From: Shamasis Bhattacharya Date: Wed, 29 Jul 2015 15:04:40 +0530 Subject: [PATCH 27/34] Updated ubuntu1404 dockerfile to point correct email address --- ubuntu_1404/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ubuntu_1404/Dockerfile b/ubuntu_1404/Dockerfile index 94d19f1..afba6e1 100644 --- a/ubuntu_1404/Dockerfile +++ b/ubuntu_1404/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:14.04.2 -MAINTAINER Postman Labs +MAINTAINER Postman Labs # Install curl and npm RUN apt-get update && apt-get install -y \ From 516bc0ffd3b960d58c823afba23b80d6734e15ea Mon Sep 17 00:00:00 2001 From: Shamasis Bhattacharya Date: Thu, 30 Jul 2015 00:21:57 +0530 Subject: [PATCH 28/34] Updated README and package.json towards release/1.0.0 --- README.md | 4 ++-- package.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d588b42..926885d 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This repository contains docker images for Newman. Newman is a command-line collection runner for Postman. It allows you to effortlessly run and test a -Postman Collections directly from the +Postman Collections 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. @@ -31,7 +31,7 @@ Pull the from docker hub: ```terminal -docker pull postman/newman_ubuntu1404; +docker pull postman/newman_ubuntu1404 ``` **Step 2:** diff --git a/package.json b/package.json index 8d7214c..ccb307c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "newman-docker", - "version": "0.0.1", + "version": "1.0.0", "description": "This repository contains the Dockerfiles and tests for the Newman Docker images.", "scripts": { "test": "mocha tests/*-spec.js" @@ -23,7 +23,7 @@ "homepage": "https://github.com/postmanlabs/newman-docker#readme", "devDependencies": { "dockerfile_lint": "0.0.8", - "dockerode": "^2.2.2", + "dockerode": "2.2.2", "expect.js": "0.3.1", "mocha": "2.2.5" } From 3e496dc08ea193c754abfe2c314ccbdd9380210e Mon Sep 17 00:00:00 2001 From: Shamasis Bhattacharya Date: Thu, 30 Jul 2015 01:23:13 +0530 Subject: [PATCH 29/34] Added whale banner to README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d588b42..ac0c89e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# newman-docker + - +# newman-docker This repository contains docker images for Newman. From d6c92d423f35d234c6398f8eac3c40dbc329879c Mon Sep 17 00:00:00 2001 From: elssar Date: Thu, 30 Jul 2015 12:51:23 +0530 Subject: [PATCH 30/34] Change the postman collection url, and file used in examples and tests --- .gitignore | 1 + .travis.yml | 2 +- README.md | 18 ++-- .../JSONBlobCoreAPI.json.postman_collection | 97 +++++++++++++++++++ tests/data/collection.json | 35 ------- tests/data/env.json | 16 --- ubuntu_1404/README.md | 8 +- 7 files changed, 112 insertions(+), 65 deletions(-) create mode 100644 tests/data/JSONBlobCoreAPI.json.postman_collection delete mode 100644 tests/data/collection.json delete mode 100644 tests/data/env.json diff --git a/.gitignore b/.gitignore index 606f56e..d9fcbc7 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ pyenv vendor/pkg/ .idea node_modules +npm-debug.log* diff --git a/.travis.yml b/.travis.yml index 6813670..e90d904 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,6 @@ before_script: - docker build -t newman_ubuntu1404 ./ubuntu_1404 script: - npm test - - docker run -v $PWD/tests/data:/tmp/test_data -t newman_ubuntu1404 -c /tmp/test_data/collection.json -e -e /tmp/test_data/env.json + - docker run -v $PWD/tests/data:/etc/newman -t newman_ubuntu1404 -c JSONBlobCoreAPI.json.postman_collection after_success: - echo "All done!" diff --git a/README.md b/README.md index ac0c89e..a5d9000 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ docker pull postman/newman_ubuntu1404; Run newman commands on the image: ```terminal -docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/4a287759fe7efe6b0f20" +docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/df0a40ef41d570c48154" ``` ### Build the docker image from this repository @@ -66,7 +66,7 @@ docker build -t postman/newman_ubuntu1404 docker-newman/newman_ubuntu1404 Run a collection using the newman image: ```terminal -docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/4a287759fe7efe6b0f20" +docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/df0a40ef41d570c48154" ``` @@ -79,7 +79,7 @@ directory of your collection files into that location and provide the file refer ```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/ubuntu_1404 --collection="PostmanDemoServer.json.postman_collection" +docker run -v ~/collections:/etc/newman -t postman/ubuntu_1404 --collection="JSONBlobCoreAPI.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 @@ -95,8 +95,8 @@ Run a local collection, pass an environment to it, and save the HTML report on t ```terminal docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ - --collection="PostmanDemoServer.json.postman_collection" \ - --environment="PostmanBin.postman_environment" \ + --collection="JSONBlobCoreAPI.json.postman_collection" \ + --environment="JSONBlobCoreAPI.postman_environment" \ --html="newman-results.html" ``` @@ -104,13 +104,13 @@ docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ ```terminal docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ - --url="https://www.getpostman.com/collections/4a287759fe7efe6b0f20" \ - --environment="PostmanBin.postman_environment" \ + --url="https://www.getpostman.com/collections/df0a40ef41d570c48154" \ + --environment="JSONBlobCoreAPI.postman_environment" \ --testReportFile="newman-report.xml" ```
Import a Postman backup file, and save collections, environments, and globals - + ```terminal docker run -v ~/collections:/etc/postman -t postman/ubuntu_1404 --import="Backup.postman_dump" --pretty ``` @@ -137,5 +137,5 @@ function onExit { # trap onExit EXIT; -docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/4a287759fe7efe6b0f20" --exitCode; +docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/df0a40ef41d570c48154" --exitCode; ``` diff --git a/tests/data/JSONBlobCoreAPI.json.postman_collection b/tests/data/JSONBlobCoreAPI.json.postman_collection new file mode 100644 index 0000000..93dfa42 --- /dev/null +++ b/tests/data/JSONBlobCoreAPI.json.postman_collection @@ -0,0 +1,97 @@ +{ + "id": "c387bfd2-2316-9ad2-f15a-94444d0f8506", + "name": "JSONBlob Core API", + "description": "JSON Blob was created to help parallelize client/server development. Mock JSON responses can be defined using the online editor and then clients can use the JSON Blob API to retrieve and update the mock responses.\n\nBlobs that are not accessed in 75 DAYS will be removed.\n\nCredit for the JSON editor and formatter goes to JSON Editor Online.", + "order": [ + "26c2a299-15c7-9ebd-96af-cd9144f405c5", + "e5dff41a-f3f1-8960-f164-5931a5dfcb5d", + "077c72b0-46c6-db00-0ebb-aeeb7826412b", + "bfcb0b16-82d0-43e7-f000-02ee6119ba4a" + ], + "folders": [], + "timestamp": 1438239521594, + "owner": "168", + "remoteLink": "", + "public": false, + "requests": [ + { + "id": "077c72b0-46c6-db00-0ebb-aeeb7826412b", + "headers": "Content-Type: application/json\nAccept: application/json\n", + "url": "https://jsonblob.com/api/jsonBlob/{{last_created_jsonblob}}", + "preRequestScript": "", + "pathVariables": {}, + "method": "PUT", + "data": [], + "dataMode": "raw", + "version": 2, + "tests": "if (responseCode.code === 404) {\n tests[\"Blob not found!\"] = false;\n}\n\nelse {\n \n}\n", + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1438239781952, + "name": "Edit a Blob", + "description": "Updating a JSON Blob is accomplished by sending a `PUT` request to `/api/jsonBlob/`. The request body should contain valid JSON that the stored JSON Blob will be replaced with. Upon successfully storing the new JSON Blob, a `200` response will be returned. If no JSON Blob exists for the given ``, a `404` response will be returned. The body of the response is the JSON that was stored in the JSON Blob.\n\n> Use the Blob ID from a *\"Create a Blob\"* `POST` request and append it to the URL to retrieve the JSON.\n> Change the raw data with your new JSON before you send the request, otherwise you may accidentally delete original data.\n> If you have recently created a blob using Postman, the variable `{{last_created_jsonblob}}` already has the blob id.", + "collectionId": "c387bfd2-2316-9ad2-f15a-94444d0f8506", + "responses": [], + "rawModeData": "{\n \"sample\": \"json\",\n \"update\": \"success\"\n}" + }, + { + "id": "26c2a299-15c7-9ebd-96af-cd9144f405c5", + "headers": "Content-Type: application/json\nAccept: application/json\n", + "url": "https://jsonblob.com/api/jsonBlob", + "preRequestScript": "", + "pathVariables": {}, + "method": "POST", + "data": [], + "dataMode": "raw", + "version": 2, + "tests": "if (responseCode.code === 201 && postman.getResponseHeader(\"location\")) {\n postman.setEnvironmentVariable(\"last_created_blob\", postman.getResponseHeader(\"location\").replace(\"https://jsonblob.com/api/jsonBlob/\", \"\"));\n \n tests[\"Blob Id: \" + postman.getEnvironmentVariable(\"last_created_blob\")] = true;\n tests[\"Blob Location: \" + postman.getResponseHeader(\"location\")] = !!postman.getResponseHeader(\"location\");\n postman.setGlobalVariable(\"last_created_jsonblob\", postman.getResponseHeader(\"location\"));\n\n}\nelse {\n tests[\"Blob not created!\"] = false;\n}", + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1438239764446, + "name": "Create a Blob", + "description": "Creating a JSON Blob is accomplished by sending a `POST` request to `/api/jsonBlob`. The body of the request should contain valid JSON that will used as the JSON Blob. Upon successfully storing the JSON blob, a `201` response will be returned. The `Location` header in the response will be set to the URL at which the blob can be accessed with a `GET` request. The body of the response is the JSON that was stored in the JSON blob.\n\n> Replace the JSON in the raw post body with your own JSON and refer to the \"test\" tab after sending the request to easily retrieve the location of your newly created JSON", + "collectionId": "c387bfd2-2316-9ad2-f15a-94444d0f8506", + "responses": [], + "rawModeData": "{\"people\":[\"bill\", \"steve\", \"bob\"]}" + }, + { + "id": "bfcb0b16-82d0-43e7-f000-02ee6119ba4a", + "headers": "Content-Type: application/json\nAccept: application/json\n", + "url": "https://jsonblob.com/api/jsonBlob/{{last_created_jsonblob}}", + "preRequestScript": "", + "pathVariables": {}, + "method": "DELETE", + "data": [], + "dataMode": "raw", + "version": 2, + "tests": "if (responseCode.code === 200) {\n tests[\"Successfully Deleted\"] = true;\n}\nelse {\n tests[\"Blob not found!\"] = false;\n}", + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1438239788710, + "name": "Delete a Blob", + "description": "Deleting a JSON Blob is accomplished by sending a `DELETE` request to `/api/jsonBlob/`. Upon successfully deleting the JSON Blob, a `200` response will be returned. If no JSON Blob exists for the given ``, a `404` response will be returned. If deleting blobs is not enabled, a 405 response will be returned.\n\n> Use the Blob ID from a *\"Create a Blob\"* `POST` request and append it to the URL to retrieve the JSON.\n> If you have recently created a blob using Postman, the variable `{{last_created_jsonblob}}` already has the blob id.", + "collectionId": "c387bfd2-2316-9ad2-f15a-94444d0f8506", + "responses": [], + "rawModeData": "" + }, + { + "id": "e5dff41a-f3f1-8960-f164-5931a5dfcb5d", + "headers": "Content-Type: application/json\nAccept: application/json\n", + "url": "https://jsonblob.com/api/jsonBlob/{{last_created_jsonblob}}", + "preRequestScript": "", + "pathVariables": {}, + "method": "GET", + "data": [], + "dataMode": "params", + "version": 2, + "tests": "if (responseCode.code !== 200) {\n tests[\"Blob not found!\"] = false;\n}\n\nelse {\n tests[\"Blob retrieved. See response body.\"] = true;\n}\n", + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1438239771799, + "name": "Retrieve a Blob", + "description": "Retrieving a JSON Blob is accomplished by sending a `GET` request to `/api/jsonBlob/`, where `` is the last part of the URL path returned from the `POST` request. Upon successfully retrieving the JSON Blob, a `200` response will be returned. If no JSON Blob exists for the given ``, a `404` response will be returned. The body of the response is the JSON that was stored in the JSON Blob.\n\n> Use the Blob ID from a *\"Create a Blob\"* `POST` request and append it to the URL to retrieve the JSON.\n> If you have recently created a blob using Postman, the variable `{{last_created_jsonblob}}` already has the blob id.", + "collectionId": "c387bfd2-2316-9ad2-f15a-94444d0f8506", + "responses": [] + } + ] +} \ No newline at end of file diff --git a/tests/data/collection.json b/tests/data/collection.json deleted file mode 100644 index ce8947e..0000000 --- a/tests/data/collection.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "id": "4aaffd8a-c1d7-5a22-3bf0-79ecfbe5fbf0", - "name": "Simple HTTPBin Collection", - "description": "Single GET", - "order": [ - "f53d5219-6036-31ca-bb44-1cea9c11bd42" - ], - "folders": [], - "timestamp": 1437633900852, - "owner": "61671", - "remoteLink": "", - "public": false, - "requests": [ - { - "id": "f53d5219-6036-31ca-bb44-1cea9c11bd42", - "headers": "", - "url": "http://{{serverloc}}", - "pathVariables": {}, - "preRequestScript": "", - "method": "GET", - "collectionId": "4aaffd8a-c1d7-5a22-3bf0-79ecfbe5fbf0", - "data": [], - "dataMode": "params", - "name": "http://{{serverloc}}", - "description": "", - "descriptionFormat": "html", - "time": 1437635444925, - "version": 2, - "responses": [], - "tests": "", - "currentHelper": "normal", - "helperAttributes": {} - } - ] -} diff --git a/tests/data/env.json b/tests/data/env.json deleted file mode 100644 index 5010b44..0000000 --- a/tests/data/env.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "id": "25c52d73-03ce-0305-ab32-3c50f9795895", - "name": "HttpBin Env", - "values": [ - { - "key": "serverloc", - "value": "httpbin.org", - "type": "text", - "name": "serverloc", - "enabled": true - } - ], - "timestamp": 1437635065317, - "synced": false, - "syncedFilename": "" -} diff --git a/ubuntu_1404/README.md b/ubuntu_1404/README.md index 299f2c2..7f83708 100644 --- a/ubuntu_1404/README.md +++ b/ubuntu_1404/README.md @@ -17,22 +17,22 @@ docker pull postman/newman_ubuntu1404 then run it ``` -docker --volume="/home/postman/collections:/etc/newman" -t newman_ubuntu1404 --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" +docker --volume="/home/postman/collections:/etc/newman" -t newman_ubuntu1404 --collection="JSONBlobCoreAPI.json.postman_collection" --html="newman-report.html" ``` 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 `/var/newman`, ``` -docker --volume="/home/postman/collection:/var/newman" -t newman_ubuntu1404 --collection="/var/newman/Github.json.postman_collection" --environment="Github.postman_environment" --html="/var/newman/newman-report.html" +docker --volume="/home/postman/collection:/var/newman" -t newman_ubuntu1404 --collection="/var/newman/JSONBlobCoreAPI.json.postman_collection" --html="/var/newman/newman-report.html" ``` - You can change the working directory while running the image to the location you mounted to, using the `-w` or `--workdir` flag. ``` -docker --volume="/home/postman/collections:/var/newman" --workdir="/var/newman" -t newman_ubuntu1404 --collection="Github.json.postman_collection" --environment="Github.postman_environment" --html="newman-report.html" +docker --volume="/home/postman/collections:/var/newman" --workdir="/var/newman" -t newman_ubuntu1404 --collection="JSONBlobCoreAPI.json.postman_collection" --html="newman-report.html" ``` In case you don't need to save newmans 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 ``` -docker -t newman_ubuntu1404 --url="https://example.com/Github.json.postman_collection" +docker -t newman_ubuntu1404 --url="https://www.getpostman.com/collections/df0a40ef41d570c48154" ``` From f3399bc6cc360874a3b73f15d7a571bd1c044bf6 Mon Sep 17 00:00:00 2001 From: elssar Date: Thu, 30 Jul 2015 13:24:52 +0530 Subject: [PATCH 31/34] Have travis run a remote collection --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e90d904..fb08d5c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,5 +25,6 @@ before_script: script: - npm test - docker run -v $PWD/tests/data:/etc/newman -t newman_ubuntu1404 -c JSONBlobCoreAPI.json.postman_collection + - docker run -t newman_ubuntu1404 -u https://www.getpostman.com/collections/df0a40ef41d570c48154 after_success: - echo "All done!" From 92cc66d3c20fc755a843a52396462a7703d612f4 Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Thu, 30 Jul 2015 16:26:23 +0530 Subject: [PATCH 32/34] new URLs and example collection --- .travis.yml | 4 +- README.md | 12 +- .../HTTPBinNewmanTest.json.postman_collection | 105 ++++++++++++++++++ ...PBinNewmanTestEnv.json.postman_environment | 16 +++ ...BinNewmanTestNoEnv.json.postman_collection | 105 ++++++++++++++++++ .../JSONBlobCoreAPI.json.postman_collection | 97 ---------------- 6 files changed, 234 insertions(+), 105 deletions(-) create mode 100644 tests/data/HTTPBinNewmanTest.json.postman_collection create mode 100644 tests/data/HTTPBinNewmanTestEnv.json.postman_environment create mode 100644 tests/data/HTTPBinNewmanTestNoEnv.json.postman_collection delete mode 100644 tests/data/JSONBlobCoreAPI.json.postman_collection diff --git a/.travis.yml b/.travis.yml index fb08d5c..f4fc4e0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_script: - docker build -t newman_ubuntu1404 ./ubuntu_1404 script: - npm test - - docker run -v $PWD/tests/data:/etc/newman -t newman_ubuntu1404 -c JSONBlobCoreAPI.json.postman_collection - - docker run -t newman_ubuntu1404 -u https://www.getpostman.com/collections/df0a40ef41d570c48154 + - docker run -v $PWD/tests/data:/etc/newman -t newman_ubuntu1404 -c HTTPBinNewmanTest.json.postman_collection + - docker run -t newman_ubuntu1404 -u https://www.getpostman.com/collections/8a0c9bc08f062d12dcda after_success: - echo "All done!" diff --git a/README.md b/README.md index a5d9000..6e60203 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ docker build -t postman/newman_ubuntu1404 docker-newman/newman_ubuntu1404 Run a collection using the newman image: ```terminal -docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/df0a40ef41d570c48154" +docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/8a0c9bc08f062d12dcda" ``` @@ -95,8 +95,8 @@ Run a local collection, pass an environment to it, and save the HTML report on t ```terminal docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ - --collection="JSONBlobCoreAPI.json.postman_collection" \ - --environment="JSONBlobCoreAPI.postman_environment" \ + --collection="HTTPBinNewmanTest.json.postman_collection" \ + --environment="HTTPBinNewmanTestEnv.json.postman_environment" \ --html="newman-results.html" ``` @@ -104,8 +104,8 @@ docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ ```terminal docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \ - --url="https://www.getpostman.com/collections/df0a40ef41d570c48154" \ - --environment="JSONBlobCoreAPI.postman_environment" \ + --url="https://www.getpostman.com/collections/8a0c9bc08f062d12dcda" \ + --environment="HTTPBinNewmanTestEnv.json.postman_environment" \ --testReportFile="newman-report.xml" ``` @@ -137,5 +137,5 @@ function onExit { # trap onExit EXIT; -docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/df0a40ef41d570c48154" --exitCode; +docker run -t postman/newman_ubuntu1404 --url="https://www.getpostman.com/collections/8a0c9bc08f062d12dcda" --exitCode; ``` diff --git a/tests/data/HTTPBinNewmanTest.json.postman_collection b/tests/data/HTTPBinNewmanTest.json.postman_collection new file mode 100644 index 0000000..b06474a --- /dev/null +++ b/tests/data/HTTPBinNewmanTest.json.postman_collection @@ -0,0 +1,105 @@ +{ + "id": "99315123-992f-c284-d6dc-b00be1d6be62", + "name": "newmanTest", + "description": "Makes four requests to HTTPBin (httpbin.org) and tests Newman", + "order": [ + "9f169dc0-7444-b89e-a7e0-950af47bd7da", + "d83dcc96-27f1-47d7-b35f-2095ef5fddc8", + "0f22ce8f-df9b-af6d-6c5a-5aef8a81e272", + "3dca05d0-7060-8ad9-1e28-0b63fed60715" + ], + "folders": [], + "timestamp": 1438249510749, + "owner": "1260", + "remoteLink": "", + "public": false, + "requests": [ + { + "id": "0f22ce8f-df9b-af6d-6c5a-5aef8a81e272", + "headers": "", + "url": "http://{{serverloc}}/delete", + "pathVariables": {}, + "preRequestScript": "", + "method": "DELETE", + "collectionId": "99315123-992f-c284-d6dc-b00be1d6be62", + "data": [], + "dataMode": "params", + "name": "DELETE request", + "description": "", + "descriptionFormat": "html", + "time": 1438250164765, + "version": 2, + "responses": [], + "tests": "tests[\"Status code is 200\"] = responseCode.code === 200;", + "currentHelper": "normal", + "helperAttributes": {} + }, + { + "id": "3dca05d0-7060-8ad9-1e28-0b63fed60715", + "headers": "", + "url": "http://{{serverloc}}/put", + "pathVariables": {}, + "preRequestScript": "", + "method": "PUT", + "collectionId": "99315123-992f-c284-d6dc-b00be1d6be62", + "data": [ + { + "key": "quotient", + "value": "223", + "type": "text", + "enabled": true + } + ], + "dataMode": "urlencoded", + "name": "PUT with form data", + "description": "", + "descriptionFormat": "html", + "time": 1438250517000, + "version": 2, + "responses": [], + "tests": "var data = JSON.parse(responseBody);\ntests[\"Test form data\"] = data.form.quotient === \"223\";", + "currentHelper": "normal", + "helperAttributes": {} + }, + { + "id": "9f169dc0-7444-b89e-a7e0-950af47bd7da", + "headers": "", + "url": "http://{{serverloc}}/get?lol=true", + "preRequestScript": "", + "pathVariables": {}, + "method": "GET", + "data": [], + "dataMode": "params", + "version": 2, + "tests": "var data = JSON.parse(responseBody);\ntests[\"Response contains params\"] = data.args.lol === \"true\";", + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1438250908857, + "name": "GET with URL Params", + "description": "Simple GET request with URL Parameters", + "collectionId": "99315123-992f-c284-d6dc-b00be1d6be62", + "responses": [] + }, + { + "id": "d83dcc96-27f1-47d7-b35f-2095ef5fddc8", + "headers": "Content-Type: application/json\n", + "url": "http://{{serverloc}}/post", + "pathVariables": {}, + "preRequestScript": "", + "method": "POST", + "collectionId": "99315123-992f-c284-d6dc-b00be1d6be62", + "data": [], + "dataMode": "raw", + "name": "POST with JSON body", + "description": "", + "descriptionFormat": "html", + "time": 1438250049106, + "version": 2, + "responses": [], + "tests": "var data = JSON.parse(responseBody);\ntests[\"Check POST param in response\"] = data.json.something === \"cool\";", + "currentHelper": "normal", + "helperAttributes": {}, + "rawModeData": "{\n \"something\": \"cool\"\n}" + } + ] +} \ No newline at end of file diff --git a/tests/data/HTTPBinNewmanTestEnv.json.postman_environment b/tests/data/HTTPBinNewmanTestEnv.json.postman_environment new file mode 100644 index 0000000..4cc3aae --- /dev/null +++ b/tests/data/HTTPBinNewmanTestEnv.json.postman_environment @@ -0,0 +1,16 @@ +{ + "id": "25c52d73-03ce-0305-ab32-3c50f9795895", + "name": "HttpBin Env", + "values": [ + { + "key": "serverloc", + "value": "httpbin.org", + "type": "text", + "name": "serverloc", + "enabled": true + } + ], + "timestamp": 1437635065317, + "synced": false, + "syncedFilename": "" +} diff --git a/tests/data/HTTPBinNewmanTestNoEnv.json.postman_collection b/tests/data/HTTPBinNewmanTestNoEnv.json.postman_collection new file mode 100644 index 0000000..41d3191 --- /dev/null +++ b/tests/data/HTTPBinNewmanTestNoEnv.json.postman_collection @@ -0,0 +1,105 @@ +{ + "id": "99315123-992f-c284-d6dc-b00be1d6be62", + "name": "newmanTest", + "description": "Makes four requests to HTTPBin (httpbin.org) and tests Newman", + "order": [ + "9f169dc0-7444-b89e-a7e0-950af47bd7da", + "d83dcc96-27f1-47d7-b35f-2095ef5fddc8", + "0f22ce8f-df9b-af6d-6c5a-5aef8a81e272", + "3dca05d0-7060-8ad9-1e28-0b63fed60715" + ], + "folders": [], + "timestamp": 1438249510749, + "owner": "1260", + "remoteLink": "", + "public": false, + "requests": [ + { + "id": "0f22ce8f-df9b-af6d-6c5a-5aef8a81e272", + "headers": "", + "url": "http://httpbin.org/delete", + "pathVariables": {}, + "preRequestScript": "", + "method": "DELETE", + "collectionId": "99315123-992f-c284-d6dc-b00be1d6be62", + "data": [], + "dataMode": "params", + "name": "DELETE request", + "description": "", + "descriptionFormat": "html", + "time": 1438250164765, + "version": 2, + "responses": [], + "tests": "tests[\"Status code is 200\"] = responseCode.code === 200;", + "currentHelper": "normal", + "helperAttributes": {} + }, + { + "id": "3dca05d0-7060-8ad9-1e28-0b63fed60715", + "headers": "", + "url": "http://httpbin.org/put", + "pathVariables": {}, + "preRequestScript": "", + "method": "PUT", + "collectionId": "99315123-992f-c284-d6dc-b00be1d6be62", + "data": [ + { + "key": "quotient", + "value": "223", + "type": "text", + "enabled": true + } + ], + "dataMode": "urlencoded", + "name": "PUT with form data", + "description": "", + "descriptionFormat": "html", + "time": 1438250517000, + "version": 2, + "responses": [], + "tests": "var data = JSON.parse(responseBody);\ntests[\"Test form data\"] = data.form.quotient === \"223\";", + "currentHelper": "normal", + "helperAttributes": {} + }, + { + "id": "9f169dc0-7444-b89e-a7e0-950af47bd7da", + "headers": "", + "url": "http://httpbin.org/get?lol=true", + "preRequestScript": "", + "pathVariables": {}, + "method": "GET", + "data": [], + "dataMode": "params", + "version": 2, + "tests": "var data = JSON.parse(responseBody);\ntests[\"Response contains params\"] = data.args.lol === \"true\";", + "currentHelper": "normal", + "helperAttributes": {}, + "time": 1438250908857, + "name": "GET with URL Params", + "description": "Simple GET request with URL Parameters", + "collectionId": "99315123-992f-c284-d6dc-b00be1d6be62", + "responses": [] + }, + { + "id": "d83dcc96-27f1-47d7-b35f-2095ef5fddc8", + "headers": "Content-Type: application/json\n", + "url": "http://httpbin.org/post", + "pathVariables": {}, + "preRequestScript": "", + "method": "POST", + "collectionId": "99315123-992f-c284-d6dc-b00be1d6be62", + "data": [], + "dataMode": "raw", + "name": "POST with JSON body", + "description": "", + "descriptionFormat": "html", + "time": 1438250049106, + "version": 2, + "responses": [], + "tests": "var data = JSON.parse(responseBody);\ntests[\"Check POST param in response\"] = data.json.something === \"cool\";", + "currentHelper": "normal", + "helperAttributes": {}, + "rawModeData": "{\n \"something\": \"cool\"\n}" + } + ] +} diff --git a/tests/data/JSONBlobCoreAPI.json.postman_collection b/tests/data/JSONBlobCoreAPI.json.postman_collection deleted file mode 100644 index 93dfa42..0000000 --- a/tests/data/JSONBlobCoreAPI.json.postman_collection +++ /dev/null @@ -1,97 +0,0 @@ -{ - "id": "c387bfd2-2316-9ad2-f15a-94444d0f8506", - "name": "JSONBlob Core API", - "description": "JSON Blob was created to help parallelize client/server development. Mock JSON responses can be defined using the online editor and then clients can use the JSON Blob API to retrieve and update the mock responses.\n\nBlobs that are not accessed in 75 DAYS will be removed.\n\nCredit for the JSON editor and formatter goes to JSON Editor Online.", - "order": [ - "26c2a299-15c7-9ebd-96af-cd9144f405c5", - "e5dff41a-f3f1-8960-f164-5931a5dfcb5d", - "077c72b0-46c6-db00-0ebb-aeeb7826412b", - "bfcb0b16-82d0-43e7-f000-02ee6119ba4a" - ], - "folders": [], - "timestamp": 1438239521594, - "owner": "168", - "remoteLink": "", - "public": false, - "requests": [ - { - "id": "077c72b0-46c6-db00-0ebb-aeeb7826412b", - "headers": "Content-Type: application/json\nAccept: application/json\n", - "url": "https://jsonblob.com/api/jsonBlob/{{last_created_jsonblob}}", - "preRequestScript": "", - "pathVariables": {}, - "method": "PUT", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": "if (responseCode.code === 404) {\n tests[\"Blob not found!\"] = false;\n}\n\nelse {\n \n}\n", - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1438239781952, - "name": "Edit a Blob", - "description": "Updating a JSON Blob is accomplished by sending a `PUT` request to `/api/jsonBlob/`. The request body should contain valid JSON that the stored JSON Blob will be replaced with. Upon successfully storing the new JSON Blob, a `200` response will be returned. If no JSON Blob exists for the given ``, a `404` response will be returned. The body of the response is the JSON that was stored in the JSON Blob.\n\n> Use the Blob ID from a *\"Create a Blob\"* `POST` request and append it to the URL to retrieve the JSON.\n> Change the raw data with your new JSON before you send the request, otherwise you may accidentally delete original data.\n> If you have recently created a blob using Postman, the variable `{{last_created_jsonblob}}` already has the blob id.", - "collectionId": "c387bfd2-2316-9ad2-f15a-94444d0f8506", - "responses": [], - "rawModeData": "{\n \"sample\": \"json\",\n \"update\": \"success\"\n}" - }, - { - "id": "26c2a299-15c7-9ebd-96af-cd9144f405c5", - "headers": "Content-Type: application/json\nAccept: application/json\n", - "url": "https://jsonblob.com/api/jsonBlob", - "preRequestScript": "", - "pathVariables": {}, - "method": "POST", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": "if (responseCode.code === 201 && postman.getResponseHeader(\"location\")) {\n postman.setEnvironmentVariable(\"last_created_blob\", postman.getResponseHeader(\"location\").replace(\"https://jsonblob.com/api/jsonBlob/\", \"\"));\n \n tests[\"Blob Id: \" + postman.getEnvironmentVariable(\"last_created_blob\")] = true;\n tests[\"Blob Location: \" + postman.getResponseHeader(\"location\")] = !!postman.getResponseHeader(\"location\");\n postman.setGlobalVariable(\"last_created_jsonblob\", postman.getResponseHeader(\"location\"));\n\n}\nelse {\n tests[\"Blob not created!\"] = false;\n}", - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1438239764446, - "name": "Create a Blob", - "description": "Creating a JSON Blob is accomplished by sending a `POST` request to `/api/jsonBlob`. The body of the request should contain valid JSON that will used as the JSON Blob. Upon successfully storing the JSON blob, a `201` response will be returned. The `Location` header in the response will be set to the URL at which the blob can be accessed with a `GET` request. The body of the response is the JSON that was stored in the JSON blob.\n\n> Replace the JSON in the raw post body with your own JSON and refer to the \"test\" tab after sending the request to easily retrieve the location of your newly created JSON", - "collectionId": "c387bfd2-2316-9ad2-f15a-94444d0f8506", - "responses": [], - "rawModeData": "{\"people\":[\"bill\", \"steve\", \"bob\"]}" - }, - { - "id": "bfcb0b16-82d0-43e7-f000-02ee6119ba4a", - "headers": "Content-Type: application/json\nAccept: application/json\n", - "url": "https://jsonblob.com/api/jsonBlob/{{last_created_jsonblob}}", - "preRequestScript": "", - "pathVariables": {}, - "method": "DELETE", - "data": [], - "dataMode": "raw", - "version": 2, - "tests": "if (responseCode.code === 200) {\n tests[\"Successfully Deleted\"] = true;\n}\nelse {\n tests[\"Blob not found!\"] = false;\n}", - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1438239788710, - "name": "Delete a Blob", - "description": "Deleting a JSON Blob is accomplished by sending a `DELETE` request to `/api/jsonBlob/`. Upon successfully deleting the JSON Blob, a `200` response will be returned. If no JSON Blob exists for the given ``, a `404` response will be returned. If deleting blobs is not enabled, a 405 response will be returned.\n\n> Use the Blob ID from a *\"Create a Blob\"* `POST` request and append it to the URL to retrieve the JSON.\n> If you have recently created a blob using Postman, the variable `{{last_created_jsonblob}}` already has the blob id.", - "collectionId": "c387bfd2-2316-9ad2-f15a-94444d0f8506", - "responses": [], - "rawModeData": "" - }, - { - "id": "e5dff41a-f3f1-8960-f164-5931a5dfcb5d", - "headers": "Content-Type: application/json\nAccept: application/json\n", - "url": "https://jsonblob.com/api/jsonBlob/{{last_created_jsonblob}}", - "preRequestScript": "", - "pathVariables": {}, - "method": "GET", - "data": [], - "dataMode": "params", - "version": 2, - "tests": "if (responseCode.code !== 200) {\n tests[\"Blob not found!\"] = false;\n}\n\nelse {\n tests[\"Blob retrieved. See response body.\"] = true;\n}\n", - "currentHelper": "normal", - "helperAttributes": {}, - "time": 1438239771799, - "name": "Retrieve a Blob", - "description": "Retrieving a JSON Blob is accomplished by sending a `GET` request to `/api/jsonBlob/`, where `` is the last part of the URL path returned from the `POST` request. Upon successfully retrieving the JSON Blob, a `200` response will be returned. If no JSON Blob exists for the given ``, a `404` response will be returned. The body of the response is the JSON that was stored in the JSON Blob.\n\n> Use the Blob ID from a *\"Create a Blob\"* `POST` request and append it to the URL to retrieve the JSON.\n> If you have recently created a blob using Postman, the variable `{{last_created_jsonblob}}` already has the blob id.", - "collectionId": "c387bfd2-2316-9ad2-f15a-94444d0f8506", - "responses": [] - } - ] -} \ No newline at end of file From 700865b6f6d7e6ae5c571455677d12c2b762a0a3 Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Thu, 30 Jul 2015 16:35:19 +0530 Subject: [PATCH 33/34] add environment to travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f4fc4e0..e3d87ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_script: - docker build -t newman_ubuntu1404 ./ubuntu_1404 script: - npm test - - docker run -v $PWD/tests/data:/etc/newman -t newman_ubuntu1404 -c HTTPBinNewmanTest.json.postman_collection + - docker run -v $PWD/tests/data:/etc/newman -t newman_ubuntu1404 -c HTTPBinNewmanTest.json.postman_collection -e HTTPBinNewmanTestEnv.json.postman_environment - docker run -t newman_ubuntu1404 -u https://www.getpostman.com/collections/8a0c9bc08f062d12dcda after_success: - echo "All done!" From c250543de36eae8b249533bbf42341918bc96a4d Mon Sep 17 00:00:00 2001 From: Aniket Panse Date: Thu, 30 Jul 2015 16:45:59 +0530 Subject: [PATCH 34/34] force exitcode on travis tests --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e3d87ac..ed33095 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,7 @@ before_script: - docker build -t newman_ubuntu1404 ./ubuntu_1404 script: - npm test - - docker run -v $PWD/tests/data:/etc/newman -t newman_ubuntu1404 -c HTTPBinNewmanTest.json.postman_collection -e HTTPBinNewmanTestEnv.json.postman_environment - - docker run -t newman_ubuntu1404 -u https://www.getpostman.com/collections/8a0c9bc08f062d12dcda + - docker run -v $PWD/tests/data:/etc/newman -t newman_ubuntu1404 -c HTTPBinNewmanTest.json.postman_collection -e HTTPBinNewmanTestEnv.json.postman_environment --exitCode + - docker run -t newman_ubuntu1404 -u https://www.getpostman.com/collections/8a0c9bc08f062d12dcda --exitCode after_success: - echo "All done!"