Skip to content

Commit 33bd35b

Browse files
committed
[keystore] use get_keystore in server cli
1 parent e9ec039 commit 33bd35b

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/cli/serve/read_keystore.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@
1717
* under the License.
1818
*/
1919

20-
import path from 'path';
2120
import { set } from '@elastic/safer-lodash-set';
2221

2322
import { Keystore } from '../../legacy/server/keystore';
24-
import { getDataPath } from '../../core/server/path';
23+
import { getKeystore } from '../../cli_keystore/get_keystore';
2524

26-
export function readKeystore(dataPath = getDataPath()) {
27-
const keystore = new Keystore(path.join(dataPath, 'kibana.keystore'));
25+
export function readKeystore(keystorePath = getKeystore()) {
26+
const keystore = new Keystore(keystorePath);
2827
keystore.load();
2928

3029
const keys = Object.keys(keystore.data);

src/cli/serve/read_keystore.test.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,17 @@ describe('cli/serve/read_keystore', () => {
4040
});
4141
});
4242

43-
it('uses data path provided', () => {
44-
const keystoreDir = '/foo/';
45-
const keystorePath = path.join(keystoreDir, 'kibana.keystore');
43+
it('uses data path if provided', () => {
44+
const keystorePath = path.join('/foo/', 'kibana.keystore');
4645

47-
readKeystore(keystoreDir);
48-
expect(Keystore.mock.calls[0][0]).toEqual(keystorePath);
46+
readKeystore(keystorePath);
47+
expect(Keystore.mock.calls[0][0]).toContain(keystorePath);
48+
});
49+
50+
it('uses the getKeystore path if not', () => {
51+
readKeystore();
52+
// we test exact path scenarios in get_keystore.test.js - we use both
53+
// deprecated and new to cover any older local environments
54+
expect(Keystore.mock.calls[0][0]).toMatch(/data|config/);
4955
});
5056
});

0 commit comments

Comments
 (0)