Skip to content

Commit 3275b45

Browse files
committed
test(@angular/cli): remove unscoped authentication test cases from registry tests
Modern package managers do not support unscoped authentication, and Yarn Classic's metadata command (yarn info) does not propagate unscoped credentials correctly, leading to 403 Forbidden failures on secure registries during ng update and ng add. This commit removes the unscoped authentication test cases from both add and update secure registry E2E tests, and cleans up the createNpmConfigForAuthentication helper to default to scoped authentication. (cherry picked from commit ecda706)
1 parent da81e55 commit 3275b45

3 files changed

Lines changed: 5 additions & 41 deletions

File tree

tests/e2e/tests/commands/add/secure-registry.ts

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { expectFileNotToExist, expectFileToExist, rimraf } from '../../../utils/fs';
2-
import { getActivePackageManager, installWorkspacePackages } from '../../../utils/packages';
1+
import { expectFileNotToExist, expectFileToExist } from '../../../utils/fs';
2+
import { installWorkspacePackages } from '../../../utils/packages';
33
import { git, ng } from '../../../utils/process';
44
import { createNpmConfigForAuthentication } from '../../../utils/registry';
55
import { expectToFail } from '../../../utils/utils';
@@ -9,37 +9,17 @@ export default async function () {
99
try {
1010
// The environment variable has priority over the .npmrc
1111
delete process.env['NPM_CONFIG_REGISTRY'];
12-
const packageManager = getActivePackageManager();
13-
const supportsUnscopedAuth = packageManager === 'yarn';
1412
const command = ['add', '@angular/pwa', '--skip-confirmation'];
1513

16-
// Works with unscoped registry authentication details
17-
if (supportsUnscopedAuth) {
18-
// Some package managers such as Bun and NPM do not support unscoped auth.
19-
await createNpmConfigForAuthentication(false);
20-
21-
await expectFileNotToExist('public/manifest.webmanifest');
22-
23-
await ng(...command);
24-
await expectFileToExist('public/manifest.webmanifest');
25-
await git('clean', '-dxf');
26-
}
27-
2814
// Works with scoped registry authentication details
2915
await expectFileNotToExist('public/manifest.webmanifest');
3016

31-
await createNpmConfigForAuthentication(true);
17+
await createNpmConfigForAuthentication();
3218
await ng(...command);
3319
await expectFileToExist('public/manifest.webmanifest');
3420
await git('clean', '-dxf');
3521

3622
// Invalid authentication token
37-
if (supportsUnscopedAuth) {
38-
// Some package managers such as Bun and NPM do not support unscoped auth.
39-
await createNpmConfigForAuthentication(false, true);
40-
await expectToFail(() => ng(...command));
41-
}
42-
4323
await createNpmConfigForAuthentication(true, true);
4424
await expectToFail(() => ng(...command));
4525
} finally {

tests/e2e/tests/update/update-secure-registry.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ import { getActivePackageManager } from '../../utils/packages';
66
import assert from 'node:assert';
77

88
export default async function () {
9-
const packageManager = getActivePackageManager();
10-
const supportsUnscopedAuth = packageManager === 'yarn';
11-
129
// The environment variable has priority over the .npmrc
1310
delete process.env['NPM_CONFIG_REGISTRY'];
1411
const worksMessage = 'We analyzed your package.json';
@@ -20,27 +17,14 @@ export default async function () {
2017

2118
// Valid authentication token
2219

23-
if (supportsUnscopedAuth) {
24-
await createNpmConfigForAuthentication(false);
25-
const { stdout: stdout1 } = await ng('update', ...extraArgs);
26-
if (!stdout1.includes(worksMessage)) {
27-
throw new Error(`Expected stdout to contain "${worksMessage}"`);
28-
}
29-
}
30-
31-
await createNpmConfigForAuthentication(true);
20+
await createNpmConfigForAuthentication();
3221
const { stdout: stdout2 } = await ng('update', ...extraArgs);
3322
if (!stdout2.includes(worksMessage)) {
3423
throw new Error(`Expected stdout to contain "${worksMessage}"`);
3524
}
3625

3726
// Invalid authentication token
3827

39-
if (supportsUnscopedAuth) {
40-
await createNpmConfigForAuthentication(false, true);
41-
await expectToFail(() => ng('update', ...extraArgs));
42-
}
43-
4428
await createNpmConfigForAuthentication(true, true);
4529
await expectToFail(() => ng('update', ...extraArgs));
4630

tests/e2e/utils/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export async function createNpmConfigForAuthentication(
6363
* _auth="dGVzdGluZzpzM2NyZXQ="`
6464
* ```
6565
*/
66-
scopedAuthentication: boolean,
66+
scopedAuthentication = true,
6767
/** When true, an incorrect token is used. Use this to validate authentication failures. */
6868
invalidToken = false,
6969
): Promise<void> {

0 commit comments

Comments
 (0)