-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(core): fix some quarantine tests (#2627)
* test(core): fix config variables quarantined test * test(core): fix tls quarantined test * test(core): fix ws tls quarantined test * test(core): removed file * test(core): fix ws subprotocols quarantined tests
- Loading branch information
1 parent
9dfd766
commit d55b152
Showing
14 changed files
with
303 additions
and
209 deletions.
There are no files selected for viewing
23 changes: 20 additions & 3 deletions
23
.../test/quarantine/test_config_variables.js → .../test/acceptance/config-variables.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
'use strict'; | ||
|
||
const { test } = require('tap'); | ||
const { test, beforeEach, afterEach } = require('tap'); | ||
const runner = require('../..').runner.runner; | ||
const { SSMS } = require('../../lib/ssms'); | ||
const createTestServer = require('../targets/simple'); | ||
|
||
test('config variables', function (t) { | ||
let server; | ||
let port; | ||
beforeEach(async () => { | ||
server = await createTestServer(0); | ||
port = server.info.port; | ||
}); | ||
|
||
afterEach(() => { | ||
server.stop(); | ||
}); | ||
|
||
test('config variables', (t) => { | ||
const script = require('../scripts/config_variables.json'); | ||
script.config.target = `http://127.0.0.1:${port}`; | ||
|
||
runner(script).then(function (ee) { | ||
ee.on('done', function (nr) { | ||
const report = SSMS.legacyReport(nr).report(); | ||
t.ok(report.codes[200] > 0, 'there are 200s for /'); | ||
t.ok(report.codes[404] > 0, 'there are 404s for /will/404'); | ||
t.end(); | ||
ee.stop().then(() => { | ||
t.end(); | ||
}); | ||
}); | ||
|
||
ee.run(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
const { test, beforeEach, afterEach } = require('tap'); | ||
const runner = require('../../lib/runner').runner; | ||
const { updateGlobalObject } = require('../../index'); | ||
const { SSMS } = require('../../lib/ssms'); | ||
const createTestServer = require('../targets/simple_tls'); | ||
|
||
let server; | ||
let port; | ||
beforeEach(async () => { | ||
await updateGlobalObject(); | ||
const serverInfo = await createTestServer(); | ||
port = serverInfo.port; | ||
server = serverInfo.server; | ||
}); | ||
|
||
afterEach(() => { | ||
server.close(); | ||
}); | ||
|
||
test('tls strict', function (t) { | ||
const script = require('../scripts/tls-strict.json'); | ||
script.config.target = `https://127.0.0.1:${port}`; | ||
runner(script).then(function (ee) { | ||
ee.on('done', function (nr) { | ||
const report = SSMS.legacyReport(nr).report(); | ||
console.log(report); | ||
const rejected = report.errors.DEPTH_ZERO_SELF_SIGNED_CERT; | ||
t.ok(rejected, 'requests to self-signed tls certs fail by default'); | ||
|
||
ee.stop().then(() => { | ||
t.end(); | ||
}); | ||
}); | ||
ee.run(); | ||
}); | ||
}); | ||
|
||
test('tls lax', function (t) { | ||
const script = require('../scripts/tls-lax.json'); | ||
script.config.target = `https://127.0.0.1:${port}`; | ||
runner(script).then(function (ee) { | ||
ee.on('done', function (nr) { | ||
const report = SSMS.legacyReport(nr).report(); | ||
const rejected = report.errors.DEPTH_ZERO_SELF_SIGNED_CERT; | ||
const reason = | ||
'requests to self-signed tls certs pass ' + | ||
'when `rejectUnauthorized` is false'; | ||
|
||
t.ok(rejected == null, reason); | ||
|
||
ee.stop().then(() => { | ||
t.end(); | ||
}); | ||
}); | ||
ee.run(); | ||
}); | ||
}); |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
'use strict'; | ||
|
||
const { test, beforeEach, afterEach } = require('tap'); | ||
const core = require('../../..'); | ||
const vuserLauncher = core.runner.runner; | ||
const { SSMS } = require('../../../lib/ssms'); | ||
const createTestServer = require('../../targets/simple_ws'); | ||
|
||
let server; | ||
let port; | ||
beforeEach(async () => { | ||
const serverInfo = await createTestServer(); | ||
port = serverInfo.port; | ||
server = serverInfo.server; | ||
}); | ||
|
||
afterEach(() => { | ||
server.close(); | ||
}); | ||
|
||
test('Subprotocols - using a known subprotocol', function (t) { | ||
const script = require('./scripts/subprotocols.json'); | ||
script.config.target = `ws://127.0.0.1:${port}`; | ||
vuserLauncher(script).then((ee) => { | ||
ee.on('done', (nr) => { | ||
const report = SSMS.legacyReport(nr).report(); | ||
console.log(report); | ||
t.equal( | ||
Object.keys(report.errors).length, | ||
0, | ||
'Test with a subprotocol should complete with no errors' | ||
); | ||
ee.stop().then(() => { | ||
t.end(); | ||
}); | ||
}); | ||
|
||
ee.run(); | ||
}); | ||
}); | ||
|
||
test('Subprotocols - no subprotocol', function (t) { | ||
const script = require('./scripts/subprotocols.json'); | ||
script.config.target = `ws://127.0.0.1:${port}`; | ||
delete script.config.ws; | ||
|
||
vuserLauncher(script).then((ee) => { | ||
ee.on('done', (nr) => { | ||
const report = SSMS.legacyReport(nr).report(); | ||
t.equal( | ||
Object.keys(report.errors).length, | ||
0, | ||
'Test with no subprotocol set should complete with no errors' | ||
); | ||
ee.stop().then(() => { | ||
t.end(); | ||
}); | ||
}); | ||
|
||
ee.run(); | ||
}); | ||
}); | ||
|
||
test('Subprotocols - unknown subprotocol', function (t) { | ||
const script = require('./scripts/subprotocols.json'); | ||
script.config.target = `ws://127.0.0.1:${port}`; | ||
|
||
script.config.ws = { | ||
subprotocols: ['unsupportedByTheServer'] | ||
}; | ||
|
||
vuserLauncher(script).then((ee) => { | ||
ee.on('done', (nr) => { | ||
const report = SSMS.legacyReport(nr).report(); | ||
t.equal(Object.keys(report.errors).length, 1, 'Should have one error'); | ||
|
||
// FIXME: This test is coupled to the error message generated by the ws library | ||
t.ok( | ||
Object.keys(report.errors)[0].toLowerCase().indexOf('no subprotocol') > | ||
-1, | ||
'The error should be of "no subprotocol" type' | ||
); | ||
|
||
ee.stop().then(() => { | ||
t.end(); | ||
}); | ||
}); | ||
|
||
ee.run(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
const { test, beforeEach, afterEach } = require('tap'); | ||
const core = require('../../..'); | ||
const vuserLauncher = core.runner.runner; | ||
const { SSMS } = require('../../../lib/ssms'); | ||
const createTestServer = require('../../targets/ws_tls'); | ||
|
||
let server; | ||
let port; | ||
beforeEach(async () => { | ||
const serverInfo = await createTestServer(); | ||
port = serverInfo.port; | ||
server = serverInfo.server; | ||
}); | ||
|
||
afterEach(() => { | ||
server.close(); | ||
}); | ||
|
||
test('TLS - with rejectUnauthorized false', function (t) { | ||
const script = require('./scripts/ws-tls.json'); | ||
script.config.target = `wss://127.0.0.1:${port}`; | ||
vuserLauncher(script).then(function (ee) { | ||
ee.on('done', function (nr) { | ||
const report = SSMS.legacyReport(nr).report(); | ||
console.log(report); | ||
t.ok(Object.keys(report.errors).length === 0, 'Test ran without errors'); | ||
ee.stop().then(() => { | ||
t.end(); | ||
}); | ||
}); | ||
ee.run(); | ||
}); | ||
}); | ||
|
||
test('TLS - with rejectUnauthorized true', function (t) { | ||
const script = require('./scripts/ws-tls.json'); | ||
script.config.target = `wss://127.0.0.1:${port}`; | ||
script.config.ws.rejectUnauthorized = true; | ||
vuserLauncher(script).then(function (ee) { | ||
ee.on('done', function (nr) { | ||
const report = SSMS.legacyReport(nr).report(); | ||
console.log(report); | ||
t.equal( | ||
Object.keys(report.errors).length, | ||
1, | ||
`Test should run with one error. Got: ${Object.keys(report.errors)}` | ||
); | ||
ee.stop().then(() => { | ||
t.end(); | ||
}); | ||
}); | ||
ee.run(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.