1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/test/functional/uplinks/cache.js
Juan Picado @jotadeveloper a68d247a44
feat: add support for jwt on api (#896)
* feat: add support for jwt on api

* test: add unit test for sign token with jwt

add multiple scenarios with configuration file

* chore: add JWT verification on middleware

* chore: restore headless

* chore: restore middleware header validation

* refactor: fix login whether user exists

* refactor: JWT is signed asynchronously

* refactor: better structure and new naming convention

* test: add unit test for token signature

* test: add unit test for creating user with JWT enabled

#168

* docs: add security section jwt

* refactor: renable  web auth middleware

* test(auth): add legacy disabled scenario

* chore: update gitignore

* chore: add some es6 sugar

* feat: enable JWT token signature for new installations

* chore: add yaml files to git

I forgot add this before 😷

* chore: trace log on auth

in case we want more output
2018-08-21 08:05:34 +02:00

93 lines
2.5 KiB
JavaScript

import fs from 'fs';
import path from 'path';
import assert from 'assert';
import {readFile} from '../lib/test.utils';
import {HTTP_STATUS} from "../../../src/lib/constants";
import {TARBALL} from '../config.functional';
import {createTarballHash} from '../../../src/lib/crypto-utils';
function getBinary() {
return readFile('../fixtures/binary');
}
const STORAGE = '../store/test-storage3';
const PKG_GH131 = 'pkg-gh131';
const PKG_GH1312 = 'pkg-gh1312';
function isCached(pkgName, tarballName) {
return fs.existsSync(path.join(__dirname, STORAGE, pkgName, tarballName));
}
export default function (server, server2, server3) {
describe('storage tarball cache test', () => {
//more info #131
beforeAll(function () {
return server.addPackage(PKG_GH131);
});
beforeAll(function () {
return server.putTarball(PKG_GH131, TARBALL, getBinary())
.status(HTTP_STATUS.CREATED)
.body_ok(/.*/);
});
beforeAll(function () {
const pkg = require('../fixtures/package')(PKG_GH131);
pkg.dist.shasum = createTarballHash().update(getBinary()).digest('hex');
return server.putVersion(PKG_GH131, '0.0.1', pkg)
.status(HTTP_STATUS.CREATED)
.body_ok(/published/);
});
beforeAll(function () {
return server3.getPackage(PKG_GH131).status(HTTP_STATUS.OK);
});
beforeAll(function () {
return server3.getTarball(PKG_GH131, TARBALL)
.status(HTTP_STATUS.OK);
});
test('should be caching packages from uplink server1', () => {
assert.equal(isCached(PKG_GH131, TARBALL), true);
});
beforeAll(function () {
return server2.addPackage(PKG_GH1312);
});
beforeAll(function () {
return server2.putTarball(PKG_GH1312, TARBALL, getBinary())
.status(HTTP_STATUS.CREATED)
.body_ok(/.*/);
});
beforeAll(function () {
const pkg = require('../fixtures/package')(PKG_GH1312);
pkg.dist.shasum = createTarballHash().update(getBinary()).digest('hex');
return server2.putVersion(PKG_GH1312, '0.0.1', pkg)
.status(HTTP_STATUS.CREATED)
.body_ok(/published/);
});
beforeAll(function () {
return server3.getPackage(PKG_GH1312)
.status(HTTP_STATUS.OK);
});
beforeAll(function () {
return server3.getTarball(PKG_GH1312, TARBALL)
.status(HTTP_STATUS.OK);
});
test('must not be caching packages from uplink server2', () => {
assert.equal(isCached(PKG_GH1312, TARBALL), false);
});
});
}