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: add warning when no proxy env vars are set #850

Merged
merged 2 commits into from
Aug 28, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions messages/diagnostics.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ Uninstall the deprecated Salesforce CLI (%s) version %s and install the @salesfo
# matchProxyEnvVarSuggestion

Modify the values for %s and %s environment variables to match.

# noProxyEnvVarSet

Warning: The CLI does not fully support the "no_proxy" and "NO_PROXY" environment variables and could cause connection issues when running commands.
5 changes: 5 additions & 0 deletions src/diagnostics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ export class Diagnostics {
testName: 'no_proxy and NO_PROXY environment variables match',
status: noProxyEnvVarStatus,
});
await Lifecycle.getInstance().emit('Doctor:diagnostic', {
testName: 'no_proxy and/or NO_PROXY environment variables set',
status: 'warn',
});
this.doctor.addSuggestion(messages.getMessage('noProxyEnvVarSet'));
}

if (httpProxyEnvVarStatus === 'fail') {
Expand Down
12 changes: 6 additions & 6 deletions test/diagnostics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ describe('Diagnostics', () => {
const diagnostics = new Diagnostics(dr, oclifConfig);
await diagnostics.proxyEnvVarsCheck();

expect(lifecycleEmitSpy.callCount, 'Expected "Doctor:diagnostic" event fired 3 times').to.equal(3);
expect(drAddSuggestionSpy.called, 'Expected no suggestions to be added').to.be.false;
expect(lifecycleEmitSpy.callCount, 'Expected "Doctor:diagnostic" event fired 4 times').to.equal(4);
expect(drAddSuggestionSpy.callCount, 'Expected suggestion to be added for no_proxy').to.equal(1);
});

it('passes with proxy env vars in only lowercase', async () => {
Expand All @@ -144,8 +144,8 @@ describe('Diagnostics', () => {
const diagnostics = new Diagnostics(dr, oclifConfig);
await diagnostics.proxyEnvVarsCheck();

expect(lifecycleEmitSpy.callCount, 'Expected "Doctor:diagnostic" event fired 3 times').to.equal(3);
expect(drAddSuggestionSpy.called, 'Expected no suggestions to be added').to.be.false;
expect(lifecycleEmitSpy.callCount, 'Expected "Doctor:diagnostic" event fired 4 times').to.equal(4);
expect(drAddSuggestionSpy.callCount, 'Expected suggestion to be added for no_proxy').to.equal(1);
});

it('fails with non-matching proxy env vars', async () => {
Expand All @@ -163,8 +163,8 @@ describe('Diagnostics', () => {
const diagnostics = new Diagnostics(dr, oclifConfig);
await diagnostics.proxyEnvVarsCheck();

expect(lifecycleEmitSpy.callCount, 'Expected "Doctor:diagnostic" event fired 3 times').to.equal(3);
expect(drAddSuggestionSpy.callCount, 'Expected 3 suggestions to be added').to.equal(3);
expect(lifecycleEmitSpy.callCount, 'Expected "Doctor:diagnostic" event fired 4 times').to.equal(4);
expect(drAddSuggestionSpy.callCount, 'Expected 4 suggestions to be added').to.equal(4);
});
});

Expand Down