mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-06 22:40:26 -05:00
Merge branch 'master' into issue-587
This commit is contained in:
commit
8d5a7f0c30
7 changed files with 720 additions and 473 deletions
|
@ -4,7 +4,7 @@ import HTTPError from 'http-errors';
|
|||
import type {Config} from '@verdaccio/types';
|
||||
import type {Router} from 'express';
|
||||
import type {IAuth, $ResponseExtend, $RequestExtend, $NextFunctionVer} from '../../../../types';
|
||||
import {combineBaseUrl, getWebProtocol} from '../../../lib/utils';
|
||||
// import {combineBaseUrl, getWebProtocol} from '../../../lib/utils';
|
||||
|
||||
function addUserAuthApi(route: Router, auth: IAuth, config: Config) {
|
||||
route.post('/login', function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
|
||||
|
@ -22,12 +22,13 @@ function addUserAuthApi(route: Router, auth: IAuth, config: Config) {
|
|||
});
|
||||
});
|
||||
|
||||
route.post('/-/logout', function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
|
||||
const base = combineBaseUrl(getWebProtocol(req), req.get('host'), config.url_prefix);
|
||||
// FIXME: this will be re-implemented
|
||||
// route.post('/-/logout', function(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer) {
|
||||
// const base = combineBaseUrl(getWebProtocol(req), req.get('host'), config.url_prefix);
|
||||
|
||||
res.cookies.set('token', '');
|
||||
res.redirect(base);
|
||||
});
|
||||
// res.cookies.set('token', '');
|
||||
// res.redirect(base);
|
||||
// });
|
||||
}
|
||||
|
||||
export default addUserAuthApi;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// @flow
|
||||
import {stringToMD5} from './string';
|
||||
|
||||
|
||||
export const GRAVATAR_DEFAULT = 'https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm';
|
||||
/**
|
||||
* Generate gravatar url from email address
|
||||
*/
|
||||
|
@ -11,6 +13,6 @@ export function generateGravatarUrl(email?: string): string {
|
|||
|
||||
return `https://www.gravatar.com/avatar/${emailMD5}`;
|
||||
} else {
|
||||
return 'https://www.gravatar.com/avatar/00000000000000000000000000000000?d=mm';
|
||||
return GRAVATAR_DEFAULT;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -14,7 +14,7 @@ const config = {
|
|||
|
||||
'forbidden-place': {
|
||||
allow_access: 'nobody',
|
||||
allow_publish: 'nobody'
|
||||
allow_publish: '$all'
|
||||
},
|
||||
|
||||
'react': {
|
||||
|
|
53
test/unit/partials/forbidden-place.js
Normal file
53
test/unit/partials/forbidden-place.js
Normal file
|
@ -0,0 +1,53 @@
|
|||
const json = {
|
||||
"_id": "forbidden-place",
|
||||
"name": "forbidden-place",
|
||||
"description": "",
|
||||
"dist-tags": {
|
||||
"latest": "1.0.6"
|
||||
},
|
||||
"versions": {
|
||||
"1.0.6": {
|
||||
"name": "forbidden-place",
|
||||
"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": "forbidden-place@1.0.6",
|
||||
"_npmVersion": "5.5.1",
|
||||
"_nodeVersion": "8.7.0",
|
||||
"_npmUser": {
|
||||
|
||||
},
|
||||
"dist": {
|
||||
"integrity": "sha512-6gHiERpiDgtb3hjqpQH5\/i7zRmvYi9pmCjQf2ZMy3QEa9wVk9RgdZaPWUt7ZOnWUPFjcr9cmE6dUBf+XoPoH4g==",
|
||||
"shasum": "2c03764f651a9f016ca0b7620421457b619151b9",
|
||||
"tarball": "http:\/\/localhost:5555\/forbidden-place\/-\/forbidden-place-1.0.6.tgz"
|
||||
}
|
||||
}
|
||||
},
|
||||
"readme": "# test",
|
||||
"_attachments": {
|
||||
"forbidden-place-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;
|
|
@ -1,10 +1,11 @@
|
|||
// @flow
|
||||
import _ from 'lodash';
|
||||
import ProxyStorage from '../../src/lib/up-storage';
|
||||
import AppConfig from '../../src/lib/config';
|
||||
import _ from 'lodash';
|
||||
// $FlowFixMe
|
||||
import configExample from './partials/config';
|
||||
import {setup} from '../../src/lib/logger';
|
||||
|
||||
import type {Config, UpLinkConf} from '@verdaccio/types';
|
||||
import type {IProxy} from '../../types';
|
||||
|
||||
|
|
|
@ -1,42 +1,78 @@
|
|||
let assert = require('assert');
|
||||
let validate = require('../../src/lib/utils').validate_name;
|
||||
// @flow
|
||||
|
||||
describe('Validate', () => {
|
||||
test('good ones', () => {
|
||||
assert( validate('verdaccio') );
|
||||
assert( validate('some.weird.package-zzz') );
|
||||
assert( validate('old-package@0.1.2.tgz') );
|
||||
import assert from 'assert';
|
||||
import {validate_name as validate} from '../../src/lib/utils';
|
||||
import {generateGravatarUrl, GRAVATAR_DEFAULT} from '../../src/utils/user';
|
||||
import {spliceURL} from '../../src/utils/string';
|
||||
|
||||
describe('Utilities', () => {
|
||||
|
||||
describe('String utilities', () => {
|
||||
test('should splice two strings and generate a url', () => {
|
||||
const url: string = spliceURL('http://domain.com', '/-/static/logo.png');
|
||||
|
||||
expect(url).toMatch('http://domain.com/-/static/logo.png');
|
||||
});
|
||||
|
||||
test('should splice a empty strings and generate a url', () => {
|
||||
const url: string = spliceURL('', '/-/static/logo.png');
|
||||
|
||||
expect(url).toMatch('/-/static/logo.png');
|
||||
});
|
||||
});
|
||||
|
||||
test('uppercase', () => {
|
||||
assert( validate('EVE') );
|
||||
assert( validate('JSONStream') );
|
||||
describe('User utilities', () => {
|
||||
test('should generate gravatar url with email', () => {
|
||||
const gravatarUrl: string = generateGravatarUrl('user@verdaccio.org');
|
||||
|
||||
expect(gravatarUrl).toMatch('https://www.gravatar.com/avatar/');
|
||||
expect(gravatarUrl).not.toMatch('000000000');
|
||||
});
|
||||
|
||||
test('should generate generic gravatar url', () => {
|
||||
const gravatarUrl: string = generateGravatarUrl();
|
||||
|
||||
expect(gravatarUrl).toMatch(GRAVATAR_DEFAULT);
|
||||
});
|
||||
});
|
||||
|
||||
test('no package.json', () => {
|
||||
assert( !validate('package.json') );
|
||||
});
|
||||
describe('Validations', () => {
|
||||
test('good ones', () => {
|
||||
assert( validate('verdaccio') );
|
||||
assert( validate('some.weird.package-zzz') );
|
||||
assert( validate('old-package@0.1.2.tgz') );
|
||||
});
|
||||
|
||||
test('no path seps', () => {
|
||||
assert( !validate('some/thing') );
|
||||
assert( !validate('some\\thing') );
|
||||
});
|
||||
test('uppercase', () => {
|
||||
assert( validate('EVE') );
|
||||
assert( validate('JSONStream') );
|
||||
});
|
||||
|
||||
test('no hidden', () => {
|
||||
assert( !validate('.bin') );
|
||||
});
|
||||
test('no package.json', () => {
|
||||
assert( !validate('package.json') );
|
||||
});
|
||||
|
||||
test('no reserved', () => {
|
||||
assert( !validate('favicon.ico') );
|
||||
assert( !validate('node_modules') );
|
||||
assert( !validate('__proto__') );
|
||||
});
|
||||
test('no path seps', () => {
|
||||
assert( !validate('some/thing') );
|
||||
assert( !validate('some\\thing') );
|
||||
});
|
||||
|
||||
test('other', () => {
|
||||
assert( !validate('pk g') );
|
||||
assert( !validate('pk\tg') );
|
||||
assert( !validate('pk%20g') );
|
||||
assert( !validate('pk+g') );
|
||||
assert( !validate('pk:g') );
|
||||
test('no hidden', () => {
|
||||
assert( !validate('.bin') );
|
||||
});
|
||||
|
||||
test('no reserved', () => {
|
||||
assert( !validate('favicon.ico') );
|
||||
assert( !validate('node_modules') );
|
||||
assert( !validate('__proto__') );
|
||||
});
|
||||
|
||||
test('other', () => {
|
||||
assert( !validate('pk g') );
|
||||
assert( !validate('pk\tg') );
|
||||
assert( !validate('pk%20g') );
|
||||
assert( !validate('pk+g') );
|
||||
assert( !validate('pk:g') );
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue