mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Fix GetFullyQualifiedName() (#1915)
Don't expect GetComputerName() (hostname) and FQDN to be the same. They may not be!
This commit is contained in:
1 parent
e7a6b314fc
commit
550a21e40e
1 file changed
+9
-16
@@ -13,25 +13,18 @@
|
||||
TEST(GetFullyQualifiedNameTest, ValidateLinuxGetFullyQualifiedDomainName)
|
||||
{
|
||||
std::string actual(GetFullyQualifiedName());
|
||||
|
||||
std::string hostname(GetComputerName());
|
||||
|
||||
// FQDN starts with hostname (which may be fully qualified)
|
||||
EXPECT_LE(hostname, actual);
|
||||
struct addrinfo hints, *info;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
EXPECT_FALSE(getaddrinfo(hostname.c_str(), "http", &hints, &info));
|
||||
|
||||
// hostname did not include domain name, so test it separately
|
||||
if (hostname < actual)
|
||||
{
|
||||
struct addrinfo hints, *info;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
EXPECT_FALSE(getaddrinfo(hostname.c_str(), "http", &hints, &info));
|
||||
// Compare canonical name to FQDN
|
||||
EXPECT_STREQ(info->ai_canonname, actual.c_str());
|
||||
|
||||
// Compare canonical name to FQDN
|
||||
EXPECT_STREQ(info->ai_canonname, actual.c_str());
|
||||
freeaddrinfo(info);
|
||||
|
||||
freeaddrinfo(info);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user