0
0
mirror of https://github.com/renovatebot/renovate.git synced 2024-12-22 05:28:35 +00:00
renovatebot_renovate/lib/config/decrypt.spec.ts

45 lines
1.3 KiB
TypeScript

import { logger } from '../../test/util';
import { decryptConfig } from './decrypt';
import { GlobalConfig } from './global';
import type { RenovateConfig } from './types';
const repository = 'abc/def';
describe('config/decrypt', () => {
describe('decryptConfig()', () => {
let config: RenovateConfig;
beforeEach(() => {
config = {};
GlobalConfig.reset();
delete process.env.RENOVATE_X_ENCRYPTED_STRICT;
});
it('returns empty with no privateKey', async () => {
delete config.encrypted;
const res = await decryptConfig(config, repository);
expect(res).toMatchObject(config);
});
it('warns if no privateKey found', async () => {
config.encrypted = { a: '1' };
GlobalConfig.set({ encryptedWarning: 'text' });
const res = await decryptConfig(config, repository);
expect(logger.logger.once.warn).toHaveBeenCalledWith('text');
expect(res.encrypted).toBeUndefined();
expect(res.a).toBeUndefined();
});
it('throws exception if encrypted found but no privateKey', async () => {
config.encrypted = { a: '1' };
process.env.RENOVATE_X_ENCRYPTED_STRICT = 'true';
await expect(decryptConfig(config, repository)).rejects.toThrow(
'config-validation',
);
});
});
});