From 4792203b8fdce41084aa4e7fd0cd02e81ef6107c Mon Sep 17 00:00:00 2001 From: Tomas Della Vedova Date: Mon, 28 Sep 2020 10:17:00 +0200 Subject: [PATCH] Test cloud id without kibana component (#1313) --- test/unit/client.test.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/unit/client.test.js b/test/unit/client.test.js index cd3ce17f7..4991b1ef9 100644 --- a/test/unit/client.test.js +++ b/test/unit/client.test.js @@ -861,6 +861,41 @@ test('Elastic cloud config', t => { t.deepEqual(pool._ssl, { secureProtocol: 'TLSv1_2_method' }) }) + t.test('Without kibana component', t => { + t.plan(5) + const client = new Client({ + cloud: { + // 'localhost$abcd$' + id: 'name:bG9jYWxob3N0JGFiY2Qk', + username: 'elastic', + password: 'changeme' + } + }) + + const pool = client.connectionPool + t.ok(pool instanceof CloudConnectionPool) + t.match(pool.connections.find(c => c.id === 'https://abcd.localhost/'), { + url: new URL('https://elastic:changeme@abcd.localhost'), + id: 'https://abcd.localhost/', + headers: { + authorization: 'Basic ' + Buffer.from('elastic:changeme').toString('base64') + }, + ssl: { secureProtocol: 'TLSv1_2_method' }, + deadCount: 0, + resurrectTimeout: 0, + roles: { + master: true, + data: true, + ingest: true, + ml: false + } + }) + + t.strictEqual(client.transport.compression, 'gzip') + t.strictEqual(client.transport.suggestCompression, true) + t.deepEqual(pool._ssl, { secureProtocol: 'TLSv1_2_method' }) + }) + t.test('Auth as separate option', t => { t.plan(5) const client = new Client({