fix: pass proxy credentials to binary download (fixes #164) - #183
Open
Arunendra21 wants to merge 1 commit into
Open
fix: pass proxy credentials to binary download (fixes #164)#183Arunendra21 wants to merge 1 commit into
Arunendra21 wants to merge 1 commit into
Conversation
browserstack-local-nodejs accepts proxyUser/proxyPass and forwards them to the BrowserStackLocal binary, but LocalBinary.download() built the HttpsProxyAgent with only host and port. Behind a proxy that requires authentication the binary download failed with 407 even when valid credentials were supplied. Include the credentials via the agent's auth option when both proxyUser and proxyPass are present, and add tests for the authenticated and unauthenticated cases. Fixes browserstack#164
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
browserstack-local-nodejsalready acceptsproxyUser/proxyPassand forwards them to theBrowserStackLocalbinary as--proxy-user/--proxy-pass(seeLocal.js). However, when the library downloads the binary itself,LocalBinary.download()builds theHttpsProxyAgentwith onlyhostandport:So behind a proxy that requires authentication, the binary download fails with
407 Proxy Authentication Requiredeven when the user has supplied valid proxy credentials. This is #164.Fix
Include the credentials in the proxy agent options when both
proxyUserandproxyPassare provided.https-proxy-agent@^5(the version already used here) accepts anauth: "user:pass"option, which it sends as theProxy-Authorizationheader:The change is scoped to the download path and only adds
authwhen both credentials are present, so existing unauthenticated-proxy and no-proxy behaviour is unchanged.Tests
Added two tests to
test/local.js(they stubhttps.get, so no network is required):auth: "user:pass".authis set (behaviour unchanged).Fixes #164