@verdaccio/e2e-cli 2.10.2 → 2.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -59,12 +59,15 @@ async function testLogin(ctx) {
|
|
|
59
59
|
const who = await yarnWhoami(ctx, tf);
|
|
60
60
|
assert.default.ok(who.includes(user1), `Expected whoami "${user1}" but got "${who}"`);
|
|
61
61
|
});
|
|
62
|
-
await ctx.subTest("login
|
|
62
|
+
await ctx.subTest("legacy re-login is rejected without basic auth", async () => {
|
|
63
63
|
const tf = await prepareLoginProject(ctx, `verdaccio-login2-${id}`);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
let loginFailed = false;
|
|
65
|
+
try {
|
|
66
|
+
await yarnLogin(ctx, tf, user1, password1, email1);
|
|
67
|
+
} catch {
|
|
68
|
+
loginFailed = true;
|
|
69
|
+
}
|
|
70
|
+
assert.default.ok(loginFailed, "Legacy re-login for an existing user should fail without Basic auth");
|
|
68
71
|
});
|
|
69
72
|
await ctx.subTest("wrong password fails", async () => {
|
|
70
73
|
const tf = await prepareLoginProject(ctx, `verdaccio-login3-${id}`);
|
|
@@ -78,6 +81,9 @@ async function testLogin(ctx) {
|
|
|
78
81
|
});
|
|
79
82
|
await ctx.subTest("login then publish", async () => {
|
|
80
83
|
const pkgName = `@verdaccio/login-pub-${id}`;
|
|
84
|
+
const publishUser = `login-pub-${id}`;
|
|
85
|
+
const publishPassword = "publish-password-123";
|
|
86
|
+
const publishEmail = `${publishUser}@test.example.com`;
|
|
81
87
|
const tf = await require_project.createTempFolder(`login-pub-${id}`);
|
|
82
88
|
const yamlContent = js_yaml.default.dump({
|
|
83
89
|
npmRegistryServer: ctx.registryUrl,
|
|
@@ -88,19 +94,22 @@ async function testLogin(ctx) {
|
|
|
88
94
|
await (0, fs_promises.writeFile)((0, path.join)(tf, "package.json"), require_project.getPackageJSON(pkgName, "1.0.0"));
|
|
89
95
|
await (0, fs_promises.writeFile)((0, path.join)(tf, "README.md"), require_project.getREADME(pkgName));
|
|
90
96
|
if (ctx.adapter.importPlugin) await ctx.adapter.importPlugin(tf, "npm-login");
|
|
91
|
-
await yarnLogin(ctx, tf,
|
|
97
|
+
await yarnLogin(ctx, tf, publishUser, publishPassword, publishEmail);
|
|
92
98
|
await ctx.adapter.exec({ cwd: tf }, "install");
|
|
93
99
|
const pubResp = await ctx.adapter.exec({ cwd: tf }, "publish");
|
|
94
100
|
assert.default.ok(pubResp.stdout.includes("Package archive published"), `Expected publish success but got "${pubResp.stdout}"`);
|
|
95
101
|
});
|
|
96
102
|
await ctx.subTest("switch users", async () => {
|
|
103
|
+
const switchUser1 = `login-switch-a-${id}`;
|
|
104
|
+
const switchPassword1 = "switch-password-123";
|
|
105
|
+
const switchEmail1 = `${switchUser1}@test.example.com`;
|
|
97
106
|
const user2 = `login-b-${id}`;
|
|
98
107
|
const password2 = "other-password-456";
|
|
99
108
|
const email2 = `${user2}@test.example.com`;
|
|
100
109
|
const tf = await prepareLoginProject(ctx, `verdaccio-login5-${id}`);
|
|
101
|
-
await yarnLogin(ctx, tf,
|
|
110
|
+
await yarnLogin(ctx, tf, switchUser1, switchPassword1, switchEmail1);
|
|
102
111
|
const who1 = await yarnWhoami(ctx, tf);
|
|
103
|
-
assert.default.ok(who1.includes(
|
|
112
|
+
assert.default.ok(who1.includes(switchUser1), `Expected "${switchUser1}" but got "${who1}"`);
|
|
104
113
|
await yarnLogin(ctx, tf, user2, password2, email2);
|
|
105
114
|
const who2 = await yarnWhoami(ctx, tf);
|
|
106
115
|
assert.default.ok(who2.includes(user2), `Expected "${user2}" after switch but got "${who2}"`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.cjs","names":[],"sources":["../../../src/tests/login.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport YAML from 'js-yaml';\nimport { join } from 'path';\n\nimport { TestContext, TestDefinition } from '../types';\nimport { createTempFolder, getPackageJSON, getREADME } from '../utils/project';\n\nconst debug = buildDebug('verdaccio:e2e-cli:test:login');\n\n/**\n * Creates a project with registry config but WITHOUT auth token,\n * so whoami will use the token saved by login to ~/.yarnrc.yml.\n */\nasync function prepareLoginProject(ctx: TestContext, name: string): Promise<string> {\n debug('preparing project for %s (no auth token)', name);\n const tempFolder = await createTempFolder(name);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tempFolder, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tempFolder, 'package.json'), JSON.stringify({ name, version: '1.0.0' }));\n if (ctx.adapter.importPlugin) {\n debug('importing npm-login plugin into %s', tempFolder);\n await ctx.adapter.importPlugin(tempFolder, 'npm-login');\n }\n return tempFolder;\n}\n\nasync function yarnLogin(\n ctx: TestContext,\n cwd: string,\n user: string,\n password: string,\n email: string\n) {\n debug('yarn npm login as %s', user);\n return ctx.adapter.exec(\n { cwd },\n 'login',\n '--auth-type=legacy',\n `--user=${user}`,\n `--password=${password}`,\n `--email=${email}`\n );\n}\n\nasync function yarnWhoami(ctx: TestContext, cwd: string): Promise<string> {\n const resp = await ctx.adapter.exec({ cwd }, 'whoami');\n debug('yarn npm whoami: %s', resp.stdout);\n return resp.stdout;\n}\n\nasync function testLogin(ctx: TestContext): Promise<void> {\n const type = ctx.adapter.type;\n const id = ctx.runId;\n\n if (type !== 'yarn-modern') {\n debug('login test only supported for yarn-modern, skipping %s', type);\n return;\n }\n\n const user1 = `login-a-${id}`;\n const password1 = 'test-password-123';\n const email1 = `${user1}@test.example.com`;\n\n await ctx.subTest('create new user + whoami', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login1-${id}`);\n const loginResp = await yarnLogin(ctx, tf, user1, password1, email1);\n assert.ok(\n loginResp.stdout.includes('Logged in') || loginResp.stdout.includes('token saved'),\n `Expected login success message but got \"${loginResp.stdout}\"`\n );\n const who = await yarnWhoami(ctx, tf);\n assert.ok(who.includes(user1), `Expected whoami \"${user1}\" but got \"${who}\"`);\n });\n\n await ctx.subTest('login
|
|
1
|
+
{"version":3,"file":"login.cjs","names":[],"sources":["../../../src/tests/login.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport YAML from 'js-yaml';\nimport { join } from 'path';\n\nimport { TestContext, TestDefinition } from '../types';\nimport { createTempFolder, getPackageJSON, getREADME } from '../utils/project';\n\nconst debug = buildDebug('verdaccio:e2e-cli:test:login');\n\n/**\n * Creates a project with registry config but WITHOUT auth token,\n * so whoami will use the token saved by login to ~/.yarnrc.yml.\n */\nasync function prepareLoginProject(ctx: TestContext, name: string): Promise<string> {\n debug('preparing project for %s (no auth token)', name);\n const tempFolder = await createTempFolder(name);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tempFolder, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tempFolder, 'package.json'), JSON.stringify({ name, version: '1.0.0' }));\n if (ctx.adapter.importPlugin) {\n debug('importing npm-login plugin into %s', tempFolder);\n await ctx.adapter.importPlugin(tempFolder, 'npm-login');\n }\n return tempFolder;\n}\n\nasync function yarnLogin(\n ctx: TestContext,\n cwd: string,\n user: string,\n password: string,\n email: string\n) {\n debug('yarn npm login as %s', user);\n return ctx.adapter.exec(\n { cwd },\n 'login',\n '--auth-type=legacy',\n `--user=${user}`,\n `--password=${password}`,\n `--email=${email}`\n );\n}\n\nasync function yarnWhoami(ctx: TestContext, cwd: string): Promise<string> {\n const resp = await ctx.adapter.exec({ cwd }, 'whoami');\n debug('yarn npm whoami: %s', resp.stdout);\n return resp.stdout;\n}\n\nasync function testLogin(ctx: TestContext): Promise<void> {\n const type = ctx.adapter.type;\n const id = ctx.runId;\n\n if (type !== 'yarn-modern') {\n debug('login test only supported for yarn-modern, skipping %s', type);\n return;\n }\n\n const user1 = `login-a-${id}`;\n const password1 = 'test-password-123';\n const email1 = `${user1}@test.example.com`;\n\n await ctx.subTest('create new user + whoami', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login1-${id}`);\n const loginResp = await yarnLogin(ctx, tf, user1, password1, email1);\n assert.ok(\n loginResp.stdout.includes('Logged in') || loginResp.stdout.includes('token saved'),\n `Expected login success message but got \"${loginResp.stdout}\"`\n );\n const who = await yarnWhoami(ctx, tf);\n assert.ok(who.includes(user1), `Expected whoami \"${user1}\" but got \"${who}\"`);\n });\n\n await ctx.subTest('legacy re-login is rejected without basic auth', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login2-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, password1, email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Legacy re-login for an existing user should fail without Basic auth');\n });\n\n await ctx.subTest('wrong password fails', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login3-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, 'wrong-password', email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Login with wrong password should have failed');\n });\n\n await ctx.subTest('login then publish', async () => {\n const pkgName = `@verdaccio/login-pub-${id}`;\n const publishUser = `login-pub-${id}`;\n const publishPassword = 'publish-password-123';\n const publishEmail = `${publishUser}@test.example.com`;\n const tf = await createTempFolder(`login-pub-${id}`);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tf, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tf, 'package.json'), getPackageJSON(pkgName, '1.0.0'));\n await writeFile(join(tf, 'README.md'), getREADME(pkgName));\n if (ctx.adapter.importPlugin) {\n await ctx.adapter.importPlugin(tf, 'npm-login');\n }\n await yarnLogin(ctx, tf, publishUser, publishPassword, publishEmail);\n await ctx.adapter.exec({ cwd: tf }, 'install');\n const pubResp = await ctx.adapter.exec({ cwd: tf }, 'publish');\n assert.ok(\n pubResp.stdout.includes('Package archive published'),\n `Expected publish success but got \"${pubResp.stdout}\"`\n );\n });\n\n await ctx.subTest('switch users', async () => {\n const switchUser1 = `login-switch-a-${id}`;\n const switchPassword1 = 'switch-password-123';\n const switchEmail1 = `${switchUser1}@test.example.com`;\n const user2 = `login-b-${id}`;\n const password2 = 'other-password-456';\n const email2 = `${user2}@test.example.com`;\n const tf = await prepareLoginProject(ctx, `verdaccio-login5-${id}`);\n\n await yarnLogin(ctx, tf, switchUser1, switchPassword1, switchEmail1);\n const who1 = await yarnWhoami(ctx, tf);\n assert.ok(who1.includes(switchUser1), `Expected \"${switchUser1}\" but got \"${who1}\"`);\n\n await yarnLogin(ctx, tf, user2, password2, email2);\n const who2 = await yarnWhoami(ctx, tf);\n assert.ok(who2.includes(user2), `Expected \"${user2}\" after switch but got \"${who2}\"`);\n });\n}\n\nexport const loginTest: TestDefinition = {\n name: 'login',\n requires: ['login'],\n run: testLogin,\n};\n"],"mappings":";;;;;;;;;;;AASA,IAAM,WAAA,GAAA,MAAA,SAAmB,+BAA+B;;;;;AAMxD,eAAe,oBAAoB,KAAkB,MAA+B;CAClF,QAAM,4CAA4C,KAAK;CACvD,MAAM,aAAa,MAAM,gBAAA,iBAAiB,KAAK;CAC/C,MAAM,cAAc,QAAA,QAAK,KAAK;EAC5B,mBAAmB,IAAI;EACvB,yBAAyB;EACzB,qBAAqB,CAAC,YAAY;EACnC,CAAC;CACF,OAAA,GAAA,YAAA,YAAA,GAAA,KAAA,MAAqB,YAAY,cAAc,EAAE,YAAY;CAC7D,OAAA,GAAA,YAAA,YAAA,GAAA,KAAA,MAAqB,YAAY,eAAe,EAAE,KAAK,UAAU;EAAE;EAAM,SAAS;EAAS,CAAC,CAAC;CAC7F,IAAI,IAAI,QAAQ,cAAc;EAC5B,QAAM,sCAAsC,WAAW;EACvD,MA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AAG,YAAY;EACpC,MAAM,QAAQ,WAAW;EACzB,MAAM,YAAY;EAClB,MAAM,SAAS,GAAG,MAAM;EACxB,MAAM,KAAK,MAAM,oBAAoB,KAAK,oBAAoB,KAAK;EAEnE,MAAM,UAAU,KAAK,IAAI,aAAa,iBAAiB,aAAa;EACpE,MAAM,OAAO,MAAM,WAAW,KAAK,GAAG;EACtC,OAAA,QAAO,GAAG,KAAK,SAAS,YAAY,EAAE,aAAa,YAAY,aAAa,KAAK,GAAG;EAEpF,MAAM,UAAU,KAAK,IAAI,OAAO,WAAW,OAAO;EAClD,MAAM,OAAO,MAAM,WAAW,KAAK,GAAG;EACtC,OAAA,QAAO,GAAG,KAAK,SAAS,MAAM,EAAE,aAAa,MAAM,0BAA0B,KAAK,GAAG;GACrF;;AAGJ,IAAa,YAA4B;CACvC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,KAAK;CACN"}
|
package/build/esm/tests/login.js
CHANGED
|
@@ -55,12 +55,15 @@ async function testLogin(ctx) {
|
|
|
55
55
|
const who = await yarnWhoami(ctx, tf);
|
|
56
56
|
assert.ok(who.includes(user1), `Expected whoami "${user1}" but got "${who}"`);
|
|
57
57
|
});
|
|
58
|
-
await ctx.subTest("login
|
|
58
|
+
await ctx.subTest("legacy re-login is rejected without basic auth", async () => {
|
|
59
59
|
const tf = await prepareLoginProject(ctx, `verdaccio-login2-${id}`);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
let loginFailed = false;
|
|
61
|
+
try {
|
|
62
|
+
await yarnLogin(ctx, tf, user1, password1, email1);
|
|
63
|
+
} catch {
|
|
64
|
+
loginFailed = true;
|
|
65
|
+
}
|
|
66
|
+
assert.ok(loginFailed, "Legacy re-login for an existing user should fail without Basic auth");
|
|
64
67
|
});
|
|
65
68
|
await ctx.subTest("wrong password fails", async () => {
|
|
66
69
|
const tf = await prepareLoginProject(ctx, `verdaccio-login3-${id}`);
|
|
@@ -74,6 +77,9 @@ async function testLogin(ctx) {
|
|
|
74
77
|
});
|
|
75
78
|
await ctx.subTest("login then publish", async () => {
|
|
76
79
|
const pkgName = `@verdaccio/login-pub-${id}`;
|
|
80
|
+
const publishUser = `login-pub-${id}`;
|
|
81
|
+
const publishPassword = "publish-password-123";
|
|
82
|
+
const publishEmail = `${publishUser}@test.example.com`;
|
|
77
83
|
const tf = await createTempFolder(`login-pub-${id}`);
|
|
78
84
|
const yamlContent = YAML.dump({
|
|
79
85
|
npmRegistryServer: ctx.registryUrl,
|
|
@@ -84,19 +90,22 @@ async function testLogin(ctx) {
|
|
|
84
90
|
await writeFile(join(tf, "package.json"), getPackageJSON(pkgName, "1.0.0"));
|
|
85
91
|
await writeFile(join(tf, "README.md"), getREADME(pkgName));
|
|
86
92
|
if (ctx.adapter.importPlugin) await ctx.adapter.importPlugin(tf, "npm-login");
|
|
87
|
-
await yarnLogin(ctx, tf,
|
|
93
|
+
await yarnLogin(ctx, tf, publishUser, publishPassword, publishEmail);
|
|
88
94
|
await ctx.adapter.exec({ cwd: tf }, "install");
|
|
89
95
|
const pubResp = await ctx.adapter.exec({ cwd: tf }, "publish");
|
|
90
96
|
assert.ok(pubResp.stdout.includes("Package archive published"), `Expected publish success but got "${pubResp.stdout}"`);
|
|
91
97
|
});
|
|
92
98
|
await ctx.subTest("switch users", async () => {
|
|
99
|
+
const switchUser1 = `login-switch-a-${id}`;
|
|
100
|
+
const switchPassword1 = "switch-password-123";
|
|
101
|
+
const switchEmail1 = `${switchUser1}@test.example.com`;
|
|
93
102
|
const user2 = `login-b-${id}`;
|
|
94
103
|
const password2 = "other-password-456";
|
|
95
104
|
const email2 = `${user2}@test.example.com`;
|
|
96
105
|
const tf = await prepareLoginProject(ctx, `verdaccio-login5-${id}`);
|
|
97
|
-
await yarnLogin(ctx, tf,
|
|
106
|
+
await yarnLogin(ctx, tf, switchUser1, switchPassword1, switchEmail1);
|
|
98
107
|
const who1 = await yarnWhoami(ctx, tf);
|
|
99
|
-
assert.ok(who1.includes(
|
|
108
|
+
assert.ok(who1.includes(switchUser1), `Expected "${switchUser1}" but got "${who1}"`);
|
|
100
109
|
await yarnLogin(ctx, tf, user2, password2, email2);
|
|
101
110
|
const who2 = await yarnWhoami(ctx, tf);
|
|
102
111
|
assert.ok(who2.includes(user2), `Expected "${user2}" after switch but got "${who2}"`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","names":[],"sources":["../../../src/tests/login.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport YAML from 'js-yaml';\nimport { join } from 'path';\n\nimport { TestContext, TestDefinition } from '../types';\nimport { createTempFolder, getPackageJSON, getREADME } from '../utils/project';\n\nconst debug = buildDebug('verdaccio:e2e-cli:test:login');\n\n/**\n * Creates a project with registry config but WITHOUT auth token,\n * so whoami will use the token saved by login to ~/.yarnrc.yml.\n */\nasync function prepareLoginProject(ctx: TestContext, name: string): Promise<string> {\n debug('preparing project for %s (no auth token)', name);\n const tempFolder = await createTempFolder(name);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tempFolder, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tempFolder, 'package.json'), JSON.stringify({ name, version: '1.0.0' }));\n if (ctx.adapter.importPlugin) {\n debug('importing npm-login plugin into %s', tempFolder);\n await ctx.adapter.importPlugin(tempFolder, 'npm-login');\n }\n return tempFolder;\n}\n\nasync function yarnLogin(\n ctx: TestContext,\n cwd: string,\n user: string,\n password: string,\n email: string\n) {\n debug('yarn npm login as %s', user);\n return ctx.adapter.exec(\n { cwd },\n 'login',\n '--auth-type=legacy',\n `--user=${user}`,\n `--password=${password}`,\n `--email=${email}`\n );\n}\n\nasync function yarnWhoami(ctx: TestContext, cwd: string): Promise<string> {\n const resp = await ctx.adapter.exec({ cwd }, 'whoami');\n debug('yarn npm whoami: %s', resp.stdout);\n return resp.stdout;\n}\n\nasync function testLogin(ctx: TestContext): Promise<void> {\n const type = ctx.adapter.type;\n const id = ctx.runId;\n\n if (type !== 'yarn-modern') {\n debug('login test only supported for yarn-modern, skipping %s', type);\n return;\n }\n\n const user1 = `login-a-${id}`;\n const password1 = 'test-password-123';\n const email1 = `${user1}@test.example.com`;\n\n await ctx.subTest('create new user + whoami', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login1-${id}`);\n const loginResp = await yarnLogin(ctx, tf, user1, password1, email1);\n assert.ok(\n loginResp.stdout.includes('Logged in') || loginResp.stdout.includes('token saved'),\n `Expected login success message but got \"${loginResp.stdout}\"`\n );\n const who = await yarnWhoami(ctx, tf);\n assert.ok(who.includes(user1), `Expected whoami \"${user1}\" but got \"${who}\"`);\n });\n\n await ctx.subTest('login
|
|
1
|
+
{"version":3,"file":"login.js","names":[],"sources":["../../../src/tests/login.ts"],"sourcesContent":["import assert from 'assert';\nimport buildDebug from 'debug';\nimport { writeFile } from 'fs/promises';\nimport YAML from 'js-yaml';\nimport { join } from 'path';\n\nimport { TestContext, TestDefinition } from '../types';\nimport { createTempFolder, getPackageJSON, getREADME } from '../utils/project';\n\nconst debug = buildDebug('verdaccio:e2e-cli:test:login');\n\n/**\n * Creates a project with registry config but WITHOUT auth token,\n * so whoami will use the token saved by login to ~/.yarnrc.yml.\n */\nasync function prepareLoginProject(ctx: TestContext, name: string): Promise<string> {\n debug('preparing project for %s (no auth token)', name);\n const tempFolder = await createTempFolder(name);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tempFolder, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tempFolder, 'package.json'), JSON.stringify({ name, version: '1.0.0' }));\n if (ctx.adapter.importPlugin) {\n debug('importing npm-login plugin into %s', tempFolder);\n await ctx.adapter.importPlugin(tempFolder, 'npm-login');\n }\n return tempFolder;\n}\n\nasync function yarnLogin(\n ctx: TestContext,\n cwd: string,\n user: string,\n password: string,\n email: string\n) {\n debug('yarn npm login as %s', user);\n return ctx.adapter.exec(\n { cwd },\n 'login',\n '--auth-type=legacy',\n `--user=${user}`,\n `--password=${password}`,\n `--email=${email}`\n );\n}\n\nasync function yarnWhoami(ctx: TestContext, cwd: string): Promise<string> {\n const resp = await ctx.adapter.exec({ cwd }, 'whoami');\n debug('yarn npm whoami: %s', resp.stdout);\n return resp.stdout;\n}\n\nasync function testLogin(ctx: TestContext): Promise<void> {\n const type = ctx.adapter.type;\n const id = ctx.runId;\n\n if (type !== 'yarn-modern') {\n debug('login test only supported for yarn-modern, skipping %s', type);\n return;\n }\n\n const user1 = `login-a-${id}`;\n const password1 = 'test-password-123';\n const email1 = `${user1}@test.example.com`;\n\n await ctx.subTest('create new user + whoami', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login1-${id}`);\n const loginResp = await yarnLogin(ctx, tf, user1, password1, email1);\n assert.ok(\n loginResp.stdout.includes('Logged in') || loginResp.stdout.includes('token saved'),\n `Expected login success message but got \"${loginResp.stdout}\"`\n );\n const who = await yarnWhoami(ctx, tf);\n assert.ok(who.includes(user1), `Expected whoami \"${user1}\" but got \"${who}\"`);\n });\n\n await ctx.subTest('legacy re-login is rejected without basic auth', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login2-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, password1, email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Legacy re-login for an existing user should fail without Basic auth');\n });\n\n await ctx.subTest('wrong password fails', async () => {\n const tf = await prepareLoginProject(ctx, `verdaccio-login3-${id}`);\n let loginFailed = false;\n try {\n await yarnLogin(ctx, tf, user1, 'wrong-password', email1);\n } catch {\n loginFailed = true;\n }\n assert.ok(loginFailed, 'Login with wrong password should have failed');\n });\n\n await ctx.subTest('login then publish', async () => {\n const pkgName = `@verdaccio/login-pub-${id}`;\n const publishUser = `login-pub-${id}`;\n const publishPassword = 'publish-password-123';\n const publishEmail = `${publishUser}@test.example.com`;\n const tf = await createTempFolder(`login-pub-${id}`);\n const yamlContent = YAML.dump({\n npmRegistryServer: ctx.registryUrl,\n enableImmutableInstalls: false,\n unsafeHttpWhitelist: ['localhost'],\n });\n await writeFile(join(tf, '.yarnrc.yml'), yamlContent);\n await writeFile(join(tf, 'package.json'), getPackageJSON(pkgName, '1.0.0'));\n await writeFile(join(tf, 'README.md'), getREADME(pkgName));\n if (ctx.adapter.importPlugin) {\n await ctx.adapter.importPlugin(tf, 'npm-login');\n }\n await yarnLogin(ctx, tf, publishUser, publishPassword, publishEmail);\n await ctx.adapter.exec({ cwd: tf }, 'install');\n const pubResp = await ctx.adapter.exec({ cwd: tf }, 'publish');\n assert.ok(\n pubResp.stdout.includes('Package archive published'),\n `Expected publish success but got \"${pubResp.stdout}\"`\n );\n });\n\n await ctx.subTest('switch users', async () => {\n const switchUser1 = `login-switch-a-${id}`;\n const switchPassword1 = 'switch-password-123';\n const switchEmail1 = `${switchUser1}@test.example.com`;\n const user2 = `login-b-${id}`;\n const password2 = 'other-password-456';\n const email2 = `${user2}@test.example.com`;\n const tf = await prepareLoginProject(ctx, `verdaccio-login5-${id}`);\n\n await yarnLogin(ctx, tf, switchUser1, switchPassword1, switchEmail1);\n const who1 = await yarnWhoami(ctx, tf);\n assert.ok(who1.includes(switchUser1), `Expected \"${switchUser1}\" but got \"${who1}\"`);\n\n await yarnLogin(ctx, tf, user2, password2, email2);\n const who2 = await yarnWhoami(ctx, tf);\n assert.ok(who2.includes(user2), `Expected \"${user2}\" after switch but got \"${who2}\"`);\n });\n}\n\nexport const loginTest: TestDefinition = {\n name: 'login',\n requires: ['login'],\n run: testLogin,\n};\n"],"mappings":";;;;;;;AASA,IAAM,QAAQ,WAAW,+BAA+B;;;;;AAMxD,eAAe,oBAAoB,KAAkB,MAA+B;CAClF,MAAM,4CAA4C,KAAK;CACvD,MAAM,aAAa,MAAM,iBAAiB,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,OAAO,GACL,QAAQ,OAAO,SAAS,4BAA4B,EACpD,qCAAqC,QAAQ,OAAO,GACrD;GACD;CAEF,MAAM,IAAI,QAAQ,gBAAgB,YAAY;EAC5C,MAAM,cAAc,kBAAkB;EACtC,MAAM,kBAAkB;EACxB,MAAM,eAAe,GAAG,YAAY;EACpC,MAAM,QAAQ,WAAW;EACzB,MAAM,YAAY;EAClB,MAAM,SAAS,GAAG,MAAM;EACxB,MAAM,KAAK,MAAM,oBAAoB,KAAK,oBAAoB,KAAK;EAEnE,MAAM,UAAU,KAAK,IAAI,aAAa,iBAAiB,aAAa;EACpE,MAAM,OAAO,MAAM,WAAW,KAAK,GAAG;EACtC,OAAO,GAAG,KAAK,SAAS,YAAY,EAAE,aAAa,YAAY,aAAa,KAAK,GAAG;EAEpF,MAAM,UAAU,KAAK,IAAI,OAAO,WAAW,OAAO;EAClD,MAAM,OAAO,MAAM,WAAW,KAAK,GAAG;EACtC,OAAO,GAAG,KAAK,SAAS,MAAM,EAAE,aAAa,MAAM,0BAA0B,KAAK,GAAG;GACrF;;AAGJ,IAAa,YAA4B;CACvC,MAAM;CACN,UAAU,CAAC,QAAQ;CACnB,KAAK;CACN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdaccio/e2e-cli",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "CLI tool to run Verdaccio e2e tests against any running registry",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@verdaccio/registry-cli": "^1.1.0",
|
|
31
|
-
"debug": "4.4.
|
|
31
|
+
"debug": "4.4.3",
|
|
32
32
|
"get-port": "5.1.1",
|
|
33
|
-
"js-yaml": "4.
|
|
33
|
+
"js-yaml": "4.3.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/debug": "4.1.12",
|