Skip to content
This repository has been archived by the owner on Jun 6, 2018. It is now read-only.

Commit

Permalink
Merge branch 'develop' into release/1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
shamasis committed Jul 30, 2015
2 parents 516bc0f + 73a9600 commit 2416f66
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 67 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -34,3 +34,4 @@ pyenv
vendor/pkg/
.idea
node_modules
npm-debug.log*
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -24,6 +24,7 @@ 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 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!"
22 changes: 11 additions & 11 deletions README.md
@@ -1,6 +1,6 @@
# newman-docker <a href="https://travis-ci.org/postmanlabs/newman-docker" target="_blank"><img src="https://travis-ci.org/postmanlabs/newman-docker.svg?branch=develop" /></a> <a href="https://gitter.im/postmanlabs/newman-docker" target="_blank"> <img src="https://badges.gitter.im/Join%20Chat.svg" /></a>
<img src="https://s3.amazonaws.com/web-artefacts/cartoon-whale-8.gif+(400%C3%97225).png">

<img src="https://s3.amazonaws.com/web-artefacts/newman-128.png">
# newman-docker <a href="https://travis-ci.org/postmanlabs/newman-docker" target="_blank"><img src="https://travis-ci.org/postmanlabs/newman-docker.svg?branch=develop" /></a> <a href="https://gitter.im/postmanlabs/newman-docker" target="_blank"> <img src="https://badges.gitter.im/Join%20Chat.svg" /></a>

This repository contains docker images for Newman.

Expand Down Expand Up @@ -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
Expand All @@ -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/8a0c9bc08f062d12dcda"
```


Expand All @@ -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
Expand All @@ -95,22 +95,22 @@ 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="HTTPBinNewmanTest.json.postman_collection" \
--environment="HTTPBinNewmanTestEnv.json.postman_environment" \
--html="newman-results.html"
```

<br />Run a remote collection, pass it a local environment, and save JUnit XML test report on the host

```terminal
docker run -v ~/collections:/etc/postman -t postman/newman_ubuntu1404 \
--url="https://www.getpostman.com/collections/4a287759fe7efe6b0f20" \
--environment="PostmanBin.postman_environment" \
--url="https://www.getpostman.com/collections/8a0c9bc08f062d12dcda" \
--environment="HTTPBinNewmanTestEnv.json.postman_environment" \
--testReportFile="newman-report.xml"
```

<br />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
```
Expand All @@ -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/8a0c9bc08f062d12dcda" --exitCode;
```
105 changes: 105 additions & 0 deletions 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}"
}
]
}
16 changes: 16 additions & 0 deletions 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": ""
}
105 changes: 105 additions & 0 deletions 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}"
}
]
}
35 changes: 0 additions & 35 deletions tests/data/collection.json

This file was deleted.

16 changes: 0 additions & 16 deletions tests/data/env.json

This file was deleted.

8 changes: 4 additions & 4 deletions ubuntu_1404/README.md
Expand Up @@ -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"
```

0 comments on commit 2416f66

Please sign in to comment.