-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tsconfig deep alias path corrections, auth0 authorizer test initial t…
…est case
- Loading branch information
1 parent
8928084
commit b509549
Showing
9 changed files
with
74 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
|
||
const sinon = require('sinon'); | ||
|
||
// import { authorize, decodeToken } from '@authorizers/auth0'; | ||
import { expect } from 'chai'; | ||
// import { SigningKeyNotFoundError } from 'jwks-rsa'; | ||
import * as jwt from 'jsonwebtoken'; | ||
|
||
import { decodeToken } from '@authorizers/auth0'; | ||
import { Responses as lang } from '@i18n/authorizer'; | ||
|
||
describe('auth0-authorizer', () => { | ||
describe('decode', () => { | ||
const sandbox = sinon.createSandbox(); | ||
|
||
afterEach(function () { | ||
sandbox.restore(); | ||
}); | ||
|
||
it('should return error', () => { | ||
sandbox.stub(jwt, 'decode').throws(new Error()); | ||
const callback = sinon.spy(); | ||
|
||
decodeToken('token', callback); | ||
expect(callback.getCall(0).args).to.include(lang.ERROR); | ||
}); | ||
|
||
it('should execute callback function', () => { | ||
sandbox.stub(jwt, 'decode').returns(false); | ||
const callback = sinon.spy(); | ||
|
||
decodeToken('token', callback); | ||
expect(callback.getCall(0).args).to.include(lang.UNAUTHORIZED); | ||
}); | ||
|
||
it('should return successfully', () => { | ||
sandbox.stub(jwt, 'decode').returns(true); | ||
const callback = sinon.spy(); | ||
|
||
const ctx = decodeToken('token', callback); | ||
expect(ctx).to.be.true; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum Responses { | ||
ERROR = 'Error: Invalid token', | ||
UNAUTHORIZED = 'Unauthorized' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters