A PowerShell port of httpunit.
This is not a 100% accurate port of httpunit.
The goal of this module is to utilize Net.Http.HttpClient
to more closely simulate a .Net client application.
It also provides easy access to the Windows Certificate store for client certificate authentication.
Install-Module -Name httpunitPS
or Install-PSResource -Name httpunitPS
TOML, YAML, JSON, and PSD1 formats are supported for the config file.
Each plan
can have:
label
A label for documentation purposes.url
The URL to retrieve.ips
For http/https, a list of IPs to send the URL to. Default is "use DNS". Otherwise the connection is made to the IP address listed, ignoring DNS. Pass'*'
to test all resolved addresses.code
For http/https, the expected status code, default 200.string
For http/https, a string we expect to find in the result.timeout
An optional timeout for the test in the format"hh:mm:ss"
. Default is 3 seconds.certificate
For http/https, a path to a certificate in the Windows Store to pass as a Client Certificate. If just a Thumbprint is provided, it will look incert:\LocalMachine\My
.tags
An optional list of tags for the test. Used for when you want to only run a subset of tests with the-tags
flag.insecureSkipVerify
Will allow testing of untrusted or self-signed certificates.plan.headers
For http/https, a list of keys and values to validate the response headers.
[[plan]]
label = "google"
url = "https://www.google.com"
code = 200
timeout = "0:0:10"
[plan.headers]
Server = "gws"
Plan:
- code: 200
label: google
timeout: "0:0:10"
url: https://www.google.com
tags: [run]
The SSLCertificate commands may be moved to a separate module in the future.
- Get-SSLCertificate Get the SSL Certificate for given host.
- Show-SSLCertificateUI Displays a dialog box with detailed information about the specified x509 certificate.
- Test-SSLCertificate Test the validitiy of a given certificate.
PS > Get-SSLCertificate expired.badssl.com | Test-SSLCertificate -ErrorVariable validation
False
Validation failures produces an error message.
Test-SSLCertificate: Certificate failed chain validation:
A required certificate is not within its validity period when verifying against the current system clock or the timestamp in the signed file.
Inspect the certificate chain inside the ErrorRecord.
PS > $validation.TargetObject.ChainElements.Certificate
Thumbprint Subject EnhancedKeyUsageList
---------- ------- --------------------
404BBD2F1F4CC2FDEEF13AABDD523EF61F1C71F3 CN=*.badssl.com, OU… {Server Authentication, Client Authentication}
339CDD57CFD5B141169B615FF31428782D1DA639 CN=COMODO RSA Domai… {Server Authentication, Client Authentication}
AFE5D244A8D1194230FF479FE2F897BBCD7A8CB4 CN=COMODO RSA Certi…