From a94083593002daf2a79fdd77fbcb0cd7a7d330db Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Fri, 5 Feb 2021 10:58:10 +0100 Subject: [PATCH] fix(crate): correct trustLevel use --- lib/datasource/common.ts | 1 - lib/datasource/crate/index.spec.ts | 7 ++++--- lib/datasource/crate/index.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/datasource/common.ts b/lib/datasource/common.ts index 5e75686bdd..71fba476d4 100644 --- a/lib/datasource/common.ts +++ b/lib/datasource/common.ts @@ -12,7 +12,6 @@ export interface DigestConfig extends Config { interface ReleasesConfigBase { npmrc?: string; registryUrls?: string[]; - trustLevel?: 'low' | 'high'; } export interface GetReleasesConfig extends ReleasesConfigBase { diff --git a/lib/datasource/crate/index.spec.ts b/lib/datasource/crate/index.spec.ts index 7a4dcf9fea..3ec31ced96 100644 --- a/lib/datasource/crate/index.spec.ts +++ b/lib/datasource/crate/index.spec.ts @@ -75,6 +75,7 @@ describe('datasource/crate', () => { afterEach(() => { fs.rmdirSync(tmpDir.path, { recursive: true }); tmpDir = null; + delete global.trustLevel; }); it('returns null for missing registry url', async () => { expect( @@ -209,11 +210,11 @@ describe('datasource/crate', () => { const { mockClone } = setupGitMocks(); const url = 'https://dl.cloudsmith.io/basic/myorg/myrepo/cargo/index.git'; + global.trustLevel = 'high'; const res = await getPkgReleases({ datasource, depName: 'mypkg', registryUrls: [url], - trustLevel: 'high', }); expect(mockClone).toHaveBeenCalled(); expect(res).toMatchSnapshot(); @@ -224,11 +225,11 @@ describe('datasource/crate', () => { const { mockClone } = setupGitMocks(); const url = 'https://github.com/mcorbin/testregistry'; + global.trustLevel = 'high'; const res = await getPkgReleases({ datasource, depName: 'mypkg', registryUrls: [url], - trustLevel: 'high', }); expect(mockClone).toHaveBeenCalled(); expect(res).toMatchSnapshot(); @@ -239,11 +240,11 @@ describe('datasource/crate', () => { const { mockClone } = setupGitMocks(); const url = 'https://github.com/mcorbin/othertestregistry'; + global.trustLevel = 'high'; await getPkgReleases({ datasource, depName: 'mypkg', registryUrls: [url], - trustLevel: 'high', }); await getPkgReleases({ datasource, diff --git a/lib/datasource/crate/index.ts b/lib/datasource/crate/index.ts index 82935504ca..aee135998b 100644 --- a/lib/datasource/crate/index.ts +++ b/lib/datasource/crate/index.ts @@ -161,7 +161,7 @@ async function fetchRegistryInfo( }; if (flavor !== RegistryFlavor.CratesIo) { - if (config.trustLevel !== 'high') { + if (global.trustLevel !== 'high') { logger.warn( 'crate datasource: trustLevel=high is required for registries other than crates.io, bailing out' ); -- GitLab