Skip to content

Commit

Permalink
resolved get_keystore unit test (#3854) (#3864)
Browse files Browse the repository at this point in the history
(cherry picked from commit 677dcbd)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 9eb8eb9 commit e676534
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/cli_keystore/get_keystore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { getKeystore } from './get_keystore';
import { Logger } from '../cli_plugin/lib/logger';
import fs from 'fs';
import sinon from 'sinon';
import { getConfigDirectory, getDataPath } from '@osd/utils';
import { join } from 'path';

describe('get_keystore', () => {
const sandbox = sinon.createSandbox();
Expand All @@ -45,15 +47,19 @@ describe('get_keystore', () => {
});

it('uses the config directory if there is no pre-existing keystore', () => {
const configKeystore = join(getConfigDirectory(), 'opensearch_dashboards.keystore');
const dataKeystore = join(getDataPath(), 'opensearch_dashboards.keystore');
sandbox.stub(fs, 'existsSync').returns(false);
expect(getKeystore()).toContain('config');
expect(getKeystore()).not.toContain('data');
expect(getKeystore()).toContain(configKeystore);
expect(getKeystore()).not.toContain(dataKeystore);
});

it('uses the data directory if there is a pre-existing keystore in the data directory', () => {
const configKeystore = join(getConfigDirectory(), 'opensearch_dashboards.keystore');
const dataKeystore = join(getDataPath(), 'opensearch_dashboards.keystore');
sandbox.stub(fs, 'existsSync').returns(true);
expect(getKeystore()).toContain('data');
expect(getKeystore()).not.toContain('config');
expect(getKeystore()).toContain(dataKeystore);
expect(getKeystore()).not.toContain(configKeystore);
});

it('logs a deprecation warning if the data directory is used', () => {
Expand Down

0 comments on commit e676534

Please sign in to comment.