Remove always-auth configuration handling from action (#1436)
Some checks failed
versions / version-file-volta-extends (windows-latest) (push) Has been cancelled
versions / node-dist (17, macos-latest) (push) Has been cancelled
Basic validation / Basic validation (push) Has been cancelled
Check dist / Check dist/ (push) Has been cancelled
CodeQL analysis / CodeQL analysis (push) Has been cancelled
versions / manifest (20.10.0, macos-latest-large) (push) Has been cancelled
versions / manifest (20.10.0, ubuntu-latest) (push) Has been cancelled
versions / manifest (20.10.0, windows-latest) (push) Has been cancelled
versions / manifest (22.0.0, macos-latest) (push) Has been cancelled
versions / manifest (22.0.0, macos-latest-large) (push) Has been cancelled
versions / manifest (22.0.0, ubuntu-latest) (push) Has been cancelled
versions / manifest (22.0.0, windows-latest) (push) Has been cancelled
versions / manifest (24.9.0, macos-latest) (push) Has been cancelled
versions / manifest (24.9.0, macos-latest-large) (push) Has been cancelled
versions / manifest (24.9.0, ubuntu-latest) (push) Has been cancelled
versions / manifest (24.9.0, windows-latest) (push) Has been cancelled
versions / check-latest (20, macos-latest) (push) Has been cancelled
versions / check-latest (24, macos-latest) (push) Has been cancelled
versions / version-file (.tool-versions, macos-latest) (push) Has been cancelled
versions / version-file (package.json, windows-latest) (push) Has been cancelled
versions / version-file-volta (macos-latest) (push) Has been cancelled
versions / version-file-volta (macos-latest-large) (push) Has been cancelled
versions / version-file-volta (ubuntu-latest) (push) Has been cancelled
versions / version-file-volta (windows-latest) (push) Has been cancelled
versions / version-file-volta-extends (macos-latest) (push) Has been cancelled
versions / version-file-volta-extends (macos-latest-large) (push) Has been cancelled
versions / version-file-volta-extends (ubuntu-latest) (push) Has been cancelled
versions / node-dist (17, macos-latest-large) (push) Has been cancelled
versions / node-dist (17, ubuntu-latest) (push) Has been cancelled
versions / node-dist (17, windows-latest) (push) Has been cancelled
versions / node-dist (19, macos-latest) (push) Has been cancelled
versions / node-dist (19, macos-latest-large) (push) Has been cancelled
versions / node-dist (19, ubuntu-latest) (push) Has been cancelled
versions / node-dist (19, windows-latest) (push) Has been cancelled
versions / old-versions (macos-latest-large) (push) Has been cancelled
versions / old-versions (ubuntu-latest) (push) Has been cancelled
versions / old-versions (windows-latest) (push) Has been cancelled
versions / arch (push) Has been cancelled
versions / local-cache (22, ubuntu-latest) (push) Has been cancelled
versions / local-cache (22, windows-latest) (push) Has been cancelled
versions / local-cache (24, macos-latest) (push) Has been cancelled
versions / local-cache (24, macos-latest-large) (push) Has been cancelled
versions / local-cache (24, ubuntu-latest) (push) Has been cancelled
versions / local-cache (24, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/*, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/*, ubuntu-latest) (push) Has been cancelled
versions / nightly-syntax (25-nightly, windows-latest) (push) Has been cancelled
versions / version-file (package.json, macos-latest) (push) Has been cancelled
versions / version-file (package.json, macos-latest-large) (push) Has been cancelled
e2e-cache / Test npm (Node 20, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test npm (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn subprojects-1 (push) Has been cancelled
e2e-cache / Test yarn subprojects some locally managed (push) Has been cancelled
e2e-cache / Test yarn subprojects some locally managed-1 (push) Has been cancelled
e2e-cache / Test yarn subprojects some locally managed-2 (push) Has been cancelled
e2e-cache / Test yarn subprojects managed by git (push) Has been cancelled
e2e-cache / Test yarn subprojects managed by git-1 (push) Has been cancelled
e2e-cache / Test yarn subprojects managed by git-2 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-1 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-2 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-3 (push) Has been cancelled
versions / version-file (package.json, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn subprojects all locally managed (push) Has been cancelled
e2e-cache / Test yarn subprojects all locally managed-1 (push) Has been cancelled
e2e-cache / Test yarn subprojects all locally managed-2 (push) Has been cancelled
e2e-cache / Test npm (Node 22, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test npm (Node 24, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test npm (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test pnpm (Node 20, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test pnpm (Node 22, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test pnpm (Node 24, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test pnpm (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 20, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 22, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 24, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 1 (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 20, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn subprojects-2 (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 20, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 20, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 20, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 22, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 22, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 22, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 24, macos-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 24, macos-latest-large) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 24, ubuntu-latest) (push) Has been cancelled
e2e-cache / Test yarn 3 (Node 24, windows-latest) (push) Has been cancelled
e2e-cache / Test yarn subprojects (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-9 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-10 (push) Has been cancelled
versions / local-cache (20, macos-latest) (push) Has been cancelled
versions / local-cache (20, macos-latest-large) (push) Has been cancelled
versions / local-cache (20, ubuntu-latest) (push) Has been cancelled
versions / lts-syntax (lts/*, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/-1, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/-1, ubuntu-latest) (push) Has been cancelled
versions / lts-syntax (lts/-1, windows-latest) (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-4 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-5 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-6 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-7 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-8 (push) Has been cancelled
e2e-cache / Test auto cache with top-level packageManager-11 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-1 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-2 (push) Has been cancelled
versions / local-cache (20, windows-latest) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-3 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-4 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-5 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-6 (push) Has been cancelled
versions / local-cache (22, macos-latest) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-7 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-8 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-9 (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-10 (push) Has been cancelled
versions / local-cache (22, macos-latest-large) (push) Has been cancelled
e2e-cache / Test auto cache with devEngines.packageManager-11 (push) Has been cancelled
Licensed / Licensed (push) Has been cancelled
proxy / test-proxy (push) Has been cancelled
proxy / test-bypass-proxy (push) Has been cancelled
versions / lts-syntax (lts/erbium, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/erbium, ubuntu-latest) (push) Has been cancelled
versions / lts-syntax (lts/erbium, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/dubnium, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/dubnium, ubuntu-latest) (push) Has been cancelled
versions / lts-syntax (lts/dubnium, windows-latest) (push) Has been cancelled
versions / nightly-syntax (25-nightly, macos-latest) (push) Has been cancelled
versions / nightly-syntax (25-nightly, macos-latest-large) (push) Has been cancelled
versions / nightly-syntax (25-nightly, ubuntu-latest) (push) Has been cancelled
versions / rc-syntax (20.0.0-rc.1, macos-latest) (push) Has been cancelled
versions / rc-syntax (20.0.0-rc.1, macos-latest-large) (push) Has been cancelled
versions / rc-syntax (20.0.0-rc.1, ubuntu-latest) (push) Has been cancelled
versions / rc-syntax (20.0.0-rc.1, windows-latest) (push) Has been cancelled
versions / rc-syntax (22.14.0-rc.1, macos-latest) (push) Has been cancelled
versions / rc-syntax (22.14.0-rc.1, macos-latest-large) (push) Has been cancelled
versions / rc-syntax (22.14.0-rc.1, ubuntu-latest) (push) Has been cancelled
versions / rc-syntax (22.14.0-rc.1, windows-latest) (push) Has been cancelled
versions / rc-syntax (24.0.0-rc.4, macos-latest) (push) Has been cancelled
versions / rc-syntax (24.0.0-rc.4, macos-latest-large) (push) Has been cancelled
versions / rc-syntax (24.0.0-rc.4, ubuntu-latest) (push) Has been cancelled
versions / rc-syntax (24.0.0-rc.4, windows-latest) (push) Has been cancelled
versions / manifest (20.10.0, macos-latest) (push) Has been cancelled
versions / check-latest (20, macos-latest-large) (push) Has been cancelled
versions / check-latest (20, ubuntu-latest) (push) Has been cancelled
versions / node-latest-aliases (latest, windows-latest) (push) Has been cancelled
versions / node-latest-aliases (node, macos-latest) (push) Has been cancelled
versions / node-latest-aliases (node, macos-latest-large) (push) Has been cancelled
versions / node-latest-aliases (node, ubuntu-latest) (push) Has been cancelled
versions / node-latest-aliases (node, windows-latest) (push) Has been cancelled
versions / lts-syntax (lts/fermium, macos-latest-large) (push) Has been cancelled
versions / lts-syntax (lts/fermium, ubuntu-latest) (push) Has been cancelled
versions / lts-syntax (lts/fermium, windows-latest) (push) Has been cancelled
versions / v8-canary-syntax (20-v8-canary, macos-latest) (push) Has been cancelled
versions / v8-canary-syntax (20-v8-canary, macos-latest-large) (push) Has been cancelled
versions / v8-canary-syntax (20-v8-canary, ubuntu-latest) (push) Has been cancelled
versions / v8-canary-syntax (20-v8-canary, windows-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary, macos-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary, macos-latest-large) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary, ubuntu-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary, windows-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, macos-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, macos-latest-large) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, ubuntu-latest) (push) Has been cancelled
versions / v8-canary-syntax (20.0.0-v8-canary20221101e50e45c9f8, windows-latest) (push) Has been cancelled
versions / nightly-syntax (20-nightly, macos-latest) (push) Has been cancelled
versions / nightly-syntax (20-nightly, macos-latest-large) (push) Has been cancelled
versions / nightly-syntax (20-nightly, ubuntu-latest) (push) Has been cancelled
versions / nightly-syntax (20-nightly, windows-latest) (push) Has been cancelled
versions / nightly-syntax (24.0.0-nightly, macos-latest) (push) Has been cancelled
versions / nightly-syntax (24.0.0-nightly, macos-latest-large) (push) Has been cancelled
versions / nightly-syntax (24.0.0-nightly, ubuntu-latest) (push) Has been cancelled
versions / nightly-syntax (24.0.0-nightly, windows-latest) (push) Has been cancelled
versions / check-latest (20, windows-latest) (push) Has been cancelled
versions / check-latest (22, macos-latest) (push) Has been cancelled
versions / check-latest (22, macos-latest-large) (push) Has been cancelled
versions / check-latest (22, ubuntu-latest) (push) Has been cancelled
versions / check-latest (22, windows-latest) (push) Has been cancelled
versions / check-latest (24, macos-latest-large) (push) Has been cancelled
versions / check-latest (24, ubuntu-latest) (push) Has been cancelled
versions / check-latest (24, windows-latest) (push) Has been cancelled
versions / version-file (.nvmrc, macos-latest) (push) Has been cancelled
versions / version-file (.nvmrc, macos-latest-large) (push) Has been cancelled
versions / version-file (.nvmrc, ubuntu-latest) (push) Has been cancelled
versions / version-file (.nvmrc, windows-latest) (push) Has been cancelled
versions / version-file (.tool-versions, macos-latest-large) (push) Has been cancelled
versions / version-file (.tool-versions, ubuntu-latest) (push) Has been cancelled
versions / version-file (.tool-versions, windows-latest) (push) Has been cancelled
versions / version-file (.tool-versions-node, macos-latest) (push) Has been cancelled
versions / version-file (.tool-versions-node, macos-latest-large) (push) Has been cancelled
versions / version-file (.tool-versions-node, ubuntu-latest) (push) Has been cancelled
versions / version-file (.tool-versions-node, windows-latest) (push) Has been cancelled
versions / node-latest-aliases (current, macos-latest) (push) Has been cancelled
versions / node-latest-aliases (current, macos-latest-large) (push) Has been cancelled
versions / node-latest-aliases (current, ubuntu-latest) (push) Has been cancelled
versions / node-latest-aliases (current, windows-latest) (push) Has been cancelled
versions / node-latest-aliases (latest, macos-latest) (push) Has been cancelled
versions / node-latest-aliases (latest, macos-latest-large) (push) Has been cancelled
versions / node-latest-aliases (latest, ubuntu-latest) (push) Has been cancelled

* Remove always-auth configuration handling from setup-node

* docs: update README to note always-auth removal

Update README to mention removal of always-auth input

* Clarify removal of 'always-auth' input in README

Updated the description of the 'always-auth' input removal for clarity.
This commit is contained in:
Priya Gupta 2025-11-26 23:07:55 +05:30 committed by GitHub
parent 633bb92bc0
commit b9b25d45f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 34 additions and 85 deletions

View file

@ -76,115 +76,102 @@ describe('authutil tests', () => {
}
it('Sets up npmrc for npmjs', async () => {
await auth.configAuthentication('https://registry.npmjs.org/', 'false');
await auth.configAuthentication('https://registry.npmjs.org/');
expect(fs.statSync(rcFile)).toBeDefined();
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
const rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false');
});
it('Appends trailing slash to registry', async () => {
await auth.configAuthentication('https://registry.npmjs.org', 'false');
await auth.configAuthentication('https://registry.npmjs.org');
expect(fs.statSync(rcFile)).toBeDefined();
const rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false');
});
it('Configures scoped npm registries', async () => {
process.env['INPUT_SCOPE'] = 'myScope';
await auth.configAuthentication('https://registry.npmjs.org', 'false');
await auth.configAuthentication('https://registry.npmjs.org');
expect(fs.statSync(rcFile)).toBeDefined();
const rc = readRcFile(rcFile);
expect(rc['@myscope:registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('false');
});
it('Automatically configures GPR scope', async () => {
await auth.configAuthentication('npm.pkg.github.com', 'false');
await auth.configAuthentication('npm.pkg.github.com');
expect(fs.statSync(rcFile)).toBeDefined();
const rc = readRcFile(rcFile);
expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/');
expect(rc['always-auth']).toBe('false');
});
it('Sets up npmrc for always-auth true', async () => {
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
expect(fs.statSync(rcFile)).toBeDefined();
const rc = readRcFile(rcFile);
expect(rc['registry']).toBe('https://registry.npmjs.org/');
expect(rc['always-auth']).toBe('true');
});
it('is already set the NODE_AUTH_TOKEN export it', async () => {
process.env.NODE_AUTH_TOKEN = 'foobar';
await auth.configAuthentication('npm.pkg.github.com', 'false');
await auth.configAuthentication('npm.pkg.github.com');
expect(fs.statSync(rcFile)).toBeDefined();
const rc = readRcFile(rcFile);
expect(rc['@ownername:registry']).toBe('npm.pkg.github.com/');
expect(rc['always-auth']).toBe('false');
expect(process.env.NODE_AUTH_TOKEN).toEqual('foobar');
});
it('configAuthentication should overwrite non-scoped with non-scoped', async () => {
fs.writeFileSync(rcFile, 'registry=NNN');
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe(
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
);
});
it('configAuthentication should overwrite only non-scoped', async () => {
fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe(
`@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
`@myscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
);
});
it('configAuthentication should add non-scoped to scoped', async () => {
fs.writeFileSync(rcFile, '@myscope:registry=NNN');
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe(
`@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
`@myscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}registry=https://registry.npmjs.org/`
);
});
it('configAuthentication should overwrite scoped with scoped', async () => {
process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `@myscope:registry=NNN`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe(
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
`//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
);
});
it('configAuthentication should overwrite only scoped', async () => {
process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `registry=NNN${os.EOL}@myscope:registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe(
`registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
`registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
);
});
it('configAuthentication should add scoped to non-scoped', async () => {
process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe(
`registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
`registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
);
});
@ -194,20 +181,20 @@ describe('authutil tests', () => {
rcFile,
`@otherscope:registry=NNN${os.EOL}@myscope:registry=MMM`
);
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe(
`@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
`@otherscope:registry=NNN${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
);
});
it('configAuthentication should add scoped to another scoped', async () => {
process.env['INPUT_SCOPE'] = 'myscope';
fs.writeFileSync(rcFile, `@otherscope:registry=MMM`);
await auth.configAuthentication('https://registry.npmjs.org/', 'true');
await auth.configAuthentication('https://registry.npmjs.org/');
const contents = fs.readFileSync(rcFile, {encoding: 'utf8'});
expect(contents).toBe(
`@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/${os.EOL}always-auth=true`
`@otherscope:registry=MMM${os.EOL}//registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN}${os.EOL}@myscope:registry=https://registry.npmjs.org/`
);
});
});