Minor testing updates:

- add option to use IPv6 for manual transport tests
- add recursion mode to call_reporting
This commit is contained in:
Sara Dickinson 2016-06-16 10:47:43 +01:00
parent c0187a19ea
commit 3c7758fdbc
4 changed files with 29 additions and 8 deletions

View File

@ -1054,6 +1054,7 @@ getdns_pp_dict(gldns_buffer * buf, size_t indent,
strcmp(item->node.key, "append_name") == 0 || strcmp(item->node.key, "append_name") == 0 ||
strcmp(item->node.key, "follow_redirects") == 0 || strcmp(item->node.key, "follow_redirects") == 0 ||
strcmp(item->node.key, "transport") == 0 || strcmp(item->node.key, "transport") == 0 ||
strcmp(item->node.key, "resolution_mode") == 0 ||
strcmp(item->node.key, "resolution_type") == 0 || strcmp(item->node.key, "resolution_type") == 0 ||
strcmp(item->node.key, "tls_authentication") == 0 ) && strcmp(item->node.key, "tls_authentication") == 0 ) &&
(strval = (strval =

View File

@ -131,6 +131,7 @@
struct getdns_dict *extensions = getdns_dict_create(); struct getdns_dict *extensions = getdns_dict_create();
uint32_t tc; uint32_t tc;
uint32_t transport; uint32_t transport;
uint32_t mode;
/* Note that stricly this test just establishes that the requested transport /* Note that stricly this test just establishes that the requested transport
and the reported transport are consistent, it does not guarentee which and the reported transport are consistent, it does not guarentee which
@ -157,6 +158,9 @@
ASSERT_RC(getdns_dict_get_int(response, "/call_reporting/0/transport", &transport), ASSERT_RC(getdns_dict_get_int(response, "/call_reporting/0/transport", &transport),
GETDNS_RETURN_GOOD, "Failed to extract \"transport\""); GETDNS_RETURN_GOOD, "Failed to extract \"transport\"");
ASSERT_RC(transport, GETDNS_TRANSPORT_UDP, "Query did not go over UDP"); ASSERT_RC(transport, GETDNS_TRANSPORT_UDP, "Query did not go over UDP");
ASSERT_RC(getdns_dict_get_int(response, "/call_reporting/0/resolution_mode", &mode),
GETDNS_RETURN_GOOD, "Failed to extract \"resolution_mode\"");
ASSERT_RC(mode, GETDNS_RESOLUTION_STUB, "Query did not use stub mode");
ASSERT_RC(getdns_dict_get_int(response, "/replies_tree/0/header/tc", &tc), ASSERT_RC(getdns_dict_get_int(response, "/replies_tree/0/header/tc", &tc),
GETDNS_RETURN_GOOD, "Failed to extract \"tc\""); GETDNS_RETURN_GOOD, "Failed to extract \"tc\"");
ASSERT_RC(tc, 1, "Packet not trucated as expected"); ASSERT_RC(tc, 1, "Packet not trucated as expected");
@ -208,6 +212,7 @@
struct getdns_dict *response = NULL; struct getdns_dict *response = NULL;
struct getdns_dict *extensions = getdns_dict_create(); struct getdns_dict *extensions = getdns_dict_create();
uint32_t status; uint32_t status;
uint32_t mode;
uint32_t tc; uint32_t tc;
/* Recursive mode does not report the transport used and does not answer /* Recursive mode does not report the transport used and does not answer
@ -239,13 +244,18 @@
CONTEXT_CREATE(TRUE); CONTEXT_CREATE(TRUE);
/* Re-do over TCP */ /* Re-do over TCP */
ASSERT_RC(getdns_dict_set_int(extensions,"return_call_reporting", GETDNS_EXTENSION_TRUE),
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_int()");
ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_TCP_ONLY), ASSERT_RC(getdns_context_set_dns_transport(context, GETDNS_TRANSPORT_TCP_ONLY),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()"); GETDNS_RETURN_GOOD, "Return code from getdns_context_set_dns_transport()");
ASSERT_RC(getdns_context_set_edns_maximum_udp_payload_size(context, 512), ASSERT_RC(getdns_context_set_edns_maximum_udp_payload_size(context, 512),
GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_maximum_udp_payload_size()"); GETDNS_RETURN_GOOD, "Return code from getdns_context_set_edns_maximum_udp_payload_size()");
ASSERT_RC(getdns_general_sync(context, "getdnsapi.net", 48, extensions, &response), ASSERT_RC(getdns_general_sync(context, "getdnsapi.net", 48, extensions, &response),
GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()"); GETDNS_RETURN_GOOD, "Return code from getdns_general_sync()");
ASSERT_RC(getdns_dict_get_int(response, "/call_reporting/0/resolution_mode", &mode),
GETDNS_RETURN_GOOD, "Failed to extract \"resolution_mode\"");
ASSERT_RC(mode, GETDNS_RESOLUTION_RECURSING, "Query did not use Recursive mode");
ASSERT_RC(getdns_dict_get_int(response, "/replies_tree/0/header/tc", &tc), ASSERT_RC(getdns_dict_get_int(response, "/replies_tree/0/header/tc", &tc),
GETDNS_RETURN_GOOD, "Failed to extract \"tc\""); GETDNS_RETURN_GOOD, "Failed to extract \"tc\"");
ASSERT_RC(tc, 0, "Packet trucated - not as expected"); ASSERT_RC(tc, 0, "Packet trucated - not as expected");

View File

@ -2,7 +2,9 @@
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
SERVER_IP="8.8.8.8" SERVER_IP="8.8.8.8"
SERVER_IPv6="2001:4860:4860::8888"
TLS_SERVER_IP="185.49.141.38~getdnsapi.net" TLS_SERVER_IP="185.49.141.38~getdnsapi.net"
TLS_SERVER_IPv6="2a04:b900:0:100::38~getdnsapi.net"
TLS_SERVER_KEY="foxZRnIh9gZpWnl+zEiKa0EJ2rdCGroMWm02gaxSc9S=" TLS_SERVER_KEY="foxZRnIh9gZpWnl+zEiKa0EJ2rdCGroMWm02gaxSc9S="
TLS_SERVER_WRONG_KEY="foxZRnIh9gZpWnl+zEiKa0EJ2rdCGroMWm02gaxSc1S=" TLS_SERVER_WRONG_KEY="foxZRnIh9gZpWnl+zEiKa0EJ2rdCGroMWm02gaxSc1S="
GOOD_RESULT_SYNC="Status was: At least one response was returned" GOOD_RESULT_SYNC="Status was: At least one response was returned"
@ -62,21 +64,22 @@ usage () {
echo " -t server configured for TLS, TCP and UDP" echo " -t server configured for TLS, TCP and UDP"
echo " (This must include the hostname e.g. 185.49.141.38~getdnsapi.net)" echo " (This must include the hostname e.g. 185.49.141.38~getdnsapi.net)"
echo " -k SPKI pin for server configured for TLS, TCP and UDP" echo " -k SPKI pin for server configured for TLS, TCP and UDP"
echo " -i Use IPv6 addresses (when using default servers)"
} }
while getopts ":p:s:t:k:dh" opt; do while getopts ":p:s:t:k:idh" opt; do
case $opt in case $opt in
d ) set -x ;; d ) set -x ; echo "DEBUG mode set" ;;
p ) DIR=$OPTARG ;; p ) DIR=$OPTARG ;;
s ) SERVER_IP=$OPTARG ; echo "Setting server to $OPTARG" ;; s ) SERVER_IP=$OPTARG ; echo "Setting server to $OPTARG" ;;
t ) TLS_SERVER_IP=$OPTARG ; echo "Setting TLS server to $OPTARG" ;; t ) TLS_SERVER_IP=$OPTARG ; echo "Setting TLS server to $OPTARG" ;;
k ) TLS_SERVER_KEY=$OPTARG ; echo "Setting TLS server key to $OPTARG" ;; k ) TLS_SERVER_KEY=$OPTARG ; echo "Setting TLS server key to $OPTARG" ;;
i ) SERVER_IP=$SERVER_IPv6; TLS_SERVER_IP=$TLS_SERVER_IPv6 ; echo "Using IPv6" ;;
h ) usage ; exit ;; h ) usage ; exit ;;
esac esac
done done
TLS_SERVER_IP_NO_NAME=`echo ${TLS_SERVER_IP%~*}` TLS_SERVER_IP_NO_NAME=`echo ${TLS_SERVER_IP%~*}`
echo $TLS_SERVER_IP_NO_NAME
TLS_SERVER_IP_WRONG_NAME=`echo ${TLS_SERVER_IP::${#TLS_SERVER_IP}-1}` TLS_SERVER_IP_WRONG_NAME=`echo ${TLS_SERVER_IP::${#TLS_SERVER_IP}-1}`
GOOD_QUERIES=( GOOD_QUERIES=(
@ -100,7 +103,7 @@ NOT_AVAILABLE_QUERIES=(
"-s -A -q getdnsapi.net -l L @${SERVER_IP}" "-s -A -q getdnsapi.net -l L @${SERVER_IP}"
"-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP_WRONG_NAME}" "-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP_WRONG_NAME}"
"-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP_NO_NAME}" "-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP_NO_NAME}"
"-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP_NO_NAME} ${TLS_SERVER_WRONG_KEY}") "-s -A -q getdnsapi.net -l L -m @${TLS_SERVER_IP_NO_NAME} -K pin-sha256=\"${TLS_SERVER_WRONG_KEY}\"")
echo "Starting transport test" echo "Starting transport test"

View File

@ -812,12 +812,19 @@ _getdns_create_call_reporting_dict(
getdns_dict_destroy(netreq_debug); getdns_dict_destroy(netreq_debug);
return NULL; return NULL;
} else if (!netreq->upstream) } else if (!netreq->upstream) {
if (getdns_dict_set_int( netreq_debug, "resolution_mode", GETDNS_RESOLUTION_RECURSING)) {
getdns_dict_destroy(netreq_debug);
return NULL;
}
/* Nothing more for full recursion */ /* Nothing more for full recursion */
return netreq_debug; return netreq_debug;
}
if (getdns_dict_set_int( netreq_debug, "resolution_mode", GETDNS_RESOLUTION_STUB)) {
getdns_dict_destroy(netreq_debug);
return NULL;
}
/* Stub resolver debug data */ /* Stub resolver debug data */
_getdns_sockaddr_to_dict( _getdns_sockaddr_to_dict(
context, &netreq->upstream->addr, &address_debug); context, &netreq->upstream->addr, &address_debug);