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

fix: do not warn for SDK creds #905

Merged
merged 1 commit into from Mar 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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