#include "net/dns/public/doh_provider_entry.h"
#include <set>
#include <string>
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gtest/include/gtest/gtest-death-test.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
namespace {
TEST(DohProviderListTest, GetDohProviderList) {
const DohProviderEntry::List& list = DohProviderEntry::GetList();
EXPECT_FALSE(list.empty());
}
TEST(DohProviderListTest, ProviderNamesAreUnique) {
base::flat_set<std::string_view> names;
for (const DohProviderEntry* entry : DohProviderEntry::GetList()) {
EXPECT_FALSE(entry->provider.empty());
auto [_, did_insert] = names.insert(entry->provider);
EXPECT_TRUE(did_insert);
}
}
TEST(DohProviderListTest, UiNamesAreUniqueOrEmpty) {
std::set<std::string_view> ui_names;
for (const DohProviderEntry* entry : DohProviderEntry::GetList()) {
if (entry->ui_name.empty())
continue;
auto [_, did_insert] = ui_names.insert(entry->ui_name);
EXPECT_TRUE(did_insert) << "UI name was not unique: " << entry->ui_name;
}
}
TEST(DohProviderListTest, NonEmptyDnsOverTlsHostnames) {
for (const DohProviderEntry* entry : DohProviderEntry::GetList()) {
SCOPED_TRACE(entry->provider);
for (const auto s : entry->dns_over_tls_hostnames) {
EXPECT_FALSE(s.empty());
}
}
}
}
}