Experimental port to Firebase hosting

This commit is contained in:
Michael Jackson
2019-01-05 16:50:05 -08:00
parent e4d6df255e
commit 31e7d3865a
300 changed files with 129300 additions and 5817 deletions

View File

@ -0,0 +1,39 @@
import * as auth from '../auth';
describe('Auth API', () => {
beforeEach(done => {
auth.removeAllRevokedTokens().then(() => done(), done);
});
it('creates tokens with the right scopes', done => {
const scopes = {
blacklist: {
add: true,
remove: true
}
};
auth.createToken(scopes).then(token => {
auth.verifyToken(token).then(payload => {
expect(payload.jti).toEqual(expect.any(String));
expect(payload.iss).toEqual(expect.any(String));
expect(payload.iat).toEqual(expect.any(Number));
expect(payload.scopes).toMatchObject(scopes);
done();
});
});
});
it('refuses to verify revoked tokens', done => {
const scopes = {};
auth.createToken(scopes).then(token => {
auth.revokeToken(token).then(() => {
auth.verifyToken(token).then(payload => {
expect(payload).toBe(null);
done();
});
});
});
});
});

View File

@ -0,0 +1,24 @@
import * as blacklist from '../blacklist';
describe('Blacklist API', () => {
beforeEach(done => {
blacklist.removeAllPackages().then(() => done(), done);
});
it('adds and removes packages to/from the blacklist', done => {
const packageName = 'bad-package';
blacklist.addPackage(packageName).then(() => {
blacklist.getPackages().then(packageNames => {
expect(packageNames).toEqual([packageName]);
blacklist.removePackage(packageName).then(() => {
blacklist.getPackages().then(packageNames => {
expect(packageNames).toEqual([]);
done();
});
});
});
});
});
});

View File

@ -1,4 +1,4 @@
const createSearch = require('../createSearch');
import createSearch from '../createSearch';
describe('createSearch', () => {
it('omits the trailing = for empty string values', () => {

View File

@ -1,4 +1,4 @@
const getContentType = require('../getContentType');
import getContentType from '../getContentType';
it('gets a content type of text/plain for LICENSE|README|CHANGES|AUTHORS|Makefile', () => {
expect(getContentType('AUTHORS')).toBe('text/plain');

View File

@ -1,4 +1,4 @@
const parsePackageURL = require('../parsePackageURL');
import parsePackageURL from '../parsePackageURL';
describe('parsePackageURL', () => {
it('parses plain packages', () => {