Skip to content

Commit 8a2ef6c

Browse files
test(core): fix ws tls quarantined test
1 parent 58af62d commit 8a2ef6c

File tree

3 files changed

+73
-38
lines changed

3 files changed

+73
-38
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"config": {
3+
"target": "wss://localhost:9443",
4+
"phases": [{ "duration": 1, "arrivalCount": 1 }],
5+
"ws": {
6+
"rejectUnauthorized": false
7+
}
8+
},
9+
"scenarios": [
10+
{
11+
"engine": "ws",
12+
"flow": [{ "send": "hello" }]
13+
}
14+
]
15+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'use strict';
2+
3+
const { test, beforeEach, afterEach } = require('tap');
4+
const core = require('../../..');
5+
const vuserLauncher = core.runner.runner;
6+
const { SSMS } = require('../../../lib/ssms');
7+
const createTestServer = require('../../targets/ws_tls');
8+
9+
let server;
10+
let port;
11+
beforeEach(async () => {
12+
const serverInfo = await createTestServer();
13+
port = serverInfo.port;
14+
server = serverInfo.server;
15+
});
16+
17+
afterEach(() => {
18+
server.close();
19+
});
20+
21+
test('TLS - with rejectUnauthorized false', function (t) {
22+
const script = require('./scripts/ws-tls.json');
23+
script.config.target = `wss://127.0.0.1:${port}`;
24+
vuserLauncher(script).then(function (ee) {
25+
ee.on('done', function (nr) {
26+
const report = SSMS.legacyReport(nr).report();
27+
console.log(report);
28+
t.ok(Object.keys(report.errors).length === 0, 'Test ran without errors');
29+
ee.stop().then(() => {
30+
t.end();
31+
});
32+
});
33+
ee.run();
34+
});
35+
});
36+
37+
test('TLS - with rejectUnauthorized true', function (t) {
38+
const script = require('./scripts/ws-tls.json');
39+
script.config.target = `wss://127.0.0.1:${port}`;
40+
script.config.ws.rejectUnauthorized = true;
41+
vuserLauncher(script).then(function (ee) {
42+
ee.on('done', function (nr) {
43+
const report = SSMS.legacyReport(nr).report();
44+
console.log(report);
45+
t.equal(
46+
Object.keys(report.errors).length,
47+
1,
48+
`Test should run with one error. Got: ${Object.keys(report.errors)}`
49+
);
50+
ee.stop().then(() => {
51+
t.end();
52+
});
53+
});
54+
ee.run();
55+
});
56+
});

packages/core/test/quarantine/ws/test_options.js

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,7 @@ const core = require('../../..');
55
const vuserLauncher = core.runner.runner;
66
const { SSMS } = require('../../../lib/ssms');
77

8-
//
9-
// If config.ws.rejectUnauthorized is not set, we will have an error.
10-
// Otherwise the test will run fine.
11-
//
12-
13-
test('TLS options for WebSocket', function (t) {
14-
const script = require('./scripts/extra_options.json');
15-
vuserLauncher(script).then(function (sessions) {
16-
sessions.on('done', function (nr) {
17-
const report = SSMS.legacyReport(nr).report();
18-
t.ok(Object.keys(report.errors).length === 0, 'Test ran without errors');
19-
20-
// Now remove TLS options and rerun - should have an error
21-
delete script.config.ws;
22-
vuserLauncher(script).then(function (sessions2) {
23-
sessions2.on('done', function (nr2) {
24-
const report2 = SSMS.legacyReport(nr2).report();
25-
t.equal(
26-
Object.keys(report2.errors).length,
27-
1,
28-
`Test should run with one error. Got: ${Object.keys(
29-
report2.errors
30-
)}`
31-
);
32-
33-
sessions.stop().then(() => {
34-
sessions2.stop().then(() => {
35-
t.end();
36-
});
37-
});
38-
});
39-
sessions2.run();
40-
});
41-
});
42-
sessions.run();
43-
});
44-
});
45-
8+
//simple-ws
469
test('Subprotocols - using a known subprotocol', function (t) {
4710
const script = require('./scripts/subprotocols.json');
4811
vuserLauncher(script).then((sessions) => {
@@ -62,6 +25,7 @@ test('Subprotocols - using a known subprotocol', function (t) {
6225
});
6326
});
6427

28+
//simple-ws
6529
test('Subprotocols - no subprotocol', function (t) {
6630
const script = require('./scripts/subprotocols.json');
6731

0 commit comments

Comments
 (0)