Commit 04102856 authored by Allen Vicencio's avatar Allen Vicencio Committed by Commit Bot

Store hosts found in NetworkScanner as lowercase

Stores the hosts found in NetworkScanner as lower case in order to
do URL resolving

Bug: 757625
Change-Id: I791072ecb07d9afb03aa2ba75aacedffcddcd5b0
Reviewed-on: https://chromium-review.googlesource.com/1097707
Commit-Queue: Allen Vicencio <allenvic@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567325}
parent dd957d67
......@@ -84,11 +84,11 @@ void NetworkScanner::AddHostsToResults(uint32_t request_id,
HostMap& existing_hosts = request_iter->second.hosts_found;
for (const auto& new_host : new_hosts) {
const Hostname& new_hostname = new_host.first;
const Hostname& new_hostname = base::ToLowerASCII(new_host.first);
const Address& new_ip = new_host.second;
if (!HostExists(existing_hosts, new_hostname)) {
existing_hosts.insert(new_host);
existing_hosts.insert(std::pair<Hostname, Address>(new_hostname, new_ip));
} else if (existing_hosts[new_hostname] != new_ip) {
LOG(WARNING) << "Different addresses found for host: " << new_hostname;
LOG(WARNING) << existing_hosts[new_hostname] << ":" << new_ip;
......
......@@ -176,5 +176,24 @@ TEST_F(NetworkScannerTest, ResolveHostWithUppercaseHost) {
ExpectResolvedHostEquals("1.2.3.4", "SHARE1");
}
TEST_F(NetworkScannerTest, HostsAreStoredAsLowercase) {
HostMap hosts;
hosts["SHARE1"] = "1.2.3.4";
hosts["sHaRe2"] = "11.12.13.14";
hosts["Share3"] = "21.22.23.24";
RegisterHostLocatorWithHosts(hosts);
// expected_hosts should have all lowercase hosts.
HostMap expected_hosts;
expected_hosts["share1"] = "1.2.3.4";
expected_hosts["share2"] = "11.12.13.14";
expected_hosts["share3"] = "21.22.23.24";
ExpectHostMapEqual(expected_hosts);
ExpectResolvedHostEquals("1.2.3.4", "share1");
ExpectResolvedHostEquals("11.12.13.14", "share2");
ExpectResolvedHostEquals("21.22.23.24", "share3");
}
} // namespace smb_client
} // namespace chromeos
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment