Skip to content

Commit

Permalink
fix: do not warn for SDK creds (#905)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Mar 1, 2020
1 parent d576aa7 commit 9536840
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 49 deletions.
12 changes: 0 additions & 12 deletions src/auth/googleauth.ts
Expand Up @@ -379,7 +379,6 @@ export class GoogleAuth {
location,
options
);
this.warnOnProblematicCredentials(client as JWT);
return client;
}

Expand Down Expand Up @@ -418,17 +417,6 @@ export class GoogleAuth {
return this.fromStream(readStream, options);
}

/**
* Credentials from the Cloud SDK that are associated with Cloud SDK's project
* are problematic because they may not have APIs enabled and have limited
* quota. If this is the case, warn about it.
*/
protected warnOnProblematicCredentials(client: JWT) {
if (client.email === CLOUD_SDK_CLIENT_ID) {
messages.warn(messages.PROBLEMATIC_CREDENTIALS_WARNING);
}
}

/**
* Create a credentials instance using the given input options.
* @param json The input object.
Expand Down
13 changes: 0 additions & 13 deletions src/messages.ts
Expand Up @@ -41,19 +41,6 @@ export interface Warning {
warned?: boolean;
}

export const PROBLEMATIC_CREDENTIALS_WARNING = {
code: 'google-auth-library:00001',
type: WarningTypes.WARNING,
message: [
'Your application has authenticated using end user credentials from Google',
'Cloud SDK. We recommend that most server applications use service accounts',
'instead. If your application continues to use end user credentials from',
'Cloud SDK, you might receive a "quota exceeded" or "API not enabled" error.',
'For more information about service accounts, see',
'https://cloud.google.com/docs/authentication/.',
].join(' '),
};

export const DEFAULT_PROJECT_ID_DEPRECATED = {
code: 'google-auth-library:DEP002',
type: WarningTypes.DEPRECATION,
Expand Down
24 changes: 0 additions & 24 deletions test/test.googleauth.ts
Expand Up @@ -1407,30 +1407,6 @@ describe('googleauth', () => {
assert.strictEqual(value, signature);
});

// tslint:disable-next-line ban
it.skip('should warn the user if using default Cloud SDK credentials', done => {
exposeLinuxWellKnownFile = true;
createLinuxWellKnownStream = () =>
fs.createReadStream('./test/fixtures/wellKnown.json');
sandbox
.stub(process, 'emitWarning')
.callsFake((message, warningOrType) => {
assert.strictEqual(
message,
messages.PROBLEMATIC_CREDENTIALS_WARNING.message
);
const warningType =
typeof warningOrType === 'string'
? warningOrType
: // @types/node doesn't recognize the emitWarning syntax which
// tslint:disable-next-line no-any
(warningOrType as any).type;
assert.strictEqual(warningType, messages.WarningTypes.WARNING);
done();
});
auth._tryGetApplicationCredentialsFromWellKnownFile();
});

it('should warn the user if using the getDefaultProjectId method', done => {
mockEnvVar('GCLOUD_PROJECT', STUB_PROJECT);
sandbox
Expand Down

0 comments on commit 9536840

Please sign in to comment.