Skip to content

Commit

Permalink
fix: add warning when no proxy env vars are set (#850)
Browse files Browse the repository at this point in the history
* fix: add warnings when using the no proxy env vars

* chore: update tests
  • Loading branch information
shetzel authored Aug 28, 2024
1 parent d486f18 commit 99fef04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
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

0 comments on commit 99fef04

Please sign in to comment.