Skip to content

Commit

Permalink
fix(crate): correct trustLevel use
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Feb 5, 2021
1 parent 3756f2a commit a940835
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion lib/datasource/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export interface DigestConfig extends Config {
interface ReleasesConfigBase {
npmrc?: string;
registryUrls?: string[];
trustLevel?: 'low' | 'high';
}

export interface GetReleasesConfig extends ReleasesConfigBase {
Expand Down
7 changes: 4 additions & 3 deletions lib/datasource/crate/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/datasource/crate/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
);
Expand Down

0 comments on commit a940835

Please sign in to comment.