Thu Feb 26 09:47:46 CST 2009 Pekka Pessi <first.last@nokia.com>

* 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
This commit is contained in:
Michael Jerris 2009-02-26 18:41:11 +00:00
parent ae27bdd5f2
commit 209da8b0fd
2 changed files with 71 additions and 1 deletions

View File

@ -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

View File

@ -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);