Skip to content
Snippets Groups Projects
Unverified Commit 94fddc05 authored by Yun Lai's avatar Yun Lai Committed by GitHub
Browse files

fix(host-rules): call set global host rules before init platform (#25521)

parent f9d1cade
No related branches found
No related tags found
No related merge requests found
import { git, mockedFunction } from '../../../test/util';
import type { AllConfig, RenovateConfig } from '../../config/types';
import { initPlatform as _initPlatform } from '../../modules/platform';
import * as hostRules from '../../util/host-rules';
import { globalInitialize } from './initialize';
jest.mock('../../util/git');
......@@ -39,4 +40,43 @@ describe('workers/global/initialize', () => {
await expect(globalInitialize(config)).toResolve();
});
});
describe('setGlobalHostRules', () => {
beforeEach(() => {
hostRules.clear();
});
it('should have run before initPlatform', async () => {
const hostRule = {
hostType: 'github',
matchHost: 'https://some.github-enterprise.host',
httpsPrivateKey: 'private-key',
httpsCertificate: 'certificate',
httpsCertificateAuthority: 'certificate-authority',
};
initPlatform.mockReset();
initPlatform.mockImplementationOnce((r) => {
const foundRule = hostRules.find({
hostType: hostRule.hostType,
url: hostRule.matchHost,
});
expect(foundRule.httpsPrivateKey).toEqual(hostRule.httpsPrivateKey);
expect(foundRule.httpsCertificateAuthority).toEqual(
hostRule.httpsCertificateAuthority,
);
expect(foundRule.httpsCertificate).toEqual(hostRule.httpsCertificate);
return Promise.resolve(r);
});
const config: RenovateConfig = {
hostRules: [hostRule],
};
git.validateGitVersion.mockResolvedValueOnce(true);
await expect(globalInitialize(config)).toResolve();
});
});
});
......@@ -69,6 +69,7 @@ export async function globalInitialize(
): Promise<RenovateConfig> {
let config = config_;
await checkVersions();
setGlobalHostRules(config);
config = await initPlatform(config);
config = await setDirectories(config);
await packageCache.init(config);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment