CFINSPEC-90: Correct existing unit test for windows to include ipv6 address

Signed-off-by: Sonu Saha <sonu.saha@progress.com>
This commit is contained in:
Sonu Saha 2022-05-07 00:22:12 +05:30
parent 1200638c84
commit 72a986ace3
3 changed files with 15 additions and 2 deletions

12
test/fixtures/cmd/Resolve-DnsName-ipv6 vendored Normal file
View file

@ -0,0 +1,12 @@
{
"IP6Address": "2404:6800:4009:827::200e",
"Name": "microsoft.com",
"Type": 28,
"CharacterSet": 1,
"Section": 1,
"DataLength": 16,
"TTL": 176,
"Address": "2404:6800:4009:827::200e",
"IPAddress": "2404:6800:4009:827::200e",
"QueryType": 28
}

View file

@ -366,6 +366,7 @@ class MockLoader
"Get-NetAdapterBinding -ComponentID ms_bridge | Get-NetAdapter | Select-Object -Property Name, InterfaceDescription | ConvertTo-Json" => cmd.call("get-netadapter-binding-bridge"),
# host for Windows
"Resolve-DnsName Type A microsoft.com | ConvertTo-Json" => cmd.call("Resolve-DnsName"),
"Resolve-DnsName Type AAAA microsoft.com | ConvertTo-Json" => cmd.call("Resolve-DnsName-ipv6"),
"Test-NetConnection -ComputerName microsoft.com -WarningAction SilentlyContinue| Select-Object -Property ComputerName, TcpTestSucceeded, PingSucceeded | ConvertTo-Json" => cmd.call("Test-NetConnection"),
# host for Linux
"getent ahosts example.com" => cmd.call("getent-ahosts-example.com"),

View file

@ -32,7 +32,7 @@ describe "Inspec::Resources::Host" do
resource = MockLoader.new(:windows).load_resource("host", "microsoft.com")
_(resource.resolvable?).must_equal true
_(resource.reachable?).must_equal false
_(resource.ipaddress).must_equal ["134.170.185.46", "134.170.188.221"]
_(resource.ipaddress).must_equal ["134.170.188.221", "2404:6800:4009:827::200e"]
_(resource.to_s).must_equal "Host microsoft.com"
end
@ -96,7 +96,7 @@ describe "Inspec::Resources::Host" do
resource = MockLoader.new(:windows).load_resource("host", "microsoft.com", port: 1234, protocol: "tcp")
_(resource.resolvable?).must_equal true
_(resource.reachable?).must_equal true
_(resource.ipaddress).must_equal ["134.170.185.46", "134.170.188.221"]
_(resource.ipaddress).must_equal ["134.170.188.221", "2404:6800:4009:827::200e"]
_(resource.to_s).must_equal "Host microsoft.com port 1234 proto tcp"
end