Skip to content

Commit

Permalink
WebRequest - Fix use_proxy: no on module options (ansible#68603)
Browse files Browse the repository at this point in the history
* WebRequest - Fix use_proxy: no on module options

* Fix up changelog fragment
  • Loading branch information
jborean93 authored Apr 1, 2020
1 parent e785bda commit ae1cd27
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/win-web-request-no_proxy.yaml
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit ae1cd27

Please sign in to comment.