Skip to content

Commit

Permalink
Merge pull request artilleryio#8 from shoreditch-ops/cookies
Browse files Browse the repository at this point in the history
(artilleryio#1) - Add cookie support
  • Loading branch information
hassy committed Oct 7, 2015
2 parents ea7c82f + 3b5cc89 commit 259d1b0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
11 changes: 10 additions & 1 deletion lib/worker_http.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ function compileScenario(scenarioSpec, config, ee) {
return (typeof rs.think === 'number');
}));

initialContext._jar = request.jar();

var steps = _.flatten([
function zero(cb) {
ee.emit('started');
Expand Down Expand Up @@ -63,7 +65,8 @@ function createRequest(requestSpec, config, ee) {
method: method,
headers: {
},
timeout: 10 * 1000
timeout: 10 * 1000,
jar: context._jar
});

if (params.json) {
Expand All @@ -79,6 +82,12 @@ function createRequest(requestSpec, config, ee) {
requestParams.headers = _.extend(defaultHeaders,
lowcaseKeys(params.headers));

if (params.cookie) {
_(params.cookie).each(function(v, k) {
context._jar.setCookie(k + '=' + v, uri);
});
}

request(requestParams, function requestCallback(err, res, body) {
if (err) {
var errCode = err.code;
Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "minigun-core",
"version": "0.2.0",
"version": "0.2.1",
"description": "minigun-core - load-generator library used by `minigun`",
"main": "index.js",
"engines": {
Expand Down Expand Up @@ -33,11 +33,15 @@
},
"devDependencies": {
"eslint": "^0.24.0",
"good": "6.4.0",
"good-console": "5.1.0",
"hapi": "10.4.0",
"interfake": "^1.13.0",
"istanbul": "^0.3.17",
"nock": "^2.7.0",
"pre-commit": "^1.0.10",
"tape": "^4.0.0"
"tape": "^4.0.0",
"uuid": "^2.0.1"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion test/targets/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ server.route({

server.state('testCookie', {
ttl: null,
isSecure: true,
isSecure: false,
isHttpOnly: true,
encoding: 'base64json',
clearInvalid: false,
Expand Down
2 changes: 1 addition & 1 deletion test/test_cookies.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var runner = require('../lib/runner').runner;
var l = require('lodash');
var request = require('request');

test('think', function(t) {
test('cookie jar', function(t) {
var script = require('./scripts/cookies.json');
var ee = runner(script);
ee.on('done', function(stats) {
Expand Down

0 comments on commit 259d1b0

Please sign in to comment.