src/net/dns/record_rdata_unittest.cc
TEST(RecordRdataTest, ParseEsniRecordOneIPv4Address) {
  // ESNI record:
  // well-formed ESNI keys
  // extensions length
  // extension
  char record[10000] = {};
  base::BigEndianWriter writer(record, sizeof(record));
  AppendWellFormedEsniKeys(&writer);

  std::vector<uint8_t> address_list;
  std::vector<IPAddress> addresses_for_validation;

  AppendAnotherIPAddress(&address_list, &addresses_for_validation,
                         4 /* ip_version */);

  AppendDnsExtensionsBlock(&writer, address_list);

  auto record_size = writer.ptr() - record;
  DnsRecordParser parser(record, record_size, 0 /* offset */);

  std::unique_ptr<EsniRecordRdata> record_obj =
      EsniRecordRdata::Create(std::string(record, record_size), parser);
  ASSERT_THAT(record_obj, NotNull());

  const auto& addresses = record_obj->addresses();

  EXPECT_EQ(addresses, addresses_for_validation);

  EXPECT_TRUE(record_obj->IsEqual(record_obj.get()));
  ExpectMatchesSampleKeys(record_obj->esni_keys());
}
// Test parsing a well-formed ESNI record bearing an address_set extension
// containing a single IPv4 address.
Test parsing a well-formed ESNI record bearing an address_set extension
containing a single IPv4 address.
Test parsing a well - formed ESNI record bearing an address_set extension containing a single IPv4 address .
TEST(RecordRdataTest, ParseEsniRecordOneIPv4Address) {
  char record[10000] = {};
  base::BigEndianWriter writer(record, sizeof(record));
  AppendWellFormedEsniKeys(&writer);
  std::vector<uint8_t> address_list;
  std::vector<IPAddress> addresses_for_validation;
  AppendAnotherIPAddress(&address_list, &addresses_for_validation,
                         4 );
  AppendDnsExtensionsBlock(&writer, address_list);
  auto record_size = writer.ptr() - record;
  DnsRecordParser parser(record, record_size, 0 );
  std::unique_ptr<EsniRecordRdata> record_obj =
      EsniRecordRdata::Create(std::string(record, record_size), parser);
  ASSERT_THAT(record_obj, NotNull());
  const auto& addresses = record_obj->addresses();
  EXPECT_EQ(addresses, addresses_for_validation);
  EXPECT_TRUE(record_obj->IsEqual(record_obj.get()));
  ExpectMatchesSampleKeys(record_obj->esni_keys());
}
TEST ( RecordRdataTest , ParseEsniRecordOneIPv4Address ) { char record [ 10000 ] = { } ; base :: BigEndianWriter writer ( record , sizeof ( record ) ) ; AppendWellFormedEsniKeys ( & writer ) ; std :: vector < uint8_t > address_list ; std :: vector < IPAddress > addresses_for_validation ; AppendAnotherIPAddress ( & address_list , & addresses_for_validation , 4 ) ; AppendDnsExtensionsBlock ( & writer , address_list ) ; auto record_size = writer . ptr ( ) - record ; DnsRecordParser parser ( record , record_size , 0 ) ; std :: unique_ptr < EsniRecordRdata > record_obj = EsniRecordRdata :: Create ( std :: string ( record , record_size ) , parser ) ; ASSERT_THAT ( record_obj , NotNull ( ) ) ; const auto & addresses = record_obj -> addresses ( ) ; EXPECT_EQ ( addresses , addresses_for_validation ) ; EXPECT_TRUE ( record_obj -> IsEqual ( record_obj . get ( ) ) ) ; ExpectMatchesSampleKeys ( record_obj -> esni_keys ( ) ) ; }
Test parsing a well-formed ESNI record bearing an address_set extension
containing a single IPv4 address.
Test parsing a well - formed ESNI record bearing an address_set extension containing a single IPv4 address .
// ESNI record: // well-formed ESNI keys // extensions length // extension /* ip_version */ /* offset */