Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature/auth : added a back link to the strategy name in the token (future use for instance refreshToken) #571

Merged
merged 31 commits into from
Jul 23, 2018
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
cef7a1d
Added password grant_type option
alain-charles Jun 29, 2018
9f0dbab
Added password grant_type option implementation
alain-charles Jun 29, 2018
44d7d2e
Playground sample for oAuth2 password grant-type
alain-charles Jun 29, 2018
f57b737
Added route to oAuth2 password grant-type sample
alain-charles Jun 29, 2018
ed4628e
Addes angular-jwt for decoding jwt token (used in playground only)
alain-charles Jun 29, 2018
d7f01df
Added /api/auth/token endpoint (oAuth2 password grant-type playground)
alain-charles Jun 29, 2018
af52e88
Patched code for passing ci
alain-charles Jun 29, 2018
554f7dc
code optimization for passing ci
alain-charles Jun 29, 2018
fa0548f
Merge branch 'master' into master
nnixaa Jun 29, 2018
b72adae
Changes request by Dmitry (first review)
alain-charles Jun 29, 2018
733efc0
Generalized code in oauth2-strategy
alain-charles Jun 29, 2018
57fab69
Merge remote-tracking branch 'origin/master'
alain-charles Jun 29, 2018
c50df3a
Generalized code in oauth2-strategy
alain-charles Jun 29, 2018
dda5436
Added unit tests for oAuth-strategy password authentication
alain-charles Jul 2, 2018
ef0be25
Merge branch 'master' into master
alain-charles Jul 3, 2018
e180dc3
Merge branch 'master' into master
nnixaa Jul 4, 2018
6aa1fdb
Cleaned code according to nnixaa second review
alain-charles Jul 4, 2018
96c7344
Merge branch 'master' of https://github.com/alain-charles/nebular
alain-charles Jul 4, 2018
cf82c42
Removed package-lock.json from git repo
alain-charles Jul 4, 2018
dcff930
package-lock.json to revert
alain-charles Jul 4, 2018
315662f
reverted package-lock.json
alain-charles Jul 4, 2018
57a0230
Added new grant_type 'PASSWORD' in the block comment for it to be ins…
alain-charles Jul 4, 2018
d69d633
Merge remote-tracking branch 'upstream/master'
alain-charles Jul 5, 2018
1be8d91
Add the refreshtoken request management in NbJwtInterceptor and NbAut…
alain-charles Jul 13, 2018
4b67825
Merge branch 'master' of https://github.com/alain-charles/nebular
alain-charles Jul 19, 2018
deea3e2
Merge branch 'master' into temp
alain-charles Jul 19, 2018
acd0241
The token now contains ownerStrategyName, with is a back link to the …
alain-charles Jul 19, 2018
25250f0
feature/auth:
alain-charles Jul 19, 2018
c0fdd31
feature/auth:
alain-charles Jul 19, 2018
bd564b3
feature/auth:
alain-charles Jul 20, 2018
44ed61a
Merge branch 'master' into master
nnixaa Jul 20, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/framework/auth/services/auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ describe('auth-service', () => {
let tokenService: NbTokenService;
let dummyAuthStrategy: NbDummyAuthStrategy;
const testTokenValue = 'test-token';
const ownerStrategyName = 'strategy';


const resp401 = new HttpResponse<Object>({body: {}, status: 401});
const resp200 = new HttpResponse<Object>({body: {}, status: 200});

const testToken = nbAuthCreateToken(NbAuthSimpleToken, testTokenValue);
const emptyToken = nbAuthCreateToken(NbAuthSimpleToken, null);
const testToken = nbAuthCreateToken(NbAuthSimpleToken, testTokenValue, ownerStrategyName);
const emptyToken = nbAuthCreateToken(NbAuthSimpleToken, null, ownerStrategyName);

const failResult = new NbAuthResult(false,
resp401,
Expand Down
14 changes: 8 additions & 6 deletions src/framework/auth/services/token/token-parceler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import { NB_AUTH_TOKENS } from '../../auth.options';
describe('token-parceler', () => {

let tokenParceler: NbAuthTokenParceler;
const simpleToken = nbAuthCreateToken(NbAuthSimpleToken, 'test value');
const wrappedSimple = `{"name":"${NbAuthSimpleToken.NAME}","value":"${simpleToken.getValue()}"}`;
const simpleToken = nbAuthCreateToken(NbAuthSimpleToken, 'test value', 'strategy');
// tslint:disable-next-line
const jwtToken = nbAuthCreateToken(NbAuthJWTToken, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJleHAiOjI1MTczMTQwNjYxNzUsIm5hbWUiOiJDaHJpcyBTZXZpbGxlamEiLCJhZG1pbiI6dHJ1ZX0=.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773');
const wrappedJWT = `{"name":"${NbAuthJWTToken.NAME}","value":"${jwtToken.getValue()}"}`;

const wrappedNonExisting = `{"name":"non-existing","value":"${simpleToken.getValue()}"}`;
const wrappedSimple = `{"name":"${NbAuthSimpleToken.NAME}","ownerStrategyName":"${simpleToken.getOwnerStrategyName()}","value":"${simpleToken.getValue()}"}`;
// tslint:disable-next-line
const jwtToken = nbAuthCreateToken(NbAuthJWTToken, 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJleHAiOjI1MTczMTQwNjYxNzUsIm5hbWUiOiJDaHJpcyBTZXZpbGxlamEiLCJhZG1pbiI6dHJ1ZX0=.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773', 'strategy');
// tslint:disable-next-line
const wrappedJWT = `{"name":"${NbAuthJWTToken.NAME}","ownerStrategyName":"${jwtToken.getOwnerStrategyName()}","value":"${jwtToken.getValue()}"}`;
// tslint:disable-next-line
const wrappedNonExisting = `{"name":"non-existing","value":"${simpleToken.getValue()}","ownerStrategyName":"${simpleToken.getOwnerStrategyName()}"}`;
const wrappedInvalid = `{"name":"non-existing"`;

describe('default configuration', () => {
Expand Down
7 changes: 5 additions & 2 deletions src/framework/auth/services/token/token-parceler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { NB_AUTH_TOKENS } from '../../auth.options';

export interface NbTokenPack {
name: string,
ownerStrategyName: string,
value: string,
}

Expand All @@ -23,21 +24,23 @@ export class NbAuthTokenParceler {
wrap(token: NbAuthToken): string {
return JSON.stringify({
name: token.getName(),
ownerStrategyName: token.getOwnerStrategyName(),
value: token.toString(),
});
}

unwrap(value: string): NbAuthToken {
let tokenClass: NbAuthTokenClass = this.fallbackClass;
let tokenValue = '';

let tokenOwnerStrategyName = '';
const tokenPack: NbTokenPack = this.parseTokenPack(value);
if (tokenPack) {
tokenClass = this.getClassByName(tokenPack.name) || this.fallbackClass;
tokenValue = tokenPack.value;
tokenOwnerStrategyName = tokenPack.ownerStrategyName;
}

return nbAuthCreateToken(tokenClass, tokenValue);
return nbAuthCreateToken(tokenClass, tokenValue, tokenOwnerStrategyName);
}

// TODO: this could be moved to a separate token registry
Expand Down
5 changes: 3 additions & 2 deletions src/framework/auth/services/token/token-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@ import { NB_AUTH_FALLBACK_TOKEN, NbAuthTokenParceler } from './token-parceler';
import { NB_AUTH_TOKENS } from '../../auth.options';

const noop = () => {};
const ownerStrategyName = 'strategy';

describe('token-service', () => {

let tokenService: NbTokenService;
let tokenStorage: NbTokenLocalStorage;
const simpleToken = nbAuthCreateToken(NbAuthSimpleToken, 'test value');
const emptyToken = nbAuthCreateToken(NbAuthSimpleToken, '');
const simpleToken = nbAuthCreateToken(NbAuthSimpleToken, 'test value', ownerStrategyName);
const emptyToken = nbAuthCreateToken(NbAuthSimpleToken, '', ownerStrategyName);
const testTokenKey = 'auth_app_token';

beforeEach(() => {
Expand Down
13 changes: 7 additions & 6 deletions src/framework/auth/services/token/token-storage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('token-storage', () => {
let tokenParceler: NbAuthTokenParceler;
const testTokenKey = 'auth_app_token';
const testTokenValue = 'test-token';
const ownerStrategyName = 'strategy';

beforeEach(() => {
TestBed.configureTestingModule({
Expand All @@ -44,7 +45,7 @@ describe('token-storage', () => {


it('set test token', () => {
const token = nbAuthCreateToken(NbAuthSimpleToken, testTokenValue);
const token = nbAuthCreateToken(NbAuthSimpleToken, testTokenValue, ownerStrategyName);

tokenStorage.set(token);
expect(localStorage.getItem(testTokenKey)).toEqual(tokenParceler.wrap(token));
Expand All @@ -53,11 +54,11 @@ describe('token-storage', () => {
it('setter set invalid token to localStorage as empty string', () => {
let token;

token = nbAuthCreateToken(NbAuthSimpleToken, null);
token = nbAuthCreateToken(NbAuthSimpleToken, null, ownerStrategyName);
tokenStorage.set(token);
expect(localStorage.getItem(testTokenKey)).toEqual(tokenParceler.wrap(token));

token = nbAuthCreateToken(NbAuthSimpleToken, undefined);
token = nbAuthCreateToken(NbAuthSimpleToken, undefined, ownerStrategyName);
tokenStorage.set(token);
expect(localStorage.getItem(testTokenKey)).toEqual(tokenParceler.wrap(token));
});
Expand All @@ -69,14 +70,14 @@ describe('token-storage', () => {
});

it('should return correct value', () => {
const token = nbAuthCreateToken(NbAuthSimpleToken, 'test');
const token = nbAuthCreateToken(NbAuthSimpleToken, 'test', ownerStrategyName);
localStorage.setItem(testTokenKey, tokenParceler.wrap(token));

expect(tokenStorage.get().getValue()).toEqual(token.getValue());
});

it('clear remove token', () => {
const token = nbAuthCreateToken(NbAuthSimpleToken, 'test');
const token = nbAuthCreateToken(NbAuthSimpleToken, 'test', ownerStrategyName);
localStorage.setItem(testTokenKey, tokenParceler.wrap(token));

tokenStorage.clear();
Expand All @@ -85,7 +86,7 @@ describe('token-storage', () => {
});

it('clear remove token only', () => {
const token = nbAuthCreateToken(NbAuthSimpleToken, 'test');
const token = nbAuthCreateToken(NbAuthSimpleToken, 'test', ownerStrategyName);
localStorage.setItem(testTokenKey, tokenParceler.wrap(token));
localStorage.setItem(testTokenKey + '2', tokenParceler.wrap(token));

Expand Down
22 changes: 11 additions & 11 deletions src/framework/auth/services/token/token.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import { NbAuthOAuth2Token, NbAuthJWTToken, NbAuthSimpleToken } from './token';
describe('auth token', () => {
describe('NbAuthJWTToken', () => {
// tslint:disable
const simpleToken = new NbAuthSimpleToken('token');
const validJWTToken = new NbAuthJWTToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJleHAiOjI1MTczMTQwNjYxNzUsIm5hbWUiOiJDaHJpcyBTZXZpbGxlamEiLCJhZG1pbiI6dHJ1ZX0=.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773');
const emptyJWTToken = new NbAuthJWTToken('..');
const invalidBase64JWTToken = new NbAuthJWTToken('h%2BHY.h%2BHY.h%2BHY');
const simpleToken = new NbAuthSimpleToken('token','strategy');
const validJWTToken = new NbAuthJWTToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJleHAiOjI1MTczMTQwNjYxNzUsIm5hbWUiOiJDaHJpcyBTZXZpbGxlamEiLCJhZG1pbiI6dHJ1ZX0=.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773', 'strategy');
const emptyJWTToken = new NbAuthJWTToken('..', 'strategy');
const invalidBase64JWTToken = new NbAuthJWTToken('h%2BHY.h%2BHY.h%2BHY','strategy');

const invalidJWTToken = new NbAuthJWTToken('.');
const invalidJWTToken = new NbAuthJWTToken('.','strategy');

const noExpJWTToken = new NbAuthJWTToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJuYW1lIjoiQ2hyaXMgU2V2aWxsZWphIiwiYWRtaW4iOnRydWV9.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773');
const noExpJWTToken = new NbAuthJWTToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJuYW1lIjoiQ2hyaXMgU2V2aWxsZWphIiwiYWRtaW4iOnRydWV9.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773','strategy');

const expiredJWTToken = new NbAuthJWTToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJleHAiOjEzMDA4MTkzODAsIm5hbWUiOiJDaHJpcyBTZXZpbGxlamEiLCJhZG1pbiI6dHJ1ZX0.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773');
const expiredJWTToken = new NbAuthJWTToken('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzY290Y2guaW8iLCJleHAiOjEzMDA4MTkzODAsIm5hbWUiOiJDaHJpcyBTZXZpbGxlamEiLCJhZG1pbiI6dHJ1ZX0.03f329983b86f7d9a9f5fef85305880101d5e302afafa20154d094b229f75773','strategy');
// tslint:enable

it('getPayload success', () => {
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('auth token', () => {

it('isValid fail', () => {
// without token
expect(new NbAuthJWTToken('').isValid()).toBeFalsy();
expect(new NbAuthJWTToken('', 'strategy').isValid()).toBeFalsy();

// expired date
expect(expiredJWTToken.isValid()).toBeFalsy();
Expand Down Expand Up @@ -123,14 +123,14 @@ describe('auth token', () => {
example_parameter: 'example_value',
};

const validToken = new NbAuthOAuth2Token(token);
const emptyToken = new NbAuthOAuth2Token({});
const validToken = new NbAuthOAuth2Token(token, 'strategy');
const emptyToken = new NbAuthOAuth2Token({}, 'strategy');

const noExpToken = new NbAuthOAuth2Token({
access_token: '2YotnFZFEjr1zCsicMWpAA',
refresh_token: 'tGzv3JOkF0XG5Qx2TlKWIA',
example_parameter: 'example_value',
});
}, 'strategy');

it('getPayload success', () => {
expect(validToken.getPayload()).toEqual(token);
Expand Down
28 changes: 22 additions & 6 deletions src/framework/auth/services/token/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export abstract class NbAuthToken {
abstract getValue(): string;
abstract isValid(): boolean;
abstract getPayload(): string;
// the strategy name used to acquire this token (needed for refreshing token)
abstract getOwnerStrategyName(): string;
abstract toString(): string;

getName(): string {
Expand All @@ -17,11 +19,18 @@ export interface NbAuthRefreshableToken {

export interface NbAuthTokenClass {
NAME: string;
new (raw: any): NbAuthToken;
new (raw: any, ownerStrategyName: string): NbAuthToken;
}

export function nbAuthCreateToken(tokenClass: NbAuthTokenClass, token: any) {
return new tokenClass(token);
// All types of token are not refreshables
export function isNbAuthRefreshableToken(token: any): token is NbAuthRefreshableToken {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is not a part of this PR, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right. Part of the next next next :)

return (<NbAuthRefreshableToken>token).getRefreshToken !== undefined ;
}

export function nbAuthCreateToken(tokenClass: NbAuthTokenClass,
token: any,
ownerStrategyName: string) {
return new tokenClass(token, ownerStrategyName);
}

/**
Expand All @@ -31,7 +40,8 @@ export class NbAuthSimpleToken extends NbAuthToken {

static NAME = 'nb:auth:simple:token';

constructor(protected readonly token: any) {
constructor(protected readonly token: any,
protected readonly ownerStrategyName: string) {
super();
}

Expand All @@ -43,6 +53,10 @@ export class NbAuthSimpleToken extends NbAuthToken {
return this.token;
}

getOwnerStrategyName(): string {
return this.ownerStrategyName;
}

getPayload(): string {
return null;
}
Expand Down Expand Up @@ -142,9 +156,11 @@ export class NbAuthOAuth2Token extends NbAuthSimpleToken {

static NAME = 'nb:auth:oauth2:token';

constructor(protected data: { [key: string]: string|number }|string = {}) {
constructor(protected data: { [key: string]: string|number }|string = {},
protected ownerStrategyName: string) {
// we may get it as string when retrieving from a storage
super(prepareOAuth2Token(data));
super(prepareOAuth2Token(data), ownerStrategyName);
this.ownerStrategyName = ownerStrategyName;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why to assign it here again as it will be assigned in super?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right again

}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/framework/auth/strategies/auth-strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export abstract class NbAuthStrategy {
}

createToken(value: any): NbAuthToken {
return nbAuthCreateToken(this.getOption('token.class'), value);
return nbAuthCreateToken(this.getOption('token.class'), value, this.getName());
}

getName(): string {
Expand Down
27 changes: 19 additions & 8 deletions src/framework/auth/strategies/oauth2/oauth2-strategy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('oauth2-auth-strategy', () => {
error_uri: 'some',
};

const successToken = nbAuthCreateToken(NbAuthOAuth2Token, tokenSuccessResponse) as NbAuthOAuth2Token;
const successToken = nbAuthCreateToken(NbAuthOAuth2Token, tokenSuccessResponse, 'strategy') as NbAuthOAuth2Token;


beforeEach(() => {
Expand Down Expand Up @@ -78,6 +78,7 @@ describe('oauth2-auth-strategy', () => {

beforeEach(() => {
strategy.setOptions({
name: 'strategy',
baseEndpoint: 'http://example.com/',
clientId: 'clientId',
clientSecret: 'clientSecret',
Expand All @@ -104,7 +105,8 @@ describe('oauth2-auth-strategy', () => {
expect(result).toBeTruthy();
expect(result.isSuccess()).toBe(true);
expect(result.isFailure()).toBe(false);
expect(result.getToken()).toEqual(successToken);
expect(result.getToken().getValue()).toEqual(successToken.getValue());
expect(result.getToken().getOwnerStrategyName()).toEqual(successToken.getOwnerStrategyName());
expect(result.getMessages()).toEqual(successMessages);
expect(result.getErrors()).toEqual([]); // no error message, response is success
expect(result.getRedirect()).toEqual('/');
Expand Down Expand Up @@ -166,7 +168,8 @@ describe('oauth2-auth-strategy', () => {
expect(result).toBeTruthy();
expect(result.isSuccess()).toBe(true);
expect(result.isFailure()).toBe(false);
expect(result.getToken()).toEqual(successToken);
expect(result.getToken().getValue()).toEqual(successToken.getValue());
expect(result.getToken().getOwnerStrategyName()).toEqual(successToken.getOwnerStrategyName());
expect(result.getMessages()).toEqual(successMessages);
expect(result.getErrors()).toEqual([]); // no error message, response is success
expect(result.getRedirect()).toEqual('/');
Expand Down Expand Up @@ -205,6 +208,7 @@ describe('oauth2-auth-strategy', () => {

beforeEach(() => {
strategy.setOptions({
name: 'strategy',
baseEndpoint: 'http://example.com/',
clientId: 'clientId',
clientSecret: 'clientSecret',
Expand Down Expand Up @@ -236,7 +240,8 @@ describe('oauth2-auth-strategy', () => {
expect(result).toBeTruthy();
expect(result.isSuccess()).toBe(true);
expect(result.isFailure()).toBe(false);
expect(result.getToken()).toEqual(nbAuthCreateToken(NbAuthOAuth2Token, token));
// tslint:disable-next-line
expect(result.getToken().getValue()).toEqual(nbAuthCreateToken(NbAuthOAuth2Token, token, 'strategy').getValue());
expect(result.getMessages()).toEqual(successMessages);
expect(result.getErrors()).toEqual([]); // no error message, response is success
expect(result.getRedirect()).toEqual('/');
Expand Down Expand Up @@ -266,6 +271,7 @@ describe('oauth2-auth-strategy', () => {

beforeEach(() => {
strategy.setOptions({
name: 'strategy',
baseEndpoint: 'http://example.com/',
clientId: 'clientId',
clientSecret: 'clientSecret',
Expand Down Expand Up @@ -317,7 +323,8 @@ describe('oauth2-auth-strategy', () => {
expect(result).toBeTruthy();
expect(result.isSuccess()).toBe(true);
expect(result.isFailure()).toBe(false);
expect(result.getToken()).toEqual(successToken);
expect(result.getToken().getValue()).toEqual(successToken.getValue());
expect(result.getToken().getOwnerStrategyName()).toEqual(successToken.getOwnerStrategyName());
expect(result.getMessages()).toEqual(successMessages);
expect(result.getErrors()).toEqual([]); // no error message, response is success
expect(result.getRedirect()).toEqual('/success');
Expand All @@ -341,7 +348,8 @@ describe('oauth2-auth-strategy', () => {
expect(result).toBeTruthy();
expect(result.isSuccess()).toBe(true);
expect(result.isFailure()).toBe(false);
expect(result.getToken()).toEqual(successToken);
expect(result.getToken().getValue()).toEqual(successToken.getValue());
expect(result.getToken().getOwnerStrategyName()).toEqual(successToken.getOwnerStrategyName());
expect(result.getMessages()).toEqual(successMessages);
expect(result.getErrors()).toEqual([]); // no error message, response is success
expect(result.getRedirect()).toEqual('/success');
Expand Down Expand Up @@ -376,7 +384,8 @@ describe('oauth2-auth-strategy', () => {
expect(result).toBeTruthy();
expect(result.isSuccess()).toBe(true);
expect(result.isFailure()).toBe(false);
expect(result.getToken()).toEqual(successToken);
expect(result.getToken().getValue()).toEqual(successToken.getValue());
expect(result.getToken().getOwnerStrategyName()).toEqual(successToken.getOwnerStrategyName());
expect(result.getMessages()).toEqual(successMessages);
expect(result.getErrors()).toEqual([]); // no error message, response is success
expect(result.getRedirect()).toEqual('/success');
Expand Down Expand Up @@ -417,6 +426,7 @@ describe('oauth2-auth-strategy', () => {

beforeEach(() => {
strategy.setOptions({
name: 'strategy',
baseEndpoint: 'http://example.com/',
clientId: 'clientId',
clientSecret: 'clientSecret',
Expand All @@ -436,7 +446,8 @@ describe('oauth2-auth-strategy', () => {
expect(result).toBeTruthy();
expect(result.isSuccess()).toBe(true);
expect(result.isFailure()).toBe(false);
expect(result.getToken()).toEqual(successToken);
expect(result.getToken().getValue()).toEqual(successToken.getValue());
expect(result.getToken().getOwnerStrategyName()).toEqual(successToken.getOwnerStrategyName());
expect(result.getMessages()).toEqual(successMessages);
expect(result.getErrors()).toEqual([]); // no error message, response is success
expect(result.getRedirect()).toEqual('/');
Expand Down
Loading