Experimental port to Firebase hosting
This commit is contained in:
39
modules/utils/__tests__/auth-test.js
Normal file
39
modules/utils/__tests__/auth-test.js
Normal 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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
24
modules/utils/__tests__/blacklist-test.js
Normal file
24
modules/utils/__tests__/blacklist-test.js
Normal 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();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,4 +1,4 @@
|
||||
const createSearch = require('../createSearch');
|
||||
import createSearch from '../createSearch';
|
||||
|
||||
describe('createSearch', () => {
|
||||
it('omits the trailing = for empty string values', () => {
|
||||
|
@ -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');
|
||||
|
@ -1,4 +1,4 @@
|
||||
const parsePackageURL = require('../parsePackageURL');
|
||||
import parsePackageURL from '../parsePackageURL';
|
||||
|
||||
describe('parsePackageURL', () => {
|
||||
it('parses plain packages', () => {
|
||||
|
Reference in New Issue
Block a user