@@ -6,7 +6,7 @@ use Cwd qw(cwd);
6
6
7
7
repeat_each(2 );
8
8
9
- plan tests => repeat_each() * (3 * blocks() + 14 );
9
+ plan tests => repeat_each() * (3 * blocks() + 16 );
10
10
11
11
my $ pwd = cwd();
12
12
@@ -1421,3 +1421,96 @@ records: [{"class":1,"name":"www.google.com","ttl":123456,"txt":["hello","world!
1421
1421
-- - no_error_log
1422
1422
[error]
1423
1423
1424
+
1425
+
1426
+ === TEST 30 : single answer reply, good A answer (AD is set)
1427
+ -- - http_config eval: $::HttpConfig
1428
+ -- - config
1429
+ location / t {
1430
+ content_by_lua '
1431
+ local resolver = require "resty.dns.resolver"
1432
+
1433
+ local r, err = resolver:new{
1434
+ nameservers = { {"127.0.0.1", 1953} }
1435
+ }
1436
+ if not r then
1437
+ ngx.say("failed to instantiate resolver: ", err)
1438
+ return
1439
+ end
1440
+
1441
+ r._id = 125
1442
+
1443
+ local ans, err = r:query("www.google.com", { qtype = r.TYPE_A })
1444
+ if not ans then
1445
+ ngx.say("failed to query: ", err)
1446
+ return
1447
+ end
1448
+
1449
+ local cjson = require "cjson"
1450
+ ngx.say("records: ", cjson.encode(ans))
1451
+ ' ;
1452
+ }
1453
+ -- - udp_listen: 1953
1454
+ -- - udp_reply dns
1455
+ {
1456
+ id => 125 ,
1457
+ opcode => 0 ,
1458
+ qname => ' www.google.com' ,
1459
+ ad => 1 ,
1460
+ answer => [{ name => " www.google.com" , ipv4 => " 127.0.0.1" , ttl => 123456 }],
1461
+ }
1462
+ -- - request
1463
+ GET / t
1464
+ -- - udp_query eval
1465
+ " \x{ 00 } }\x{ 01 } \x{ 00 } \x{ 00 } \x{ 01 } \x{ 00 } \x{ 00 } \x{ 00 } \x{ 00 } \x{ 00 } \x{ 00 } \x{ 03 } www\x{ 06 } google\x{ 03 } com\x{ 00 } \x{ 00 } \x{ 01 } \x{ 00 } \x{ 01 } "
1466
+ -- - response_body
1467
+ records: [{" address" : " 127.0.0.1" ," type" : 1 ," class" : 1 ," name" : " www.google.com" ," ttl" : 123456 }]
1468
+ -- - no_error_log
1469
+ [error]
1470
+
1471
+
1472
+
1473
+ === TEST 31 : single answer reply, good A answer (CD is set)
1474
+ -- - http_config eval: $::HttpConfig
1475
+ -- - config
1476
+ location / t {
1477
+ content_by_lua '
1478
+ local resolver = require "resty.dns.resolver"
1479
+
1480
+ local r, err = resolver:new{
1481
+ nameservers = { {"127.0.0.1", 1953} }
1482
+ }
1483
+ if not r then
1484
+ ngx.say("failed to instantiate resolver: ", err)
1485
+ return
1486
+ end
1487
+
1488
+ r._id = 125
1489
+
1490
+ local ans, err = r:query("www.google.com", { qtype = r.TYPE_A })
1491
+ if not ans then
1492
+ ngx.say("failed to query: ", err)
1493
+ return
1494
+ end
1495
+
1496
+ local cjson = require "cjson"
1497
+ ngx.say("records: ", cjson.encode(ans))
1498
+ ' ;
1499
+ }
1500
+ -- - udp_listen: 1953
1501
+ -- - udp_reply dns
1502
+ {
1503
+ id => 125 ,
1504
+ opcode => 0 ,
1505
+ qname => ' www.google.com' ,
1506
+ cd => 1 ,
1507
+ answer => [{ name => " www.google.com" , ipv4 => " 127.0.0.1" , ttl => 123456 }],
1508
+ }
1509
+ -- - request
1510
+ GET / t
1511
+ -- - udp_query eval
1512
+ " \x{ 00 } }\x{ 01 } \x{ 00 } \x{ 00 } \x{ 01 } \x{ 00 } \x{ 00 } \x{ 00 } \x{ 00 } \x{ 00 } \x{ 00 } \x{ 03 } www\x{ 06 } google\x{ 03 } com\x{ 00 } \x{ 00 } \x{ 01 } \x{ 00 } \x{ 01 } "
1513
+ -- - response_body
1514
+ records: [{" address" : " 127.0.0.1" ," type" : 1 ," class" : 1 ," name" : " www.google.com" ," ttl" : 123456 }]
1515
+ -- - no_error_log
1516
+ [error]
0 commit comments