Skip to content

Commit

Permalink
added oauth tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengill committed May 21, 2020
1 parent e8bd599 commit ebd5e11
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
41 changes: 37 additions & 4 deletions src/App.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,28 +66,61 @@ describe('App', () => {
assert(authorizeCallback.notCalled, 'Should not call the authorize callback on instantiation');
assert.instanceOf(app, App);
});
it('should fail without a token for single team authorization or authorize callback', async () => {
it('should fail without a token for single team authorization or authorize callback or oauth installer',
async () => {
// Arrange
const App = await importApp(); // tslint:disable-line:variable-name

// Act
try {
new App({ signingSecret: '' }); // tslint:disable-line:no-unused-expression
assert.fail();
} catch (error) {
// Assert
assert.propertyVal(error, 'code', ErrorCode.AppInitializationError);
}
});
it('should fail when both a token and authorize callback are specified', async () => {
// Arrange
const authorizeCallback = sinon.fake();
const App = await importApp(); // tslint:disable-line:variable-name

// Act
try {
new App({ signingSecret: '' }); // tslint:disable-line:no-unused-expression
// tslint:disable-next-line:no-unused-expression
new App({ token: '', authorize: authorizeCallback, signingSecret: '' });
assert.fail();
} catch (error) {
// Assert
assert.propertyVal(error, 'code', ErrorCode.AppInitializationError);
assert(authorizeCallback.notCalled);
}
});
it('should fail when both a token and authorize callback are specified', async () => {
it('should fail when both a token is specified and OAuthInstaller is initialized', async () => {
// Arrange
const authorizeCallback = sinon.fake();
const App = await importApp(); // tslint:disable-line:variable-name

// Act
try {
// tslint:disable-next-line:no-unused-expression
new App({ token: '', authorize: authorizeCallback, signingSecret: '' });
new App({ token: '', clientId: '', clientSecret: '', stateSecret: '', signingSecret: '' });
assert.fail();
} catch (error) {
// Assert
assert.propertyVal(error, 'code', ErrorCode.AppInitializationError);
assert(authorizeCallback.notCalled);
}
});
it('should fail when both a authorize callback is specified and OAuthInstaller is initialized', async () => {
// Arrange
const authorizeCallback = sinon.fake();
const App = await importApp(); // tslint:disable-line:variable-name

// Act
try {
// tslint:disable-next-line:no-unused-expression
new App({ authorize: authorizeCallback, clientId: '', clientSecret: '', stateSecret: '', signingSecret: '' });
assert.fail();
} catch (error) {
// Assert
Expand Down
7 changes: 7 additions & 0 deletions src/ExpressReceiver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ describe('ExpressReceiver', () => {
logger: noopLogger,
endpoints: { events: '/custom-endpoint' },
processBeforeResponse: true,
clientId: 'my-clientId',
clientSecret: 'my-client-secret',
stateSecret: 'state-secret',
scopes: ['channels:read'],
installerOptions: {
authVersion: 'v2',
},
});
assert.isNotNull(receiver);
});
Expand Down

0 comments on commit ebd5e11

Please sign in to comment.