From 209da8b0fd04c6f31c62d6200ab521343cbbc424 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Thu, 26 Feb 2009 18:41:11 +0000 Subject: [PATCH] Thu Feb 26 09:47:46 CST 2009 Pekka Pessi * check_sres_sip.c: more test cases for naptr git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12306 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../libsofia-sip-ua/sresolv/Makefile.am | 4 +- .../libsofia-sip-ua/sresolv/check_sres_sip.c | 68 +++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) diff --git a/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.am b/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.am index f256674b9c..8aaae9a6b3 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.am +++ b/libs/sofia-sip/libsofia-sip-ua/sresolv/Makefile.am @@ -19,13 +19,15 @@ noinst_LTLIBRARIES = libsresolv.la check_PROGRAMS = torture_sresolv test_sresolv -TESTS = torture_sresolv run_test_sresolv +TESTS = check_PROGRAMS += check_sres_sip TESTS += check_sres_sip check_sres_sip_LDADD = $(LDADD) ${top_builddir}/s2check/libs2.a @CHECK_LIBS@ INCLUDES += -I${top_srcdir}/s2check +TESTS += torture_sresolv run_test_sresolv + CLEANFILES = resolv.conf error.conf named.conf.tmp \ .test_sresolv.api.conf.?????? \ named.run diff --git a/libs/sofia-sip/libsofia-sip-ua/sresolv/check_sres_sip.c b/libs/sofia-sip/libsofia-sip-ua/sresolv/check_sres_sip.c index b8ffabce02..d88e2f6e7e 100644 --- a/libs/sofia-sip/libsofia-sip-ua/sresolv/check_sres_sip.c +++ b/libs/sofia-sip/libsofia-sip-ua/sresolv/check_sres_sip.c @@ -602,6 +602,72 @@ START_TEST(found_naptr) } END_TEST +START_TEST(found_naptr_nohint) +{ + sres_sip_t *srs; + char const *d; + + s2_dns_default(d = "example.com."); + + s2_dns_record(d, sres_type_naptr, + /* order priority flags services regexp target */ + d, sres_type_naptr, 20, 50, "s", "SIP+D2Z", "", "_sip._tilulilu", + /* priority weight port target */ + "_sip._tilulilu", sres_type_srv, 2, 100, 5060, "sip00", + "sip00", sres_type_a, "12.13.14.15", + NULL); + + srs = sres_sip_new(x->sres, (void *)"sip:example.com", NULL, + 1, 1, + resolver_callback, x->root); + fail_if(srs == NULL); + + while (sres_sip_next_step(srs)) + su_root_step(x->root, 1000); + + fail_unless(sres_sip_results(srs) == NULL); + fail_unless(sres_sip_error(srs) == SRES_SIP_ERR_NO_TPORT); + + sres_sip_unref(srs); +} +END_TEST + +START_TEST(found_bad_naptr) +{ + sres_sip_t *srs; + su_addrinfo_t const *ai; + char const *d; + + s2_dns_default(d = "example.com."); + + s2_dns_record(d, sres_type_naptr, + /* order priority flags services regexp target */ + d, sres_type_naptr, 20, 50, "s", "ZIP+D2T", "", "_zip._tcp", + NULL); + + s2_dns_record(d, sres_type_a, + "", sres_type_a, "11.12.13.14", + NULL); + + srs = sres_sip_new(x->sres, (void *)"sip:example.com", NULL, + 1, 1, + resolver_callback, x->root); + fail_if(srs == NULL); + + while (sres_sip_next_step(srs)) + su_root_run(x->root); + + ai = sres_sip_results(srs); + assert(ai != NULL); + fail_if(ai->ai_protocol != TPPROTO_UDP); + fail_if(!(ai = ai->ai_next)); + fail_if(ai->ai_protocol != TPPROTO_TCP); + fail_if((ai = ai->ai_next)); + + sres_sip_unref(srs); +} +END_TEST + START_TEST(ignore_naptr) { sres_sip_t *srs; @@ -1033,6 +1099,8 @@ TCase *api_tcase(void) tcase_add_test(tc, found_maddr_ip); tcase_add_test(tc, found_a_aaaa); tcase_add_test(tc, found_naptr); + tcase_add_test(tc, found_bad_naptr); + tcase_add_test(tc, found_naptr_nohint); tcase_add_test(tc, found_naptr2); tcase_add_test(tc, found_naptr3); tcase_add_test(tc, found_naptr_with_a);