text: /*
   * Licensed to Elasticsearch B.V. under one or more contributor
   * license agreements. See the NOTICE file distributed with
   * this work for additional information regarding copyright
   * ownership. Elasticsearch B.V. licenses this file to you under
   * the Apache License, Version 2.0 (the "License"); you may
   * not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *    http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing,
   * software distributed under the License is distributed on an
   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   * KIND, either express or implied.  See the License for the
   * specific language governing permissions and limitations
   * under the License.
   */
  
  const mockKeystoreData = '1:IxR0geiUTMJp8ueHDkqeUJ0I9eEw4NJPXIJi22UDyfGfJSy4mH'
    + 'BBuGPkkAix/x/YFfIxo4tiKGdJ2oVTtU8LgKDkVoGdL+z7ylY4n3myatt6osqhI4lzJ9M'
    + 'Ry21UcAJki2qFUTj4TYuvhta3LId+RM5UX/dJ2468hQ==';
  
  jest.mock('fs', () => ({
    readFileSync: jest.fn().mockImplementation(() => JSON.stringify(mockKeystoreData)),
    existsSync: jest.fn().mockImplementation(() => true),
    writeFileSync: jest.fn()
  }));
  
  import sinon from 'sinon';
  
  import { Keystore } from '../server/keystore';
  import { remove } from './remove';
  
  describe('Kibana keystore', () => {
    describe('remove', () => {
      const sandbox = sinon.createSandbox();
  
      afterEach(() => {
        sandbox.restore();
      });
  
      it('removes key', () => {
        const keystore = new Keystore('/data/test.keystore');
  
        remove(keystore, 'a2');
  
        expect(keystore.data).toEqual({ 'a1.b2.c3': 'foo' });
      });
  
      it('persists the keystore', () => {
        const keystore = new Keystore('/data/test.keystore');
        sandbox.stub(keystore, 'save');
  
        remove(keystore, 'a2');
  
        sinon.assert.calledOnce(keystore.save);
      });
    });
  
    afterAll(() => {
      jest.restoreAllMocks();
    });
  });
  