dns_ut.cpp 824 B

12345678910111213141516171819202122232425
  1. #include <library/cpp/testing/unittest/registar.h>
  2. #include <library/cpp/dns/cache.h>
  3. #include <util/network/address.h>
  4. Y_UNIT_TEST_SUITE(TestDNS) {
  5. using namespace NDns;
  6. Y_UNIT_TEST(TestMagic) {
  7. UNIT_ASSERT_EXCEPTION(CachedThrResolve(TResolveInfo("?", 80)), yexception);
  8. }
  9. Y_UNIT_TEST(TestAsteriskAlias) {
  10. AddHostAlias("*", "localhost");
  11. const TResolvedHost* rh = CachedThrResolve(TResolveInfo("yandex.ru", 80));
  12. UNIT_ASSERT(rh != nullptr);
  13. const TNetworkAddress& addr = rh->Addr;
  14. for (TNetworkAddress::TIterator ai = addr.Begin(); ai != addr.End(); ai++) {
  15. if (ai->ai_family == AF_INET || ai->ai_family == AF_INET6) {
  16. NAddr::TAddrInfo info(&*ai);
  17. UNIT_ASSERT(IsLoopback(info));
  18. }
  19. }
  20. }
  21. }