Skip to content

Adding support for a custom proxy input - #218

Merged
Arthur Araujo (arthuraraujo-msft) merged 7 commits into
mainfrom
user/arthuraraujo/proxy-input
Dec 5, 2024
Merged

Arthur Araujo (arthuraraujo-msft) merged 7 commits into
mainfrom
user/arthuraraujo/proxy-input

Conversation

@arthuraraujo-msft

Copy link
Copy Markdown
Contributor

Related Issues

Why is this change being made?

WinGet has a feature where a user can specify a proxy string. Some users of winget download are interested in using the feature so they can use a proxy to bypass enterprise blocking of the service URL, and sfs client would need to support the proxy string in its network connection layer.

For the curl implementation inside the client, that means passing in a string to CURLOPT_PROXY setting.

This PR is implementing support for a new input parameter for a request to supply a custom proxy.

What is being changed?

  • A caller can now specify a std::optional<std::string> proxy argument on requestParams in the Client APIs. The correspondent request will use that proxy when connecting to the service to get product information.
  • The implementation happens in the Curl connection layer, where the proxy string is passed to CURLOPT_PROXY setting
  • For testing:
    • I've implemented a simple ProxyServer class reusing the model for the MockWebServer class and the cpp-httplib library. It just redirects GET and POST requests to the original server target URL.
    • I've added unit tests for validating that CURL accepts only valid proxy strings.
    • I've added functional tests using the new proxy server.

How was the change tested?

New tests are being added as mentioned above.

Comment thread client/tests/mock/ServerCommon.cpp Fixed
Comment thread client/src/details/UrlBuilder.cpp Resolved
@shishirb-MSFT

Copy link
Copy Markdown

Merging directly to main? No develop branch? I see winget waiting for this fix.. will they validate your proxy support in winget before you make an official release?

@arthuraraujo-msft

Copy link
Copy Markdown
Contributor Author

Merging directly to main? No develop branch? I see winget waiting for this fix.. will they validate your proxy support in winget before you make an official release?

Yeah, our philosophy is that main is always building & working, but API users should be picking up from release-tagged commits. Thus, pushing to main should not affect a user immediately. They should run validation before integrating a new release.

The PM who's interested in the feature has already validated it internally using our PR and a modification they made to winget (microsoft/winget-cli#5030) and said it's working fine.
WinGet should still do extra tests before committing the version change after we release.

@arthuraraujo-msft
Arthur Araujo (arthuraraujo-msft) deleted the user/arthuraraujo/proxy-input branch December 5, 2024 21:40
@arthuraraujo-msft Arthur Araujo (arthuraraujo-msft) linked an issue Dec 6, 2024 that may be closed by this pull request
1 task
Nicolas Dietrich (nidietr-MSFT) added a commit to nidietr-MSFT/winget-cli that referenced this pull request Dec 10, 2024
Requires ingesting sfs-client update from
microsoft/sfs-client#218
JohnMcPMS added a commit to microsoft/winget-cli that referenced this pull request Dec 10, 2024
Pulling SfsClient subtree release 1.1.0
[SfsClient Release
1.1.0](https://github.com/microsoft/sfs-client/releases/tag/1.1.0)

Which brought especially
[SfsClient - Client: proxy support
#84](microsoft/sfs-client#218)

This subtree update is required for WinGet Download Proxy support 
[WinGet download doesn't work through a proxy
#5030](#5030)

Also requires passing the appropriate proxy to SfsClient which is done
as part of separate PR
[Allows setting WinGet proxy setting as SFS Client Proxy
#5032](#5032)
JohnMcPMS pushed a commit to microsoft/winget-cli that referenced this pull request Dec 11, 2024
Allows setting WinGet proxy setting as the SFS Client Proxy.

Fixes the issue below
[WinGet download doesn't work through a proxy
#5030](#5030)

This PR requires SfsClient subtree updated to 1.1.0
[SfsClient update 1.1.0 for proxy support
#5052](#5052)

Which brings especially
[Adding support for a custom proxy input
#218](microsoft/sfs-client#218)

This PR replaces closed PR below
[Allows setting WinGet proxy setting as SFS Client Proxy
#5032](#5032)

<!-- To check a checkbox place an "x" between the brackets. e.g: [x] -->

- [x] I have signed the [Contributor License
Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs).
- [x] This pull request is related to an issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a way for caller to pass a proxy to be used in the connection Fix code scanning alert #54

3 participants