From 431f86f41406380d712da9cc4a23880bbb2bc916 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Fri, 21 Dec 2018 12:10:19 +0100 Subject: [PATCH] Make tests aware of NODATA == NO_NAME change --- src/test/check_getdns_address.h | 2 +- src/test/check_getdns_address_sync.h | 3 ++- src/test/check_getdns_common.c | 9 ++++++++- src/test/check_getdns_general.h | 6 +++--- src/test/check_getdns_general_sync.h | 6 +++--- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/test/check_getdns_address.h b/src/test/check_getdns_address.h index 10e4b7b2..a4eaad71 100644 --- a/src/test/check_getdns_address.h +++ b/src/test/check_getdns_address.h @@ -178,7 +178,7 @@ { /* * name = "localhost" name should be resolved from host file - * expect: NOERROR/NODATA response: + * expect: NOERROR response: * status = GETDNS_RESPSTATUS_GOOD * rcode = 0 * ancount = 1 (number of records in ANSWER section) diff --git a/src/test/check_getdns_address_sync.h b/src/test/check_getdns_address_sync.h index 07f8408f..c5c4ae92 100644 --- a/src/test/check_getdns_address_sync.h +++ b/src/test/check_getdns_address_sync.h @@ -147,7 +147,7 @@ /* * name = "willem.getdnsapi.net" need to replace this with domain from unbound zone * expect: NOERROR/NODATA response: - * status = GETDNS_RESPSTATUS_GOOD + * status = GETDNS_RESPSTATUS_NO_DATA * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ @@ -162,6 +162,7 @@ EXTRACT_RESPONSE; assert_noerror(&ex_response); + assert_nodata(&ex_response); //assert_soa_in_authority(&ex_response); CONTEXT_DESTROY; diff --git a/src/test/check_getdns_common.c b/src/test/check_getdns_common.c index 192ab661..9816f8ff 100644 --- a/src/test/check_getdns_common.c +++ b/src/test/check_getdns_common.c @@ -160,10 +160,15 @@ void extract_local_response(struct getdns_dict *response, struct extracted_respo void assert_noerror(struct extracted_response *ex_response) { uint32_t rcode; + uint32_t ancount = 0; - ASSERT_RC(ex_response->status, GETDNS_RESPSTATUS_GOOD, "Unexpected value for \"status\""); ASSERT_RC(getdns_dict_get_int(ex_response->header, "rcode", &rcode), GETDNS_RETURN_GOOD, "Failed to extract \"rcode\""); ck_assert_msg(rcode == 0, "Expected rcode == 0, got %d", rcode); + + ASSERT_RC(getdns_dict_get_int(ex_response->header, "ancount", &ancount), + GETDNS_RETURN_GOOD, "Failed to extract \"ancount\""); + + ASSERT_RC(ex_response->status, ((ancount > 0) ? GETDNS_RESPSTATUS_GOOD : GETDNS_RESPSTATUS_NO_NAME), "Unexpected value for \"status\""); } /* @@ -182,6 +187,8 @@ void assert_nodata(struct extracted_response *ex_response) ASSERT_RC(getdns_list_get_length(ex_response->answer, &length), GETDNS_RETURN_GOOD, "Failed to extract \"answer\" length"); ck_assert_msg(length == 0, "Expected \"answer\" length == 0, got %d", length); + + ASSERT_RC(ex_response->status, GETDNS_RESPSTATUS_NO_NAME, "Unexpected value for \"status\""); } /* diff --git a/src/test/check_getdns_general.h b/src/test/check_getdns_general.h index f073cd86..23bb7e77 100644 --- a/src/test/check_getdns_general.h +++ b/src/test/check_getdns_general.h @@ -146,7 +146,7 @@ * name = "google.com" * request_type = 0 (minimum valid RRTYPE) * expect: NOERROR/NODATA response: - * status = GETDNS_RESPSTATUS_GOOD + * status = GETDNS_RESPSTATUS_NO_NAME * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ @@ -180,7 +180,7 @@ * name = "google.com" * request_type = 65279 (maximum unassigned RRTYPE) * expect: NOERROR/NODATA response: - * status = GETDNS_RESPSTATUS_GOOD + * status = GETDNS_RESPSTATUS_NO_NAME * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ @@ -322,7 +322,7 @@ * name = "willem.getdnsapi.net" and unbound zone * request_type = GETDNS_RRTYPE_MX * expect: NOERROR/NODATA response: - * status = GETDNS_RESPSTATUS_GOOD + * status = GETDNS_RESPSTATUS_NO_NAME * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ diff --git a/src/test/check_getdns_general_sync.h b/src/test/check_getdns_general_sync.h index 5386ff53..52eacaff 100644 --- a/src/test/check_getdns_general_sync.h +++ b/src/test/check_getdns_general_sync.h @@ -128,7 +128,7 @@ * name = "google.com" * request_type = 0 (minimum valid RRTYPE) * expect: NOERROR/NODATA response: - * status = GETDNS_RESPSTATUS_GOOD + * status = GETDNS_RESPSTATUS_NO_NAME * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ @@ -155,7 +155,7 @@ * name = "google.com" * request_type = 65279 (maximum unassigned RRTYPE) * expect: NOERROR/NODATA response: - * status = GETDNS_RESPSTATUS_GOOD + * status = GETDNS_RESPSTATUS_NO_NAME * rcode = 0 * ancount = 0 (number of records in ANSWER section) */ @@ -269,7 +269,7 @@ * name = "willem.getdnsapi.net" an unbound zone (as in no MX) * request_type = GETDNS_RRTYPE_MX * expect: NOERROR/NODATA response: - * status = GETDNS_RESPSTATUS_GOOD + * status = GETDNS_RESPSTATUS_NO_NAME * rcode = 0 * ancount = 0 (number of records in ANSWER section) */