1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/dns/public/doh_provider_entry.h"
6
7 #include <set>
8 #include <string>
9
10 #include "testing/gmock/include/gmock/gmock-matchers.h"
11 #include "testing/gtest/include/gtest/gtest-death-test.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13
14 namespace net {
15 namespace {
16
TEST(DohProviderListTest,GetDohProviderList)17 TEST(DohProviderListTest, GetDohProviderList) {
18 const DohProviderEntry::List& list = DohProviderEntry::GetList();
19 EXPECT_FALSE(list.empty());
20 }
21
TEST(DohProviderListTest,ProviderNamesAreUnique)22 TEST(DohProviderListTest, ProviderNamesAreUnique) {
23 std::set<std::string> names;
24 for (const DohProviderEntry* entry : DohProviderEntry::GetList()) {
25 EXPECT_FALSE(entry->provider.empty());
26 auto [_, did_insert] = names.insert(entry->provider);
27 EXPECT_TRUE(did_insert);
28 }
29 }
30
TEST(DohProviderListTest,UiNamesAreUniqueOrEmpty)31 TEST(DohProviderListTest, UiNamesAreUniqueOrEmpty) {
32 std::set<std::string> ui_names;
33 for (const DohProviderEntry* entry : DohProviderEntry::GetList()) {
34 if (entry->ui_name.empty())
35 continue;
36 auto [_, did_insert] = ui_names.insert(entry->ui_name);
37 EXPECT_TRUE(did_insert) << "UI name was not unique: " << entry->ui_name;
38 }
39 }
40
TEST(DohProviderListTest,NonEmptyDnsOverTlsHostnames)41 TEST(DohProviderListTest, NonEmptyDnsOverTlsHostnames) {
42 for (const DohProviderEntry* entry : DohProviderEntry::GetList()) {
43 SCOPED_TRACE(entry->provider);
44 for (const std::string& s : entry->dns_over_tls_hostnames) {
45 EXPECT_FALSE(s.empty());
46 }
47 }
48 }
49
50 } // namespace
51 } // namespace net
52