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

WebRequest - Fix use_proxy: no on module options #68603

Merged
merged 2 commits into from Apr 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
2 changes: 2 additions & 0 deletions changelogs/fragments/win-web-request-no_proxy.yaml
@@ -0,0 +1,2 @@
bugfixes:
- 'Ansible.ModuleUtils.WebRequest - actually set no proxy when ``use_proxy: no`` is set on a Windows module - https://github.com/ansible/ansible/issues/68528'
Expand Up @@ -272,10 +272,10 @@ Function Get-AnsibleWebRequest {
} else {
$proxy.Credentials = $null
}

$web_request.Proxy = $proxy
}

$web_request.Proxy = $proxy

# Some parameters only apply when dealing with a HttpWebRequest
if ($web_request -is [System.Net.HttpWebRequest]) {
if ($Headers) {
Expand Down
Expand Up @@ -436,6 +436,25 @@ $tests = [Ordered]@{
} | ConvertFrom-Json
$actual.headers.'User-Agent' | Assert-Equals -Expected 'actual-agent'
}

'Web request with default proxy' = {
$params = @{
Uri = "https://$httpbin_host/get"
}
$r = Get-AnsibleWebRequest @params

$null -ne $r.Proxy | Assert-Equals -Expected $true
}

'Web request with no proxy' = {
$params = @{
Uri = "https://$httpbin_host/get"
UseProxy = $false
}
$r = Get-AnsibleWebRequest @params

$null -eq $r.Proxy | Assert-Equals -Expected $true
}
}

# setup and teardown should favour native tools to create and delete the service and not the util we are testing.
Expand Down