Skip to content

Commit 66b92a4

Browse files
committed
Lint fixes
1 parent 0aa2590 commit 66b92a4

File tree

5 files changed

+194
-194
lines changed

5 files changed

+194
-194
lines changed

test/integration/grant-types/authorization-code-grant-type.spec.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -616,23 +616,23 @@ describe('AuthorizationCodeGrantType integration', () => {
616616

617617
describe('with PKCE', function() {
618618
it('should throw an error if the `code_verifier` is invalid with S256 code challenge method', () => {
619-
var codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
620-
var authorizationCode = {
619+
const codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
620+
const authorizationCode = {
621621
authorizationCode: 12345,
622622
client: { id: 'foobar' },
623623
expiresAt: new Date(new Date().getTime() * 2),
624624
user: {},
625625
codeChallengeMethod: 'S256',
626-
codeChallenge: stringUtil.base64URLEncode(crypto.createHash('sha256').update(codeVerifier).digest())
626+
codeChallenge: stringUtil.base64URLEncode(crypto.createHash('sha256').update(codeVerifier).digest()),
627627
};
628-
var client: any = { id: 'foobar', isPublic: true };
629-
var model = {
630-
getAuthorizationCode: function() { return authorizationCode; },
631-
revokeAuthorizationCode: function() {},
632-
saveToken: function() {}
628+
const client: any = { id: 'foobar', isPublic: true };
629+
const model = {
630+
getAuthorizationCode() { return authorizationCode; },
631+
revokeAuthorizationCode() {},
632+
saveToken() {},
633633
};
634-
var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model });
635-
var request = new Request({ body: { code: 12345, code_verifier: 'foo' }, headers: {}, method: 'POST', query: {} });
634+
const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model });
635+
const request = new Request({ body: { code: 12345, code_verifier: 'foo' }, headers: {}, method: 'POST', query: {} });
636636

637637
return grantType.getAuthorizationCode(request, client)
638638
.then(() => {
@@ -645,23 +645,23 @@ describe('AuthorizationCodeGrantType integration', () => {
645645
});
646646

647647
it('should throw an error if the `code_verifier` is invalid with plain code challenge method', () => {
648-
var codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
649-
var authorizationCode = {
648+
const codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
649+
const authorizationCode = {
650650
authorizationCode: 12345,
651651
client: { id: 'foobar' },
652652
expiresAt: new Date(new Date().getTime() * 2),
653653
user: {},
654654
codeChallengeMethod: 'plain',
655-
codeChallenge: codeVerifier
655+
codeChallenge: codeVerifier,
656656
};
657-
var client: any = { id: 'foobar', isPublic: true };
658-
var model = {
659-
getAuthorizationCode: function() { return authorizationCode; },
660-
revokeAuthorizationCode: function() {},
661-
saveToken: function() {}
657+
const client: any = { id: 'foobar', isPublic: true };
658+
const model = {
659+
getAuthorizationCode() { return authorizationCode; },
660+
revokeAuthorizationCode() {},
661+
saveToken() {},
662662
};
663-
var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model });
664-
var request = new Request({ body: { code: 12345, code_verifier: 'foo' }, headers: {}, method: 'POST', query: {} });
663+
const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model });
664+
const request = new Request({ body: { code: 12345, code_verifier: 'foo' }, headers: {}, method: 'POST', query: {} });
665665

666666
return grantType.getAuthorizationCode(request, client)
667667
.then(() => {
@@ -674,23 +674,23 @@ describe('AuthorizationCodeGrantType integration', () => {
674674
});
675675

676676
it('should return an auth code when `code_verifier` is valid with S256 code challenge method', () => {
677-
var codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
678-
var authorizationCode = {
677+
const codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
678+
const authorizationCode = {
679679
authorizationCode: 12345,
680680
client: { id: 'foobar', isPublic: true },
681681
expiresAt: new Date(new Date().getTime() * 2),
682682
user: {},
683683
codeChallengeMethod: 'S256',
684-
codeChallenge: stringUtil.base64URLEncode(crypto.createHash('sha256').update(codeVerifier).digest())
684+
codeChallenge: stringUtil.base64URLEncode(crypto.createHash('sha256').update(codeVerifier).digest()),
685685
};
686-
var client: any = { id: 'foobar', isPublic: true };
687-
var model = {
688-
getAuthorizationCode: function() { return authorizationCode; },
689-
revokeAuthorizationCode: function() {},
690-
saveToken: function() {}
686+
const client: any = { id: 'foobar', isPublic: true };
687+
const model = {
688+
getAuthorizationCode() { return authorizationCode; },
689+
revokeAuthorizationCode() {},
690+
saveToken() {},
691691
};
692-
var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model });
693-
var request = new Request({ body: { code: 12345, code_verifier: codeVerifier }, headers: {}, method: 'POST', query: {} });
692+
const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model });
693+
const request = new Request({ body: { code: 12345, code_verifier: codeVerifier }, headers: {}, method: 'POST', query: {} });
694694

695695
return grantType.getAuthorizationCode(request, client)
696696
.then(function(data) {
@@ -702,23 +702,23 @@ describe('AuthorizationCodeGrantType integration', () => {
702702
});
703703

704704
it('should return an auth code when `code_verifier` is valid with plain code challenge method', () => {
705-
var codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
706-
var authorizationCode = {
705+
const codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
706+
const authorizationCode = {
707707
authorizationCode: 12345,
708708
client: { id: 'foobar' },
709709
expiresAt: new Date(new Date().getTime() * 2),
710710
user: {},
711711
codeChallengeMethod: 'plain',
712-
codeChallenge: codeVerifier
712+
codeChallenge: codeVerifier,
713713
};
714-
var client: any = { id: 'foobar', isPublic: true };
715-
var model = {
716-
getAuthorizationCode: function() { return authorizationCode; },
717-
revokeAuthorizationCode: function() {},
718-
saveToken: function() {}
714+
const client: any = { id: 'foobar', isPublic: true };
715+
const model = {
716+
getAuthorizationCode() { return authorizationCode; },
717+
revokeAuthorizationCode() {},
718+
saveToken() {},
719719
};
720-
var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model });
721-
var request = new Request({ body: { code: 12345, code_verifier: codeVerifier }, headers: {}, method: 'POST', query: {} });
720+
const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model });
721+
const request = new Request({ body: { code: 12345, code_verifier: codeVerifier }, headers: {}, method: 'POST', query: {} });
722722

723723
return grantType.getAuthorizationCode(request, client)
724724
.then(function(data) {

test/integration/handlers/authenticate-handler.spec.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,11 @@ describe('AuthenticateHandler integration', () => {
162162

163163
it('should set the `WWW-Authenticate` header if an InvalidRequestError is thrown without message', () => {
164164
const model = {
165-
getAccessToken: function() {
165+
getAccessToken() {
166166
throw new InvalidRequestError();
167-
}
167+
},
168168
};
169-
const handler = new AuthenticateHandler({ model: model });
169+
const handler = new AuthenticateHandler({ model });
170170
const request = new Request({ body: {}, headers: { Authorization: 'Bearer foo' }, method: 'ANY', query: {} });
171171
const response = new Response({ body: {}, headers: {} });
172172

@@ -183,11 +183,11 @@ describe('AuthenticateHandler integration', () => {
183183
it('should set the `WWW-Authenticate` header if an InvalidRequestError is thrown with message', () => {
184184
const errorDescription = 'Error description';
185185
const model = {
186-
getAccessToken: function() {
186+
getAccessToken() {
187187
throw new InvalidRequestError(errorDescription);
188-
}
188+
},
189189
};
190-
const handler = new AuthenticateHandler({ model: model });
190+
const handler = new AuthenticateHandler({ model });
191191
const request = new Request({ body: {}, headers: { Authorization: 'Bearer foo' }, method: 'ANY', query: {} });
192192
const response = new Response({ body: {}, headers: {} });
193193

@@ -203,12 +203,12 @@ describe('AuthenticateHandler integration', () => {
203203

204204
it('should set the `WWW-Authenticate` header if an InvalidTokenError is thrown without message', () => {
205205
const model = {
206-
getAccessToken: function() {
206+
getAccessToken() {
207207
throw new InvalidTokenError();
208-
}
208+
},
209209
};
210-
const handler = new AuthenticateHandler({ model: model });
211-
const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: 'ANY', query: {} });
210+
const handler = new AuthenticateHandler({ model });
211+
const request = new Request({ body: {}, headers: { Authorization: 'Bearer foo' }, method: 'ANY', query: {} });
212212
const response = new Response({ body: {}, headers: {} });
213213

214214
return handler.handle(request, response)
@@ -224,12 +224,12 @@ describe('AuthenticateHandler integration', () => {
224224
it('should set the `WWW-Authenticate` header if an InvalidTokenError is thrown with message', () => {
225225
const errorDescription = 'Error description';
226226
const model = {
227-
getAccessToken: function() {
227+
getAccessToken() {
228228
throw new InvalidTokenError(errorDescription);
229-
}
229+
},
230230
};
231-
const handler = new AuthenticateHandler({ model: model });
232-
const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: 'ANY', query: {} });
231+
const handler = new AuthenticateHandler({ model });
232+
const request = new Request({ body: {}, headers: { Authorization: 'Bearer foo' }, method: 'ANY', query: {} });
233233
const response = new Response({ body: {}, headers: {} });
234234

235235
return handler.handle(request, response)
@@ -244,12 +244,12 @@ describe('AuthenticateHandler integration', () => {
244244

245245
it('should set the `WWW-Authenticate` header if an InsufficientScopeError is thrown without message', () => {
246246
const model = {
247-
getAccessToken: function() {
247+
getAccessToken() {
248248
throw new InsufficientScopeError();
249-
}
249+
},
250250
};
251-
const handler = new AuthenticateHandler({ model: model });
252-
const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: 'ANY', query: {} });
251+
const handler = new AuthenticateHandler({ model });
252+
const request = new Request({ body: {}, headers: { Authorization: 'Bearer foo' }, method: 'ANY', query: {} });
253253
const response = new Response({ body: {}, headers: {} });
254254

255255
return handler.handle(request, response)
@@ -265,12 +265,12 @@ describe('AuthenticateHandler integration', () => {
265265
it('should set the `WWW-Authenticate` header if an InsufficientScopeError is thrown with message', () => {
266266
const errorDescription = 'Error description';
267267
const model = {
268-
getAccessToken: function() {
268+
getAccessToken() {
269269
throw new InsufficientScopeError(errorDescription);
270-
}
270+
},
271271
};
272-
const handler = new AuthenticateHandler({ model: model });
273-
const request = new Request({ body: {}, headers: { 'Authorization': 'Bearer foo' }, method: 'ANY', query: {} });
272+
const handler = new AuthenticateHandler({ model });
273+
const request = new Request({ body: {}, headers: { Authorization: 'Bearer foo' }, method: 'ANY', query: {} });
274274
const response = new Response({ body: {}, headers: {} });
275275

276276
return handler.handle(request, response)

test/integration/handlers/authorize-handler.spec.ts

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -191,35 +191,35 @@ describe('AuthorizeHandler integration', () => {
191191

192192
it('should throw an error if `allowed` is `false`', () => {
193193
const model = {
194-
getAccessToken: function() {
194+
getAccessToken() {
195195
return {
196196
user: {},
197-
accessTokenExpiresAt: new Date(new Date().getTime() + 10000)
197+
accessTokenExpiresAt: new Date(new Date().getTime() + 10000),
198198
};
199199
},
200-
getClient: function() {
200+
getClient() {
201201
return { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] };
202202
},
203-
saveAuthorizationCode: function() {
203+
saveAuthorizationCode() {
204204
throw new Error('Unhandled exception');
205-
}
205+
},
206206
};
207207
const handler = new AuthorizeHandler({
208208
authorizationCodeLifetime: 120,
209209
model,
210210
});
211211
const request = new Request({
212212
body: {
213-
client_id: 'test'
213+
client_id: 'test',
214214
},
215215
headers: {
216-
'Authorization': 'Bearer foo'
216+
Authorization: 'Bearer foo',
217217
},
218218
method: 'ANY',
219219
query: {
220220
allowed: 'false',
221-
state: 'foobar'
222-
}
221+
state: 'foobar',
222+
},
223223
});
224224
const response = new Response({ body: {}, headers: {} });
225225

@@ -446,84 +446,84 @@ describe('AuthorizeHandler integration', () => {
446446
});
447447

448448
it('should redirect to a successful response if `model.validateScope` is not defined', function() {
449-
var client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] };
450-
var model = {
451-
getAccessToken: function() {
449+
let client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] };
450+
let model = {
451+
getAccessToken() {
452452
return {
453-
client: client,
453+
client,
454454
user: {},
455-
accessTokenExpiresAt: new Date(new Date().getTime() + 10000)
455+
accessTokenExpiresAt: new Date(new Date().getTime() + 10000),
456456
};
457457
},
458-
getClient: function() {
458+
getClient() {
459459
return client;
460460
},
461-
saveAuthorizationCode: function() {
462-
return { authorizationCode: 12345, client: client };
463-
}
461+
saveAuthorizationCode() {
462+
return { authorizationCode: 12345, client };
463+
},
464464
};
465-
var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model });
466-
var request = new Request({
465+
let handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model });
466+
let request = new Request({
467467
body: {
468468
client_id: 12345,
469-
response_type: 'code'
469+
response_type: 'code',
470470
},
471471
headers: {
472-
'Authorization': 'Bearer foo'
472+
Authorization: 'Bearer foo',
473473
},
474474
method: 'POST',
475475
query: {
476476
scope: 'read',
477-
state: 'foobar'
478-
}
477+
state: 'foobar',
478+
},
479479
});
480-
var response = new Response({ body: {}, headers: {} });
480+
let response = new Response({ body: {}, headers: {} });
481481

482482
return handler.handle(request, response)
483483
.then(function(data) {
484484
data.should.eql({
485485
authorizationCode: 12345,
486-
client: client
486+
client,
487487
});
488488
});
489489
});
490490

491491
it('should redirect to an error response if `scope` is insufficient', function() {
492-
var client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] };
493-
var model = {
494-
getAccessToken: function() {
492+
let client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] };
493+
let model = {
494+
getAccessToken() {
495495
return {
496-
client: client,
496+
client,
497497
user: {},
498-
accessTokenExpiresAt: new Date(new Date().getTime() + 10000)
498+
accessTokenExpiresAt: new Date(new Date().getTime() + 10000),
499499
};
500500
},
501-
getClient: function() {
501+
getClient() {
502502
return client;
503503
},
504-
saveAuthorizationCode: function() {
505-
return { authorizationCode: 12345, client: client };
504+
saveAuthorizationCode() {
505+
return { authorizationCode: 12345, client };
506506
},
507-
validateScope: function() {
507+
validateScope() {
508508
return false;
509-
}
509+
},
510510
};
511-
var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model });
512-
var request = new Request({
511+
let handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model });
512+
let request = new Request({
513513
body: {
514514
client_id: 12345,
515-
response_type: 'code'
515+
response_type: 'code',
516516
},
517517
headers: {
518-
'Authorization': 'Bearer foo'
518+
Authorization: 'Bearer foo',
519519
},
520520
method: 'POST',
521521
query: {
522522
scope: 'read',
523-
state: 'foobar'
524-
}
523+
state: 'foobar',
524+
},
525525
});
526-
var response = new Response({ body: {}, headers: {} });
526+
let response = new Response({ body: {}, headers: {} });
527527

528528
return handler.handle(request, response)
529529
.then(() => {

0 commit comments

Comments
 (0)