Merge remote-tracking branch 'origin/4.x' into feat-new-detail-page

This commit is contained in:
Juan Picado @jotadeveloper 2019-02-03 12:25:59 +01:00
commit d7eea01efc
No known key found for this signature in database
GPG Key ID: 18AC54485952D158
9 changed files with 2250 additions and 2289 deletions

View File

@ -1,68 +1,3 @@
{
"env": {
"ui": {
"presets": [
"@babel/react",
"@babel/flow",
["@babel/env",{
"targets": {
"browsers": [
"last 5 versions",
"FireFox >= 44",
"Safari >= 7",
"Explorer 11",
"last 4 Edge versions"
]
}
}]
],
"plugins": [
"react-hot-loader/babel",
"@babel/transform-runtime",
"@babel/proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"@babel/syntax-dynamic-import",
"emotion"
]
},
"test": {
"presets": [["@babel/env", {
"targets": {
"node": "6.10"
}
}], "@babel/flow",
"@babel/react"],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
"babel-plugin-dynamic-import-node",
"emotion"
]
},
"registry": {
"presets": [
["@babel/env", {
"targets": {
"node": "6.10"
}
}], "@babel/flow"],
"plugins": [
"@babel/plugin-proposal-object-rest-spread",
"@babel/proposal-class-properties"
]
},
"registry-docker": {
"presets": [
["@babel/env", {
"targets": {
"node": "10"
}
}],
"@babel/flow"],
"plugins": [
"@babel/plugin-proposal-object-rest-spread",
"@babel/proposal-class-properties"
]
}
}
"presets": [["@verdaccio", {"flow": true}]]
}

View File

@ -16,8 +16,8 @@
},
"dependencies": {
"@verdaccio/file-locking": "0.0.7",
"@verdaccio/local-storage": "1.2.0",
"@verdaccio/streams": "1.0.0",
"@verdaccio/local-storage": "2.0.0-beta.1",
"@verdaccio/streams": "2.0.0-beta.0",
"JSONStream": "1.3.4",
"async": "2.6.1",
"body-parser": "1.18.3",
@ -52,41 +52,13 @@
"verror": "1.10.0"
},
"devDependencies": {
"@babel/cli": "7.2.3",
"@babel/core": "7.2.2",
"@babel/node": "7.2.2",
"@babel/plugin-proposal-class-properties": "7.2.3",
"@babel/plugin-proposal-decorators": "7.2.3",
"@babel/plugin-proposal-export-namespace-from": "7.2.0",
"@babel/plugin-proposal-function-sent": "7.2.0",
"@babel/plugin-proposal-json-strings": "7.2.0",
"@babel/plugin-proposal-numeric-separator": "7.2.0",
"@babel/plugin-proposal-object-rest-spread": "7.2.0",
"@babel/plugin-proposal-throw-expressions": "7.2.0",
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/plugin-syntax-import-meta": "7.2.0",
"@babel/plugin-transform-async-to-generator": "7.2.0",
"@babel/plugin-transform-classes": "7.2.2",
"@babel/plugin-transform-runtime": "7.2.0",
"@babel/polyfill": "7.2.3",
"@babel/preset-env": "7.2.3",
"@babel/preset-flow": "7.0.0",
"@babel/preset-react": "7.0.0",
"@babel/register": "7.0.0",
"@babel/runtime": "^7.2.0",
"@commitlint/cli": "7.2.1",
"@commitlint/config-conventional": "7.1.2",
"@material-ui/core": "3.9.0",
"@material-ui/icons": "3.0.2",
"@verdaccio/babel-preset": "0.0.3",
"@verdaccio/types": "4.1.4",
"autosuggest-highlight": "3.1.1",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.0.1",
"babel-jest": "23.6.0",
"babel-loader": "8.0.4",
"babel-plugin-dynamic-import-node": "2.2.0",
"babel-plugin-emotion": "9.2.10",
"babel-plugin-flow-runtime": "0.17.0",
"bundlesize": "0.17.0",
"codecov": "3.1.0",
"cross-env": "5.2.0",
@ -154,7 +126,7 @@
"typeface-roboto": "0.0.54",
"url-loader": "1.1.1",
"verdaccio-auth-memory": "0.0.4",
"verdaccio-memory": "1.0.3",
"verdaccio-memory": "2.0.0-beta.0",
"webpack": "4.20.2",
"webpack-bundle-analyzer": "3.0.2",
"webpack-cli": "3.1.1",

View File

@ -9,7 +9,7 @@ import VError from 'verror';
import chalk from 'chalk';
import express from 'express';
import { combineBaseUrl, getWebProtocol, spliceURL } from '../../lib/utils';
import { combineBaseUrl, getWebProtocol } from '../../lib/utils';
import Search from '../../lib/search';
import { HEADERS, HTTP_STATUS, WEB_TITLE } from '../../lib/constants';
import { spliceURL } from '../../utils/string';

View File

@ -102,8 +102,10 @@ export const API_ERROR = {
CONFIG_BAD_FORMAT: 'config file must be an object',
BAD_USERNAME_PASSWORD: 'bad username/password, access denied',
NO_PACKAGE: 'no such package available',
PACKAGE_CANNOT_BE_ADDED: 'this package cannot be added',
BAD_DATA: 'bad data',
NOT_ALLOWED: 'not allowed to access package',
NOT_ALLOWED_PUBLISH: 'not allowed to publish package',
INTERNAL_SERVER_ERROR: 'internal server error',
UNKNOWN_ERROR: 'unknown error',
NOT_PACKAGE_UPLINK: 'package does not exist on uplink',

View File

@ -631,29 +631,6 @@ class LocalStorage implements IStorage {
});
}
_getCustomPackageLocalStorages() {
const storages = {};
// add custom storage if exist
if (this.config.storage) {
storages[this.config.storage] = true;
}
const { packages } = this.config;
if (packages) {
const listPackagesConf = Object.keys(packages);
listPackagesConf.map(pkg => {
if (packages[pkg].storage) {
storages[packages[pkg].storage] = true;
}
});
}
return storages;
}
/**
* Walks through each package and calls `on_package` on them.
* @param {*} onPackage

View File

@ -13,17 +13,17 @@ export default function(server) {
* Check whether the user is allowed to fetch packages
* @param auth {object} disable auth
* @param pkg {string} package name
* @param ok {boolean}
* @param status {boolean}
*/
function checkAccess(auth, pkg, ok) {
function checkAccess(auth, pkg, status) {
test(
`${(ok ? 'allows' : 'forbids')} access ${auth} to ${pkg}`, () => {
`${(status ? 'allows' : 'forbids')} access ${auth} to ${pkg}`, () => {
server.authstr = auth ? buildAccesToken(auth) : undefined;
const req = server.getPackage(pkg);
if (ok) {
if (status === HTTP_STATUS.NOT_FOUND) {
return req.status(HTTP_STATUS.NOT_FOUND).body_error(API_ERROR.NO_PACKAGE);
} else {
} else if (status === HTTP_STATUS.FORBIDDEN) {
return req.status(HTTP_STATUS.FORBIDDEN).body_error(API_ERROR.NOT_ALLOWED);
}
}
@ -34,16 +34,20 @@ export default function(server) {
* Check whether the user is allowed to publish packages
* @param auth {object} disable auth
* @param pkg {string} package name
* @param ok {boolean}
* @param status {boolean}
*/
function checkPublish(auth, pkg, ok) {
test(`${(ok ? 'allows' : 'forbids')} publish ${auth} to ${pkg}`, () => {
function checkPublish(auth, pkg, status) {
test(`${(status ? 'allows' : 'forbids')} publish ${auth} to ${pkg}`, () => {
server.authstr = auth ? buildAccesToken(auth) : undefined;
const req = server.putPackage(pkg, require('../fixtures/package')(pkg));
if (ok) {
return req.status(HTTP_STATUS.NOT_FOUND).body_error(/this package cannot be added/);
} else {
return req.status(HTTP_STATUS.FORBIDDEN).body_error(/not allowed to publish package/);
if (status === HTTP_STATUS.NOT_FOUND) {
return req.status(HTTP_STATUS.NOT_FOUND).body_error(API_ERROR.PACKAGE_CANNOT_BE_ADDED);
} else if (status === HTTP_STATUS.FORBIDDEN) {
return req.status(HTTP_STATUS.FORBIDDEN).body_error(API_ERROR.NOT_ALLOWED_PUBLISH);
} else if (status === HTTP_STATUS.CREATED) {
return req.status(HTTP_STATUS.CREATED);
} else if (status === HTTP_STATUS.CONFLICT) {
return req.status(HTTP_STATUS.CONFLICT);
}
});
}
@ -60,39 +64,39 @@ export default function(server) {
const testOnlyAuth = 'test-only-auth';
describe('all are allowed to access', () => {
checkAccess(validCredentials, testAccessOnly, true);
checkAccess(undefined, testAccessOnly, true);
checkAccess(badCredentials, testAccessOnly, true);
checkPublish(validCredentials, testAccessOnly, false);
checkPublish(undefined, testAccessOnly, false);
checkPublish(badCredentials, testAccessOnly, false);
checkAccess(validCredentials, testAccessOnly, HTTP_STATUS.NOT_FOUND);
checkAccess(undefined, testAccessOnly, HTTP_STATUS.NOT_FOUND);
checkAccess(badCredentials, testAccessOnly, HTTP_STATUS.NOT_FOUND);
checkPublish(validCredentials, testAccessOnly, HTTP_STATUS.FORBIDDEN);
checkPublish(undefined, testAccessOnly, HTTP_STATUS.FORBIDDEN);
checkPublish(badCredentials, testAccessOnly, HTTP_STATUS.FORBIDDEN);
});
describe('all are allowed to publish', () => {
checkAccess(validCredentials, testPublishOnly, false);
checkAccess(undefined, testPublishOnly, false);
checkAccess(badCredentials, testPublishOnly, false);
checkPublish(validCredentials, testPublishOnly, true);
checkPublish(undefined, testPublishOnly, true);
checkPublish(badCredentials, testPublishOnly, true);
checkAccess(validCredentials, testPublishOnly, HTTP_STATUS.FORBIDDEN);
checkAccess(undefined, testPublishOnly, HTTP_STATUS.FORBIDDEN);
checkAccess(badCredentials, testPublishOnly, HTTP_STATUS.FORBIDDEN);
checkPublish(validCredentials, testPublishOnly, HTTP_STATUS.CREATED);
checkPublish(undefined, testPublishOnly, HTTP_STATUS.CONFLICT);
checkPublish(badCredentials, testPublishOnly, HTTP_STATUS.CONFLICT);
});
describe('only user "test" is allowed to publish and access', () => {
checkAccess(validCredentials, testOnlyTest, true);
checkAccess(undefined, testOnlyTest, false);
checkAccess(badCredentials, testOnlyTest, false);
checkPublish(validCredentials, testOnlyTest, true);
checkPublish(undefined, testOnlyTest, false);
checkPublish(badCredentials, testOnlyTest, false);
checkAccess(validCredentials, testOnlyTest, HTTP_STATUS.NOT_FOUND);
checkAccess(undefined, testOnlyTest, HTTP_STATUS.FORBIDDEN);
checkAccess(badCredentials, testOnlyTest, HTTP_STATUS.FORBIDDEN);
checkPublish(validCredentials, testOnlyTest, HTTP_STATUS.CREATED);
checkPublish(undefined, testOnlyTest, HTTP_STATUS.FORBIDDEN);
checkPublish(badCredentials, testOnlyTest, HTTP_STATUS.FORBIDDEN);
});
describe('only authenticated users are allowed', () => {
checkAccess(validCredentials, testOnlyAuth, true);
checkAccess(undefined, testOnlyAuth, false);
checkAccess(badCredentials, testOnlyAuth, false);
checkPublish(validCredentials, testOnlyAuth, true);
checkPublish(undefined, testOnlyAuth, false);
checkPublish(badCredentials, testOnlyAuth, false);
checkAccess(validCredentials, testOnlyAuth, HTTP_STATUS.NOT_FOUND);
checkAccess(undefined, testOnlyAuth, HTTP_STATUS.FORBIDDEN);
checkAccess(badCredentials, testOnlyAuth, HTTP_STATUS.FORBIDDEN);
checkPublish(validCredentials, testOnlyAuth, HTTP_STATUS.CREATED);
checkPublish(undefined, testOnlyAuth, HTTP_STATUS.FORBIDDEN);
checkPublish(badCredentials, testOnlyAuth, HTTP_STATUS.FORBIDDEN);
});
});
}

View File

@ -13,6 +13,7 @@ export default function (server, server2) {
const PKG_NAME = 'test-nullstorage2';
const PKG_VERSION = '0.0.1';
// const TARBALL = `${PKG_NAME}-file.name`;
describe('should test a scenario when tarball is being fetch from uplink', () => {
@ -38,8 +39,7 @@ export default function (server, server2) {
describe(`should succesfully publish ${PKG_NAME} package on server2`, () => {
beforeAll(function() {
return server2.putTarball(PKG_NAME, TARBALL, getBinary())
.status(HTTP_STATUS.CREATED).body_ok(/.*/);
return server2.putTarball(PKG_NAME, TARBALL, getBinary()).status(HTTP_STATUS.CREATED).body_ok(/.*/);
});
beforeAll(function() {

View File

@ -19,6 +19,7 @@ uplinks:
timeout: 100ms
server2:
url: http://localhost:55552/
maxage: 0
server3:
url: http://localhost:55553/
baduplink:
@ -88,7 +89,7 @@ packages:
access: $all
publish: $all
proxy: server2
storage: false
storage: sub_storage
'baduplink':
access: $all
@ -98,22 +99,22 @@ packages:
'test-access-only':
access: $all
publish: nobody
storage: false
storage: sub_storage
'test-publish-only':
access: nobody
publish: $all
storage: false
storage: sub_storage
'test-only-test':
access: test
publish: test
storage: false
storage: sub_storage
'test-only-auth':
access: $authenticated
publish: $authenticated
storage: false
storage: sub_storage
'*':
access: test $anonymous

4318
yarn.lock

File diff suppressed because it is too large Load Diff