Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(tests): avoid installing package from untrusted registry in integration tests [SECURITY] #8776

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions __tests__/integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,13 @@ describe('--registry option', () => {
expect(lockfile[2]).toContain(registry);
});

test('--registry option with non-exiting registry and show an error', async () => {
test('--registry option with nonexistent registry and show an error', async () => {
const cwd = await makeTemp();
const registry = 'https://example-registry-doesnt-exist.com';
// See https://datatracker.ietf.org/doc/html/rfc6761#section-6.4
const registry = 'https://example-registry-doesnt-exist.invalid';

try {
await runYarn(['add', 'is-array', '--registry', registry], {cwd});
} catch (err) {
const stdoutOutput = err.message;
expect(stdoutOutput.toString()).toMatch(/getaddrinfo ENOTFOUND example-registry-doesnt-exist\.com/g);
}
const yarnAdd = runYarn(['add', 'is-array', '--registry', registry, '--ignore-scripts'], {cwd});
await expect(yarnAdd).rejects.toThrow(/getaddrinfo .* example-registry-doesnt-exist\.invalid/);
});

test('registry option from yarnrc', async () => {
Expand Down