mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
test(e2e): add test for protected packages
Protected packages are not displayed on UI
This commit is contained in:
parent
8679ee9598
commit
1740aad834
6 changed files with 163 additions and 6 deletions
30
test/e2e/config/config-protected-e2e.yaml
Normal file
30
test/e2e/config/config-protected-e2e.yaml
Normal file
|
@ -0,0 +1,30 @@
|
|||
# this is useless yet since we use a custom storage, just ignore it
|
||||
storage: ./store-e2e
|
||||
|
||||
web:
|
||||
enable: true
|
||||
title: verdaccio-server-protected-e2e
|
||||
|
||||
store:
|
||||
memory:
|
||||
cache: true
|
||||
|
||||
auth:
|
||||
auth-memory:
|
||||
users:
|
||||
test:
|
||||
name: test
|
||||
password: test
|
||||
|
||||
logs:
|
||||
- {type: stdout, format: pretty, level: warn}
|
||||
|
||||
packages:
|
||||
'protected-*':
|
||||
access: $authenticated
|
||||
publish: $authenticated
|
||||
|
||||
listen: 0.0.0.0:55552
|
||||
|
||||
# expose internal methods
|
||||
_debug: true
|
|
@ -1,3 +1,4 @@
|
|||
# this is useless yet since we use a custom storage, just ignore it
|
||||
storage: ./store-e2e
|
||||
|
||||
web:
|
||||
|
@ -24,7 +25,7 @@ packages:
|
|||
publish: $all
|
||||
'**':
|
||||
access: $all
|
||||
publish: $all
|
||||
publish: $authenticated
|
||||
|
||||
listen: 0.0.0.0:55558
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
const publishMetadata = require('../unit/partials/publish-api');
|
||||
const scopedPackageMetadata = require('./partials/pkg-scoped');
|
||||
const protectedPackageMetadata = require('./partials/pkg-protected');
|
||||
|
||||
describe('/ (Verdaccio Page)', () => {
|
||||
let page;
|
||||
// this might be increased based on the delays included in all test
|
||||
jest.setTimeout(20000);
|
||||
jest.setTimeout(200000);
|
||||
|
||||
const clickElement = async function(selector, options = {button: 'middle', delay: 100}) {
|
||||
const button = await page.$(selector);
|
||||
|
@ -18,7 +19,7 @@ describe('/ (Verdaccio Page)', () => {
|
|||
|
||||
const getPackages = async function() {
|
||||
return await page.$$('.package-list-items > div');
|
||||
}
|
||||
};
|
||||
|
||||
const logIn = async function() {
|
||||
await clickElement('header button');
|
||||
|
@ -108,7 +109,7 @@ describe('/ (Verdaccio Page)', () => {
|
|||
})
|
||||
|
||||
it('should publish a package', async () => {
|
||||
await global.__SERVER__.putPackage(publishMetadata.name, publishMetadata);
|
||||
await global.__SERVER__.putPackage(scopedPackageMetadata.name, scopedPackageMetadata);
|
||||
await page.waitFor(1000);
|
||||
await page.reload();
|
||||
await page.waitFor(1000);
|
||||
|
@ -133,4 +134,15 @@ describe('/ (Verdaccio Page)', () => {
|
|||
expect(versionList).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('should publish a protected package', async () => {
|
||||
await page.goto('http://0.0.0.0:55552');
|
||||
await page.waitFor(500);
|
||||
await global.__SERVER_PROTECTED__.putPackage(protectedPackageMetadata.name, protectedPackageMetadata);
|
||||
await page.waitFor(500);
|
||||
await page.reload();
|
||||
await page.waitFor(500);
|
||||
let text = await page.evaluate(() => document.querySelector('.container h1').textContent);
|
||||
expect(text).toMatch('No Package Published Yet');
|
||||
});
|
||||
|
||||
});
|
||||
|
|
53
test/e2e/partials/pkg-protected.js
Normal file
53
test/e2e/partials/pkg-protected.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
const json = {
|
||||
"_id": "protected-pkg",
|
||||
"name": "protected-pkg",
|
||||
"description": "",
|
||||
"dist-tags": {
|
||||
"latest": "5.0.5"
|
||||
},
|
||||
"versions": {
|
||||
"5.0.5": {
|
||||
"name": "protected-pkg",
|
||||
"version": "5.0.5",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
],
|
||||
"author": {
|
||||
"name": "Juan Picado",
|
||||
"email": "juan@jotadeveloper.com"
|
||||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"verdaccio": "^2.7.2"
|
||||
},
|
||||
"readme": "# test",
|
||||
"readmeFilename": "README.md",
|
||||
"_id": "protected-pkg@5.0.5",
|
||||
"_npmVersion": "5.5.1",
|
||||
"_nodeVersion": "8.7.0",
|
||||
"_npmUser": {
|
||||
|
||||
},
|
||||
"dist": {
|
||||
"integrity": "sha512-6gHiERpiDgtb3hjqpQH5\/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==",
|
||||
"shasum": "2c03764f651a9f016ca0b7620421457b619151b9",
|
||||
"tarball": "http:\/\/localhost:5555\/protected-pkg\/-\/protected-pkg-5.0.5.tgz"
|
||||
}
|
||||
}
|
||||
},
|
||||
"readme": "# test",
|
||||
"_attachments": {
|
||||
"protected-pkg-5.0.5.tgz": {
|
||||
"content_type": "application\/octet-stream",
|
||||
"data": "H4sIAAAAAAAAE+2W32vbMBDH85y\/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo\/\/79KPeQsnIw5KUDX\/9IOvurLuz\/DHSjK\/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF\/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI\/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS\/pLQe+D+FIv\/agIWI6GX66kFuIhT+1gDjrp\/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0\/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi\/IHpU9fz3\/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6\/f88f\/Pu47zomiPk2Lv\/dOv8h+P\/34\/D\/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=",
|
||||
"length": 512
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = json;
|
53
test/e2e/partials/pkg-scoped.js
Normal file
53
test/e2e/partials/pkg-scoped.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
const json = {
|
||||
"_id": "@scope\/pk1-test",
|
||||
"name": "@scope\/pk1-test",
|
||||
"description": "",
|
||||
"dist-tags": {
|
||||
"latest": "1.0.6"
|
||||
},
|
||||
"versions": {
|
||||
"1.0.6": {
|
||||
"name": "@scope\/pk1-test",
|
||||
"version": "1.0.6",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [
|
||||
|
||||
],
|
||||
"author": {
|
||||
"name": "Juan Picado",
|
||||
"email": "juan@jotadeveloper.com"
|
||||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"verdaccio": "^2.7.2"
|
||||
},
|
||||
"readme": "# test",
|
||||
"readmeFilename": "README.md",
|
||||
"_id": "@scope\/pk1-test@1.0.6",
|
||||
"_npmVersion": "5.5.1",
|
||||
"_nodeVersion": "8.7.0",
|
||||
"_npmUser": {
|
||||
|
||||
},
|
||||
"dist": {
|
||||
"integrity": "sha512-6gHiERpiDgtb3hjqpQH5\/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==",
|
||||
"shasum": "2c03764f651a9f016ca0b7620421457b619151b9",
|
||||
"tarball": "http:\/\/localhost:5555\/@scope\/pk1-test\/-\/@scope\/pk1-test-1.0.6.tgz"
|
||||
}
|
||||
}
|
||||
},
|
||||
"readme": "# test",
|
||||
"_attachments": {
|
||||
"@scope\/pk1-test-1.0.6.tgz": {
|
||||
"content_type": "application\/octet-stream",
|
||||
"data": "H4sIAAAAAAAAE+2W32vbMBDH85y\/QnjQp9qxLEeBMsbGlocNBmN7bFdQ5WuqxJaEpGQdo\/\/79KPeQsnIw5KUDX\/9IOvurLuz\/DHSjK\/YAiY6jcXSKjk6sMqypHWNdtmD6hlBI0wqQmo8nVbVqMR4OsNoVB66kF1aW8eML+Vv10m9oF\/jP6IfY4QyyTrILlD2eqkcm+gVzpdrJrPz4NuAsULJ4MZFWdBkbcByI7R79CRjx0ScCdnAvf+SkjUFWu8IubzBgXUhDPidQlfZ3BhlLpBUKDiQ1cDFrYDmKkNnZwjuhUM4808+xNVW8P2bMk1Y7vJrtLC1u1MmLPjBF40+Cc4ahV6GDmI\/DWygVRpMwVX3KtXUCg7Sxp7ff3nbt6TBFy65gK1iffsN41yoEHtdFbOiisWMH8bPvXUH0SP3k+KG3UBr+DFy7OGfEJr4x5iWVeS\/pLQe+D+FIv\/agIWI6GX66kFuIhT+1gDjrp\/4d7WAvAwEJPh0u14IufWkM0zaW2W6nLfM2lybgJ4LTJ0\/jWiAK8OcMjt8MW3OlfQppcuhhQ6k+2OgkK2Q8DssFPi\/IHpU9fz3\/+xj5NjDf8QFE39VmE4JDfzPCBn4P4X6\/f88f\/Pu47zomiPk2Lv\/dOv8h+P\/34\/D\/p9CL+Kp67mrGDRo0KBBp9ZPsETQegASAAA=",
|
||||
"length": 512
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = json;
|
|
@ -18,11 +18,17 @@ class PuppeteerEnvironment extends NodeEnvironment {
|
|||
|
||||
async setup() {
|
||||
const config1 = new VerdaccioConfig(path.join(__dirname, './store-e2e'),
|
||||
path.join(__dirname, './config-e2e.yaml'), 'http://0.0.0.0:55558/', 55558);
|
||||
path.join(__dirname, './config/config-scoped-e2e.yaml'), 'http://0.0.0.0:55558/', 55558);
|
||||
const config2 = new VerdaccioConfig(path.join(__dirname, './store-e2e'),
|
||||
path.join(__dirname, './config/config-protected-e2e.yaml'), 'http://0.0.0.0:55552/', 55552);
|
||||
const server1 = new Server.default(config1.domainPath);
|
||||
const server2 = new Server.default(config2.domainPath);
|
||||
const process1 = new VerdaccioProcess.default(config1, server1, false);
|
||||
const process2 = new VerdaccioProcess.default(config2, server2, false);
|
||||
const fork = await process1.init();
|
||||
const fork2 = await process2.init();
|
||||
this.global.__VERDACCIO_E2E__ = fork[0];
|
||||
this.global.__VERDACCIO__PROTECTED_E2E__ = fork2[0];
|
||||
|
||||
console.log(chalk.yellow('Setup Test Environment.'));
|
||||
await super.setup();
|
||||
|
@ -31,6 +37,7 @@ class PuppeteerEnvironment extends NodeEnvironment {
|
|||
throw new Error('wsEndpoint not found')
|
||||
}
|
||||
this.global.__SERVER__ = server1;
|
||||
this.global.__SERVER_PROTECTED__ = server2;
|
||||
this.global.__BROWSER__ = await puppeteer.connect({
|
||||
browserWSEndpoint: wsEndpoint,
|
||||
})
|
||||
|
@ -40,6 +47,7 @@ class PuppeteerEnvironment extends NodeEnvironment {
|
|||
console.log(chalk.yellow('Teardown Test Environment.'));
|
||||
await super.teardown();
|
||||
this.global.__VERDACCIO_E2E__.stop();
|
||||
this.global.__VERDACCIO__PROTECTED_E2E__.stop();
|
||||
}
|
||||
|
||||
runScript(script) {
|
||||
|
|
Loading…
Reference in a new issue