build(aio): upgrade preview server dependencies
This commit is contained in:
parent
3ce9d51a9c
commit
1b13bdea4b
|
@ -63,7 +63,7 @@ export class GithubApi {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getPaginated(pathname, baseParams, currentPage + 1).then(moreItems => [...items, ...moreItems]);
|
return this.getPaginated<T>(pathname, baseParams, currentPage + 1).then(moreItems => [...items, ...moreItems]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ export class BuildVerifier {
|
||||||
|
|
||||||
protected verifyJwt(expectedPr: number, token: string): Promise<JwtPayload> {
|
protected verifyJwt(expectedPr: number, token: string): Promise<JwtPayload> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
jwt.verify(token, this.secret, {issuer: 'Travis CI, GmbH'}, (err, payload) => {
|
jwt.verify(token, this.secret, {issuer: 'Travis CI, GmbH'}, (err, payload: JwtPayload) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
reject(err.message || err);
|
reject(err.message || err);
|
||||||
} else if (payload.slug !== this.repoSlug) {
|
} else if (payload.slug !== this.repoSlug) {
|
||||||
|
|
|
@ -41,7 +41,7 @@ class UploadServerFactory {
|
||||||
const buildCreator = this.createBuildCreator(buildsDir, githubToken, repoSlug, domainName);
|
const buildCreator = this.createBuildCreator(buildsDir, githubToken, repoSlug, domainName);
|
||||||
|
|
||||||
const middleware = this.createMiddleware(buildVerifier, buildCreator);
|
const middleware = this.createMiddleware(buildVerifier, buildCreator);
|
||||||
const httpServer = http.createServer(middleware);
|
const httpServer = http.createServer(middleware as any);
|
||||||
|
|
||||||
httpServer.on('listening', () => {
|
httpServer.on('listening', () => {
|
||||||
const info = httpServer.address();
|
const info = httpServer.address();
|
||||||
|
@ -80,13 +80,13 @@ class UploadServerFactory {
|
||||||
this.throwRequestError(401, `Missing or empty '${AUTHORIZATION_HEADER}' header`, req);
|
this.throwRequestError(401, `Missing or empty '${AUTHORIZATION_HEADER}' header`, req);
|
||||||
} else if (!archive) {
|
} else if (!archive) {
|
||||||
this.throwRequestError(400, `Missing or empty '${X_FILE_HEADER}' header`, req);
|
this.throwRequestError(400, `Missing or empty '${X_FILE_HEADER}' header`, req);
|
||||||
|
} else {
|
||||||
|
buildVerifier.
|
||||||
|
verify(+pr, authHeader).
|
||||||
|
then(() => buildCreator.create(pr, sha, archive)).
|
||||||
|
then(() => res.sendStatus(201)).
|
||||||
|
catch(err => this.respondWithError(res, err));
|
||||||
}
|
}
|
||||||
|
|
||||||
buildVerifier.
|
|
||||||
verify(+pr, authHeader).
|
|
||||||
then(() => buildCreator.create(pr, sha, archive)).
|
|
||||||
then(() => res.sendStatus(201)).
|
|
||||||
catch(err => this.respondWithError(res, err));
|
|
||||||
});
|
});
|
||||||
middleware.get(/^\/health-check\/?$/, (_req, res) => res.sendStatus(200));
|
middleware.get(/^\/health-check\/?$/, (_req, res) => res.sendStatus(200));
|
||||||
middleware.get('*', req => this.throwRequestError(404, 'Unknown resource', req));
|
middleware.get('*', req => this.throwRequestError(404, 'Unknown resource', req));
|
||||||
|
|
|
@ -114,7 +114,7 @@ describe('BuildCleaner', () => {
|
||||||
|
|
||||||
it('should resolve with the value returned by \'removeUnnecessaryBuilds()\'', done => {
|
it('should resolve with the value returned by \'removeUnnecessaryBuilds()\'', done => {
|
||||||
promise.then(result => {
|
promise.then(result => {
|
||||||
expect(result).toBe('Test');
|
expect(result as any).toBe('Test');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -292,7 +292,7 @@ describe('GithubApi', () => {
|
||||||
|
|
||||||
|
|
||||||
describe('onResponse', () => {
|
describe('onResponse', () => {
|
||||||
let promise: Promise<void>;
|
let promise: Promise<Object>;
|
||||||
let respond: (statusCode: number) => IncomingMessage;
|
let respond: (statusCode: number) => IncomingMessage;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
|
@ -66,7 +66,7 @@ describe('GithubPullRequests', () => {
|
||||||
|
|
||||||
it('should resolve with the returned response', done => {
|
it('should resolve with the returned response', done => {
|
||||||
prs.addComment(42, 'body').then(data => {
|
prs.addComment(42, 'body').then(data => {
|
||||||
expect(data).toEqual('Test');
|
expect(data as any).toBe('Test');
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ describe('GithubPullRequests', () => {
|
||||||
|
|
||||||
it('should forward the value returned by \'getPaginated()\'', () => {
|
it('should forward the value returned by \'getPaginated()\'', () => {
|
||||||
prsGetPaginatedSpy.and.returnValue('Test');
|
prsGetPaginatedSpy.and.returnValue('Test');
|
||||||
expect(prs.fetchAll()).toBe('Test');
|
expect(prs.fetchAll() as any).toBe('Test');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,7 +38,7 @@ describe('GithubTeams', () => {
|
||||||
|
|
||||||
it('should forward the value returned by \'getPaginated()\'', () => {
|
it('should forward the value returned by \'getPaginated()\'', () => {
|
||||||
teamsGetPaginatedSpy.and.returnValue('Test');
|
teamsGetPaginatedSpy.and.returnValue('Test');
|
||||||
expect(teams.fetchAll()).toBe('Test');
|
expect(teams.fetchAll() as any).toBe('Test');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -50,12 +50,16 @@ describe('GithubTeams', () => {
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
teams = new GithubTeams('12345', 'foo');
|
teams = new GithubTeams('12345', 'foo');
|
||||||
teamsGetSpy = spyOn(teams, 'get');
|
teamsGetSpy = spyOn(teams, 'get').and.returnValue(Promise.resolve(null));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return a promise', () => {
|
it('should return a promise', done => {
|
||||||
expect(teams.isMemberById('user', [1])).toEqual(jasmine.any(Promise));
|
const promise = teams.isMemberById('user', [1]);
|
||||||
|
promise.then(done); // Do not complete the test (and release the spies) synchronously
|
||||||
|
// to avoid running the actual `get()`.
|
||||||
|
|
||||||
|
expect(promise).toEqual(jasmine.any(Promise));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -69,7 +73,6 @@ describe('GithubTeams', () => {
|
||||||
|
|
||||||
|
|
||||||
it('should call \'get()\' with the correct pathname', done => {
|
it('should call \'get()\' with the correct pathname', done => {
|
||||||
teamsGetSpy.and.returnValue(Promise.resolve(null));
|
|
||||||
teams.isMemberById('user', [1]).then(() => {
|
teams.isMemberById('user', [1]).then(() => {
|
||||||
expect(teamsGetSpy).toHaveBeenCalledWith('/teams/1/memberships/user');
|
expect(teamsGetSpy).toHaveBeenCalledWith('/teams/1/memberships/user');
|
||||||
done();
|
done();
|
||||||
|
|
|
@ -18,7 +18,7 @@ describe('BuildVerifier', () => {
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
const createBuildVerifier = (partialConfig: Partial<typeof defaultConfig> = {}) => {
|
const createBuildVerifier = (partialConfig: Partial<typeof defaultConfig> = {}) => {
|
||||||
const cfg = {...defaultConfig, ...partialConfig};
|
const cfg = {...defaultConfig, ...partialConfig} as typeof defaultConfig;
|
||||||
return new BuildVerifier(cfg.secret, cfg.githubToken, cfg.repoSlug, cfg.organization,
|
return new BuildVerifier(cfg.secret, cfg.githubToken, cfg.repoSlug, cfg.organization,
|
||||||
cfg.allowedTeamSlugs);
|
cfg.allowedTeamSlugs);
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,7 +22,7 @@ describe('uploadServerFactory', () => {
|
||||||
|
|
||||||
// Helpers
|
// Helpers
|
||||||
const createUploadServer = (partialConfig: Partial<typeof defaultConfig> = {}) =>
|
const createUploadServer = (partialConfig: Partial<typeof defaultConfig> = {}) =>
|
||||||
usf.create({...defaultConfig, ...partialConfig});
|
usf.create({...defaultConfig, ...partialConfig} as typeof defaultConfig);
|
||||||
|
|
||||||
|
|
||||||
describe('create()', () => {
|
describe('create()', () => {
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue