mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
win_uri: Add integration tests, new functionality... (#25373)
This is a cleanup of the win_uri module to make it feature-complete. This PR includes: - Added check-mode support - Add as many options from the uri module as possible - Added creates - Added follow_redirects - Added maximum_redirection - Added password - Added removes - Added return_content - Added status_code - Added timeout - Added user - Added validate_certs - Fixed list-handling for comma-separated strings - Added basic integration tests (should come from uri module)
This commit is contained in:
parent
a4ebde1516
commit
0aba04fdad
4 changed files with 225 additions and 66 deletions
36
test/integration/targets/uri/files/testserver.ps1
Normal file
36
test/integration/targets/uri/files/testserver.ps1
Normal file
|
@ -0,0 +1,36 @@
|
|||
param (
|
||||
[int]$port = 8000,
|
||||
)
|
||||
|
||||
$listener = New-Object Net.HttpListener
|
||||
$listener.Prefixes.Add("http://+:$port/")
|
||||
$listener.Start()
|
||||
|
||||
try {
|
||||
while ($listener.IsListening) {
|
||||
# process received request
|
||||
$context = $listener.GetContext()
|
||||
$Request = $context.Request
|
||||
$Response = $context.Response
|
||||
#$Response.Headers.Add("Content-Type","text/plain")
|
||||
|
||||
$received = '{0} {1}' -f $Request.httpmethod, $Request.url.localpath
|
||||
|
||||
# is there HTML content for this URL?
|
||||
$html = $htmlcontents[$received]
|
||||
if ($html -eq $null) {
|
||||
$Response.statuscode = 404
|
||||
$html = 'Oops, the page is not available!'
|
||||
}
|
||||
|
||||
# return the HTML to the caller
|
||||
$buffer = [Text.Encoding]::UTF8.GetBytes($html)
|
||||
$Response.ContentLength64 = $buffer.length
|
||||
$Response.OutputStream.Write($buffer, 0, $buffer.length)
|
||||
|
||||
$Response.Close()
|
||||
}
|
||||
} finally {
|
||||
$listener.Stop()
|
||||
$listener.Close()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue