mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-23 22:27:34 -05:00
dbf20175dc
* feat: support for npm token This is an effor of: This commit intent to provide npm token support. https: //github.com/verdaccio/verdaccio/issues/541 https: //github.com/verdaccio/verdaccio/pull/1271 https: //github.com/verdaccio/local-storage/pull/168 Co-Authored-By: Manuel Spigolon <behemoth89@gmail.com> Co-Authored-By: Juan Gabriel Jiménez <juangabreil@gmail.com> * chore: update secrets baselines Co-Authored-By: Liran Tal <liran.tal@gmail.com> * chore: update lock file * chore: add logger mock methods * chore: update @verdaccio/types * refactor: unit test was flacky adapt the pkg access to the new configuration setup * refactor: add plugin methods validation * test: add test for aesEncrypt * chore: update local-storage dependency * chore: add support for experimetns token will be part of the experiment lists * chore: increase timeout * chore: increase timeout threshold * chore: update nock * chore: update dependencies * chore: update eslint config * chore: update dependencies * test: add unit test for npm token * chore: update readme
114 lines
2.8 KiB
TypeScript
114 lines
2.8 KiB
TypeScript
import request from 'supertest';
|
|
import path from 'path';
|
|
import rimraf from 'rimraf';
|
|
|
|
import { setup } from '../../../../src/lib/logger';
|
|
|
|
setup([]);
|
|
|
|
import { HEADERS, HTTP_STATUS } from '../../../../src/lib/constants';
|
|
import configDefault from '../../partials/config';
|
|
import endPointAPI from '../../../../src/api';
|
|
import {mockServer} from '../../__helper/mock';
|
|
import {DOMAIN_SERVERS} from '../../../functional/config.functional';
|
|
|
|
require('../../../../src/lib/logger').setup([]);
|
|
|
|
describe('api with no limited access configuration', () => {
|
|
let app;
|
|
let mockRegistry;
|
|
const store = path.join(__dirname, '../../partials/store/access-storage');
|
|
jest.setTimeout(10000);
|
|
|
|
beforeAll(function(done) {
|
|
const mockServerPort = 55530;
|
|
|
|
rimraf(store, async () => {
|
|
const configForTest = configDefault({
|
|
auth: {
|
|
htpasswd: {
|
|
file: './access-storage/htpasswd-pkg-access'
|
|
}
|
|
},
|
|
self_path: store,
|
|
uplinks: {
|
|
remote: {
|
|
url: `http://${DOMAIN_SERVERS}:${mockServerPort}`
|
|
}
|
|
},
|
|
logs: [
|
|
{ type: 'stdout', format: 'pretty', level: 'warn' }
|
|
]
|
|
}, 'pkg.access.spec.yaml');
|
|
|
|
app = await endPointAPI(configForTest);
|
|
mockRegistry = await mockServer(mockServerPort).init();
|
|
done();
|
|
});
|
|
});
|
|
|
|
afterAll(function(done) {
|
|
rimraf(store, (err) => {
|
|
if (err) {
|
|
mockRegistry[0].stop();
|
|
return done(err);
|
|
}
|
|
|
|
mockRegistry[0].stop();
|
|
return done();
|
|
});
|
|
});
|
|
|
|
describe('test proxy packages partially restricted', () => {
|
|
|
|
|
|
test('should test fails on fetch endpoint /-/not-found', (done) => {
|
|
request(app)
|
|
// @ts-ignore
|
|
.get('/not-found-for-sure')
|
|
.set(HEADERS.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
.expect(HEADERS.CONTENT_TYPE, /json/)
|
|
.expect(HTTP_STATUS.NOT_FOUND)
|
|
.end(function(err) {
|
|
if (err) {
|
|
return done(err);
|
|
}
|
|
|
|
done();
|
|
});
|
|
});
|
|
|
|
test('should test fetch endpoint /-/jquery', (done) => {
|
|
request(app)
|
|
// @ts-ignore
|
|
.get('/jquery')
|
|
.set(HEADERS.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
.expect(HEADERS.CONTENT_TYPE, /json/)
|
|
.expect(HTTP_STATUS.OK)
|
|
.end(function(err) {
|
|
if (err) {
|
|
return done(err);
|
|
}
|
|
|
|
done();
|
|
});
|
|
});
|
|
|
|
test('should success on fetch endpoint /-/vue', (done) => {
|
|
request(app)
|
|
// @ts-ignore
|
|
.get('/vue')
|
|
.set(HEADERS.CONTENT_TYPE, HEADERS.JSON_CHARSET)
|
|
.expect(HEADERS.CONTENT_TYPE, /json/)
|
|
.expect(HTTP_STATUS.OK)
|
|
.end(function(err, res) {
|
|
if (err) {
|
|
return done(err);
|
|
}
|
|
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|
|
});
|