Skip to content

Commit

Permalink
fixy
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Jul 25, 2018
1 parent f4d041a commit 7090641
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 91 deletions.
52 changes: 11 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion test/test.apikey.ts
Expand Up @@ -44,7 +44,8 @@ async function testAuthKey(urlshortener: APIEndpoint) {
.get('/urlshortener/v1/url/history?key=YOUR%20API%20KEY')
.reply(200);
const res = await urlshortener.url.list({auth: 'YOUR API KEY'});
assert.strictEqual(Utils.getQs(res)!.indexOf('key=YOUR%20API%20KEY') > -1, true);
assert.strictEqual(
Utils.getQs(res)!.indexOf('key=YOUR%20API%20KEY') > -1, true);
}

describe('API key', () => {
Expand Down
34 changes: 18 additions & 16 deletions test/test.auth.ts
Expand Up @@ -38,14 +38,14 @@ describe('JWT client', () => {
it('should create scoped JWT', () => {
const jwt = new googleapis.auth.JWT(
'someone@somewhere.com', 'file1', 'key1', undefined, 'subject1');
assert.strictEqual(jwt.scopes, null);
assert.strictEqual(jwt.scopes, undefined);
assert.strictEqual(jwt.createScopedRequired(), true);

// Create a scoped version of the token now.
const jwt2 = jwt.createScoped('scope1');

// The original token should be unchanged.
assert.strictEqual(jwt.scopes, null);
assert.strictEqual(jwt.scopes, undefined);
assert.strictEqual(jwt.createScopedRequired(), true);

// The new token should have scopes.
Expand Down Expand Up @@ -198,12 +198,13 @@ describe('OAuth2 client', () => {

nock(Utils.baseUrl).get('/drive/v2/files/wat').reply(200);
await localDrive.files.get({fileId: 'wat', auth: oauth2client});
assert.strictEqual(JSON.stringify(oauth2client.credentials), JSON.stringify({
access_token: 'abc123',
refresh_token: 'abc',
expiry_date: tenMinutesFromNow,
token_type: 'Bearer'
}));
assert.strictEqual(
JSON.stringify(oauth2client.credentials), JSON.stringify({
access_token: 'abc123',
refresh_token: 'abc',
expiry_date: tenMinutesFromNow,
token_type: 'Bearer'
}));

assert.throws(() => {
scope.done();
Expand All @@ -220,12 +221,13 @@ describe('OAuth2 client', () => {

nock(Utils.baseUrl).get('/drive/v2/files/wat').reply(200);
await remoteDrive.files.get({fileId: 'wat', auth: oauth2client});
assert.strictEqual(JSON.stringify(oauth2client.credentials), JSON.stringify({
access_token: 'abc123',
refresh_token: 'abc',
expiry_date: tenMinutesFromNow,
token_type: 'Bearer'
}));
assert.strictEqual(
JSON.stringify(oauth2client.credentials), JSON.stringify({
access_token: 'abc123',
refresh_token: 'abc',
expiry_date: tenMinutesFromNow,
token_type: 'Bearer'
}));

assert.throws(() => {
scope.done();
Expand Down Expand Up @@ -258,7 +260,7 @@ describe('OAuth2 client', () => {
const res = await oauth2client.revokeCredentials();
scope.done();
assert.strictEqual(res.data.success, true);
assert.deepEqual(oauth2client.credentials, {});
assert.deepStrictEqual(oauth2client.credentials, {});
});

it('should clear credentials and return error if no access token to revoke',
Expand All @@ -269,7 +271,7 @@ describe('OAuth2 client', () => {
await assertRejects(
oauth2client.revokeCredentials(),
/Error: No access token to revoke./);
assert.deepEqual(oauth2client.credentials, {});
assert.deepStrictEqual(oauth2client.credentials, {});
});
});

Expand Down

0 comments on commit 7090641

Please sign in to comment.