Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcdogo committed Oct 12, 2020
1 parent 0aa2590 commit 66b92a4
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 194 deletions.
80 changes: 40 additions & 40 deletions test/integration/grant-types/authorization-code-grant-type.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,23 +616,23 @@ describe('AuthorizationCodeGrantType integration', () => {

describe('with PKCE', function() {
it('should throw an error if the `code_verifier` is invalid with S256 code challenge method', () => {
var codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
var authorizationCode = {
const codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
const authorizationCode = {
authorizationCode: 12345,
client: { id: 'foobar' },
expiresAt: new Date(new Date().getTime() * 2),
user: {},
codeChallengeMethod: 'S256',
codeChallenge: stringUtil.base64URLEncode(crypto.createHash('sha256').update(codeVerifier).digest())
codeChallenge: stringUtil.base64URLEncode(crypto.createHash('sha256').update(codeVerifier).digest()),
};
var client: any = { id: 'foobar', isPublic: true };
var model = {
getAuthorizationCode: function() { return authorizationCode; },
revokeAuthorizationCode: function() {},
saveToken: function() {}
const client: any = { id: 'foobar', isPublic: true };
const model = {
getAuthorizationCode() { return authorizationCode; },
revokeAuthorizationCode() {},
saveToken() {},
};
var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model });
var request = new Request({ body: { code: 12345, code_verifier: 'foo' }, headers: {}, method: 'POST', query: {} });
const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model });
const request = new Request({ body: { code: 12345, code_verifier: 'foo' }, headers: {}, method: 'POST', query: {} });

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

it('should throw an error if the `code_verifier` is invalid with plain code challenge method', () => {
var codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
var authorizationCode = {
const codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
const authorizationCode = {
authorizationCode: 12345,
client: { id: 'foobar' },
expiresAt: new Date(new Date().getTime() * 2),
user: {},
codeChallengeMethod: 'plain',
codeChallenge: codeVerifier
codeChallenge: codeVerifier,
};
var client: any = { id: 'foobar', isPublic: true };
var model = {
getAuthorizationCode: function() { return authorizationCode; },
revokeAuthorizationCode: function() {},
saveToken: function() {}
const client: any = { id: 'foobar', isPublic: true };
const model = {
getAuthorizationCode() { return authorizationCode; },
revokeAuthorizationCode() {},
saveToken() {},
};
var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model });
var request = new Request({ body: { code: 12345, code_verifier: 'foo' }, headers: {}, method: 'POST', query: {} });
const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model });
const request = new Request({ body: { code: 12345, code_verifier: 'foo' }, headers: {}, method: 'POST', query: {} });

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

it('should return an auth code when `code_verifier` is valid with S256 code challenge method', () => {
var codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
var authorizationCode = {
const codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
const authorizationCode = {
authorizationCode: 12345,
client: { id: 'foobar', isPublic: true },
expiresAt: new Date(new Date().getTime() * 2),
user: {},
codeChallengeMethod: 'S256',
codeChallenge: stringUtil.base64URLEncode(crypto.createHash('sha256').update(codeVerifier).digest())
codeChallenge: stringUtil.base64URLEncode(crypto.createHash('sha256').update(codeVerifier).digest()),
};
var client: any = { id: 'foobar', isPublic: true };
var model = {
getAuthorizationCode: function() { return authorizationCode; },
revokeAuthorizationCode: function() {},
saveToken: function() {}
const client: any = { id: 'foobar', isPublic: true };
const model = {
getAuthorizationCode() { return authorizationCode; },
revokeAuthorizationCode() {},
saveToken() {},
};
var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model });
var request = new Request({ body: { code: 12345, code_verifier: codeVerifier }, headers: {}, method: 'POST', query: {} });
const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model });
const request = new Request({ body: { code: 12345, code_verifier: codeVerifier }, headers: {}, method: 'POST', query: {} });

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

it('should return an auth code when `code_verifier` is valid with plain code challenge method', () => {
var codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
var authorizationCode = {
const codeVerifier = stringUtil.base64URLEncode(crypto.randomBytes(32));
const authorizationCode = {
authorizationCode: 12345,
client: { id: 'foobar' },
expiresAt: new Date(new Date().getTime() * 2),
user: {},
codeChallengeMethod: 'plain',
codeChallenge: codeVerifier
codeChallenge: codeVerifier,
};
var client: any = { id: 'foobar', isPublic: true };
var model = {
getAuthorizationCode: function() { return authorizationCode; },
revokeAuthorizationCode: function() {},
saveToken: function() {}
const client: any = { id: 'foobar', isPublic: true };
const model = {
getAuthorizationCode() { return authorizationCode; },
revokeAuthorizationCode() {},
saveToken() {},
};
var grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model: model });
var request = new Request({ body: { code: 12345, code_verifier: codeVerifier }, headers: {}, method: 'POST', query: {} });
const grantType = new AuthorizationCodeGrantType({ accessTokenLifetime: 123, model });
const request = new Request({ body: { code: 12345, code_verifier: codeVerifier }, headers: {}, method: 'POST', query: {} });

return grantType.getAuthorizationCode(request, client)
.then(function(data) {
Expand Down
44 changes: 22 additions & 22 deletions test/integration/handlers/authenticate-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ describe('AuthenticateHandler integration', () => {

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

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

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

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

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

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

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

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

return handler.handle(request, response)
Expand Down
86 changes: 43 additions & 43 deletions test/integration/handlers/authorize-handler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,35 +191,35 @@ describe('AuthorizeHandler integration', () => {

it('should throw an error if `allowed` is `false`', () => {
const model = {
getAccessToken: function() {
getAccessToken() {
return {
user: {},
accessTokenExpiresAt: new Date(new Date().getTime() + 10000)
accessTokenExpiresAt: new Date(new Date().getTime() + 10000),
};
},
getClient: function() {
getClient() {
return { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] };
},
saveAuthorizationCode: function() {
saveAuthorizationCode() {
throw new Error('Unhandled exception');
}
},
};
const handler = new AuthorizeHandler({
authorizationCodeLifetime: 120,
model,
});
const request = new Request({
body: {
client_id: 'test'
client_id: 'test',
},
headers: {
'Authorization': 'Bearer foo'
Authorization: 'Bearer foo',
},
method: 'ANY',
query: {
allowed: 'false',
state: 'foobar'
}
state: 'foobar',
},
});
const response = new Response({ body: {}, headers: {} });

Expand Down Expand Up @@ -446,84 +446,84 @@ describe('AuthorizeHandler integration', () => {
});

it('should redirect to a successful response if `model.validateScope` is not defined', function() {
var client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] };
var model = {
getAccessToken: function() {
let client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] };
let model = {
getAccessToken() {
return {
client: client,
client,
user: {},
accessTokenExpiresAt: new Date(new Date().getTime() + 10000)
accessTokenExpiresAt: new Date(new Date().getTime() + 10000),
};
},
getClient: function() {
getClient() {
return client;
},
saveAuthorizationCode: function() {
return { authorizationCode: 12345, client: client };
}
saveAuthorizationCode() {
return { authorizationCode: 12345, client };
},
};
var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model });
var request = new Request({
let handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model });
let request = new Request({
body: {
client_id: 12345,
response_type: 'code'
response_type: 'code',
},
headers: {
'Authorization': 'Bearer foo'
Authorization: 'Bearer foo',
},
method: 'POST',
query: {
scope: 'read',
state: 'foobar'
}
state: 'foobar',
},
});
var response = new Response({ body: {}, headers: {} });
let response = new Response({ body: {}, headers: {} });

return handler.handle(request, response)
.then(function(data) {
data.should.eql({
authorizationCode: 12345,
client: client
client,
});
});
});

it('should redirect to an error response if `scope` is insufficient', function() {
var client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] };
var model = {
getAccessToken: function() {
let client = { grants: ['authorization_code'], redirectUris: ['http://example.com/cb'] };
let model = {
getAccessToken() {
return {
client: client,
client,
user: {},
accessTokenExpiresAt: new Date(new Date().getTime() + 10000)
accessTokenExpiresAt: new Date(new Date().getTime() + 10000),
};
},
getClient: function() {
getClient() {
return client;
},
saveAuthorizationCode: function() {
return { authorizationCode: 12345, client: client };
saveAuthorizationCode() {
return { authorizationCode: 12345, client };
},
validateScope: function() {
validateScope() {
return false;
}
},
};
var handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model: model });
var request = new Request({
let handler = new AuthorizeHandler({ authorizationCodeLifetime: 120, model });
let request = new Request({
body: {
client_id: 12345,
response_type: 'code'
response_type: 'code',
},
headers: {
'Authorization': 'Bearer foo'
Authorization: 'Bearer foo',
},
method: 'POST',
query: {
scope: 'read',
state: 'foobar'
}
state: 'foobar',
},
});
var response = new Response({ body: {}, headers: {} });
let response = new Response({ body: {}, headers: {} });

return handler.handle(request, response)
.then(() => {
Expand Down
Loading

0 comments on commit 66b92a4

Please sign in to comment.