forked from artilleryio/artillery-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_cookies.js
91 lines (84 loc) · 2.4 KB
/
test_cookies.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
'use strict';
var test = require('tape');
var runner = require('../lib/runner').runner;
var l = require('lodash');
var request = require('request');
test('cookie jar http', function(t) {
var script = require('./scripts/cookies.json');
runner(script).then(function(ee) {
ee.on('done', function(report) {
request(
{
method: 'GET',
url: 'http://127.0.0.1:3003/_stats',
json: true
},
function(err, res, body) {
if (err) {
return t.fail();
}
var ok = report.scenariosCompleted && l.size(body.cookies) === report.scenariosCompleted;
t.assert(ok, 'Each scenario had a unique cookie');
if (!ok) {
console.log(body);
console.log(report);
}
t.end();
});
});
ee.run();
});
});
test('cookie jar socketio', function(t) {
var script = require('./scripts/cookies_socketio.json');
runner(script).then(function(ee) {
ee.on('done', function(report) {
request(
{
method: 'GET',
url: 'http://127.0.0.1:9092/_stats',
json: true
},
function(err, res, body) {
if (err) {
return t.fail();
}
var ok = report.scenariosCompleted && l.size(body.cookies) === report.scenariosCompleted;
t.assert(ok, 'Each scenario had a unique cookie');
if (!ok) {
console.log(body);
console.log(report);
}
t.end();
});
});
ee.run();
});
});
test('default cookies', function(t) {
var script = require('./scripts/defaults_cookies.json');
runner(script).then(function(ee) {
ee.on('done', function(report) {
t.assert(report.codes[200] && report.codes[200] > 0,
'There should be some 200s');
t.assert(report.codes[403] === undefined,
'There should be no 403s');
t.end();
});
ee.run();
});
});
test('no default cookie', function(t) {
var script = require('./scripts/defaults_cookies.json');
delete script.config.defaults.cookie;
runner(script).then(function(ee) {
ee.on('done', function(report) {
t.assert(report.codes[403] && report.codes[403] > 0,
'There should be some 403s');
t.assert(report.codes[200] === undefined,
'There should be no 200s');
t.end();
});
ee.run();
});
});