diff --git a/test/integration/test-runner.js b/test/integration/test-runner.js index 76d0447cd..144310659 100644 --- a/test/integration/test-runner.js +++ b/test/integration/test-runner.js @@ -252,7 +252,7 @@ TestRunner.prototype.set = function (key, name) { TestRunner.prototype.do = function (action, done) { const cmd = this.parseDo(action) const api = delve(this.client, cmd.method).bind(this.client) - const options = { ignore: cmd.params.ignore, headers: cmd.params.headers } + const options = { ignore: cmd.params.ignore, headers: action.headers } api(cmd.params, options, (err, { body, warnings }) => { if (action.warnings && warnings === null) { this.tap.fail('We should get a warning header', action.warnings) diff --git a/test/unit/connection.test.js b/test/unit/connection.test.js index 07eccf053..98a3fe940 100644 --- a/test/unit/connection.test.js +++ b/test/unit/connection.test.js @@ -6,7 +6,7 @@ const { URL } = require('url') const intoStream = require('into-stream') const { buildServer } = require('../utils') const Connection = require('../../lib/Connection') -const { TimeoutError } = require('../../lib/errors') +const { TimeoutError, ConfigurationError } = require('../../lib/errors') test('Basic (http)', t => { t.plan(4) @@ -560,3 +560,16 @@ test('Connection id should not contain credentials', t => { t.strictEqual(connection.id, 'http://localhost:9200/') t.end() }) + +test('Should throw if the protocol is not http or https', t => { + try { + new Connection({ // eslint-disable-line + url: new URL('nope://nope') + }) + t.fail('Should throw') + } catch (err) { + t.ok(err instanceof ConfigurationError) + t.is(err.message, 'Invalid protocol: \'nope:\'') + } + t.end() +})