diff --git a/src/test/check_getdns.c b/src/test/check_getdns.c index e04d834d..cdf2890d 100644 --- a/src/test/check_getdns.c +++ b/src/test/check_getdns.c @@ -27,6 +27,8 @@ #include "check_getdns_dict_set_list.h" #include "check_getdns_dict_set_bindata.h" #include "check_getdns_dict_set_int.h" +#include "check_getdns_convert_ulabel_to_alabel.h" +//#include "check_getdns_convert_alabel_to_ulabel.h" int main (void) @@ -53,6 +55,8 @@ main (void) Suite *getdns_dict_set_list_suite(void); Suite *getdns_dict_set_bindata_suite(void); Suite *getdns_dict_set_int_suite(void); + Suite *getdns_convert_ulabel_to_alabel_suite(void); + //Suite *getdns_convert_alabel_to_ulabel_suite(void); sr = srunner_create(getdns_general_suite()); srunner_add_suite(sr, getdns_general_sync_suite()); @@ -73,6 +77,8 @@ main (void) srunner_add_suite(sr, getdns_dict_set_list_suite()); srunner_add_suite(sr, getdns_dict_set_bindata_suite()); srunner_add_suite(sr, getdns_dict_set_int_suite()); + srunner_add_suite(sr, getdns_convert_ulabel_to_alabel_suite()); + //srunner_add_suite(sr, getdns_convert_alabel_to_ulabel_suite()); srunner_set_log(sr, "check_getdns.log"); srunner_run_all(sr, CK_NORMAL); diff --git a/src/test/check_getdns_address_sync.h b/src/test/check_getdns_address_sync.h index f4c790ff..59f937ce 100644 --- a/src/test/check_getdns_address_sync.h +++ b/src/test/check_getdns_address_sync.h @@ -42,25 +42,6 @@ END_TEST START_TEST (getdns_address_sync_3) - { - /* - * name = invalid domain (too many octets) - * expect: GETDNS_RETURN_BAD_DOMAIN_NAME - */ - struct getdns_context *context = NULL; - struct getdns_dict *response = NULL; - const char *name = "oh.my.gosh.and.for.petes.sake.are.you.fricking.crazy.man.because.this.spectacular.and.elaborately.thought.out.domain.name.of.very.significant.length.is.just.too.darn.long.because.you.know.the rfc.states.that.two.hundred.fifty.five.characters.is.the.max.com"; - - CONTEXT_CREATE(TRUE); - - ASSERT_RC(getdns_address_sync(context, name, NULL, &response), - GETDNS_RETURN_BAD_DOMAIN_NAME, "Return code from getdns_address_sync()"); - - CONTEXT_DESTROY; - } - END_TEST - - START_TEST (getdns_address_sync_4) { /* * name = invalid domain (label too long) @@ -79,7 +60,7 @@ } END_TEST - START_TEST (getdns_address_sync_5) + START_TEST (getdns_address_sync_4) { /* * response = NULL @@ -96,7 +77,7 @@ } END_TEST - START_TEST (getdns_address_sync_6) + START_TEST (getdns_address_sync_5) { /* * name = "google.com" @@ -122,7 +103,7 @@ } END_TEST - START_TEST (getdns_address_sync_7) + START_TEST (getdns_address_sync_6) { /* * name = "localhost" @@ -149,7 +130,7 @@ } END_TEST - START_TEST (getdns_address_sync_8) + START_TEST (getdns_address_sync_7) { /* * name = "google.joe" @@ -179,7 +160,7 @@ } END_TEST - START_TEST (getdns_address_sync_9) + START_TEST (getdns_address_sync_8) { /* * name = "hampster.com" need to replace this with domain from unbound zone @@ -204,7 +185,7 @@ } END_TEST - START_TEST (getdns_address_sync_10) + START_TEST (getdns_address_sync_9) { /* * name = "google.com" need to swap this out for max domain name length with max lable length` @@ -230,7 +211,7 @@ } END_TEST - START_TEST (getdns_address_sync_11) + START_TEST (getdns_address_sync_10) { /* * name = "75.101.146.66" need to change this to local unbound data @@ -258,7 +239,7 @@ } END_TEST - START_TEST (getdns_address_sync_12) + START_TEST (getdns_address_sync_11) { /* * name = "2607:f8b0:4006:802::1007" need to change this to local unbound data @@ -308,7 +289,6 @@ tcase_add_test(tc_pos, getdns_address_sync_9); tcase_add_test(tc_pos, getdns_address_sync_10); tcase_add_test(tc_pos, getdns_address_sync_11); - tcase_add_test(tc_pos, getdns_address_sync_12); suite_add_tcase(s, tc_pos); return s; diff --git a/src/test/check_getdns_convert_alabel_to_ulabel.h b/src/test/check_getdns_convert_alabel_to_ulabel.h new file mode 100644 index 00000000..d1884193 --- /dev/null +++ b/src/test/check_getdns_convert_alabel_to_ulabel.h @@ -0,0 +1,70 @@ +#ifndef _check_getdns_convert_alabel_to_ulabel_h_ +#define _check_getdns_convert_alabel_to_ulabel_h_ + + /* + ************************************************************************************* + * * + * T E S T S F O R G E T D N S _ C O N V E R T _ A L A B E L _ T O _ U L A B E L * + * * + ************************************************************************************* + */ + + START_TEST (getdns_convert_alabel_to_ulabel_1) + { + /* + * ulabel = NULL + * expect: GETDNS_RETURN_GENERIC_ERROR + */ + char alabel = NULL; + + ASSERT_RC(getdns_convert_alabel_to_ulabel( *alabel ), + GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_convert_alabel_to_ulabel()"); + } + END_TEST + + START_TEST (getdns_convert_alabel_to_ulabel_2) + { + /* + * alabel = invalid characters + * expect: GETDNS_RETURN_GENERIC_ERROR + */ + char alabel = "#$%_"; + + ASSERT_RC(getdns_convert_alabel_to_ulabel( *alabel ), + GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_convert_alabel_to_ulabel()"); + } + END_TEST + + START_TEST (getdns_convert_alabel_to_ulabel_3) + { + /* + * alabel = valid characters (ace must begin with prefix "xn--" and be followed by a valid puny algorithm output; length limited to 59 chars) + * expect: GETDNS_RETURN_GOOD + */ + char alabel = "xn--caf-dma"; + + ASSERT_RC(getdns_convert_alabel_to_ulabel( *alabel ), + GETDNS_RETURN_GOOD, "Return code from getdns_convert_alabel_to_ulabel()"); + } + END_TEST + + Suite * + getdns_convert_alabel_to_ulabel_suite (void) + { + Suite *s = suite_create ("getdns_convert_alabel_to_ulabel()"); + + /* Negative test caseis */ + TCase *tc_neg = tcase_create("Negative"); + tcase_add_test(tc_neg, getdns_convert_alabel_to_ulabel_1); + tcase_add_test(tc_neg, getdns_convert_alabel_to_ulabel_2); + suite_add_tcase(s, tc_neg); + + /* Positive test cases */ + TCase *tc_pos = tcase_create("Positive"); + tcase_add_test(tc_pos, getdns_convert_alabel_to_ulabel_3); + suite_add_tcase(s, tc_pos); + + return s; + } + +#endif diff --git a/src/test/check_getdns_convert_ulabel_to_alabel.h b/src/test/check_getdns_convert_ulabel_to_alabel.h new file mode 100644 index 00000000..dc20ffc4 --- /dev/null +++ b/src/test/check_getdns_convert_ulabel_to_alabel.h @@ -0,0 +1,70 @@ +#ifndef _check_getdns_convert_ulabel_to_alabel_h_ +#define _check_getdns_convert_ulabel_to_alabel_h_ + + /* + ************************************************************************************* + * * + * T E S T S F O R G E T D N S _ C O N V E R T _ U L A B E L _ T O _ A L A B E L * + * * + ************************************************************************************* + */ + + START_TEST (getdns_convert_ulabel_to_alabel_1) + { + /* + * ulabel = NULL + * expect: GETDNS_RETURN_GENERIC_ERROR + */ + char ulabel = NULL; + + ASSERT_RC(getdns_convert_ulabel_to_alabel( *ulabel ), + GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_convert_ulabel_to_alabel()"); + } + END_TEST + + START_TEST (getdns_convert_ulabel_to_alabel_2) + { + /* + * ulabel = invalid characters + * expect: GETDNS_RETURN_GENERIC_ERROR + */ + char ulabel = "#$%_"; + + ASSERT_RC(getdns_convert_ulabel_to_alabel( *ulabel ), + GETDNS_RETURN_GENERIC_ERROR, "Return code from getdns_convert_ulabel_to_alabel()"); + } + END_TEST + + START_TEST (getdns_convert_ulabel_to_alabel_3) + { + /* + * ulabel = valid characters ( _abc, -abc, -abc-, abc- and limited to 63 octets ) + * expect: GETDNS_RETURN_GOOD + */ + char ulabel = "café"; + + ASSERT_RC(getdns_convert_ulabel_to_alabel( *ulabel ), + GETDNS_RETURN_GOOD, "Return code from getdns_convert_ulabel_to_alabel()"); + } + END_TEST + + Suite * + getdns_convert_ulabel_to_alabel_suite (void) + { + Suite *s = suite_create ("getdns_convert_ulabel_to_alabel()"); + + /* Negative test caseis */ + TCase *tc_neg = tcase_create("Negative"); + tcase_add_test(tc_neg, getdns_convert_ulabel_to_alabel_1); + tcase_add_test(tc_neg, getdns_convert_ulabel_to_alabel_2); + suite_add_tcase(s, tc_neg); + + /* Positive test cases */ + TCase *tc_pos = tcase_create("Positive"); + tcase_add_test(tc_pos, getdns_convert_ulabel_to_alabel_3); + suite_add_tcase(s, tc_pos); + + return s; + } + +#endif