aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-07-28 07:15:28 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-07-30 22:28:44 +0300
commitf708f54c0323f6698474e99bc5d0c5c1fbf65733 (patch)
treeecd368e9b49c6dbfdd7b7f62f2e644ab508bc7de /src/testcurl
parentfff9fa78328f56f79bccf9417ae4401a0f19a853 (diff)
downloadlibmicrohttpd-f708f54c0323f6698474e99bc5d0c5c1fbf65733.tar.gz
libmicrohttpd-f708f54c0323f6698474e99bc5d0c5c1fbf65733.zip
test_digestauth2: added testing of RFC2069 mode
Diffstat (limited to 'src/testcurl')
-rw-r--r--src/testcurl/.gitignore2
-rw-r--r--src/testcurl/Makefile.am8
-rw-r--r--src/testcurl/test_digestauth2.c46
3 files changed, 46 insertions, 10 deletions
diff --git a/src/testcurl/.gitignore b/src/testcurl/.gitignore
index 70fb27dc..c06787a1 100644
--- a/src/testcurl/.gitignore
+++ b/src/testcurl/.gitignore
@@ -158,6 +158,8 @@ core
158/test_digestauth_emu_ext 158/test_digestauth_emu_ext
159/test_digestauth_emu_ext_oldapi 159/test_digestauth_emu_ext_oldapi
160/test_digestauth2 160/test_digestauth2
161/test_digestauth2_rfc2069
162/test_digestauth2_rfc2069_userdigest
161/test_digestauth2_oldapi1 163/test_digestauth2_oldapi1
162/test_digestauth2_oldapi2 164/test_digestauth2_oldapi2
163/test_digestauth2_userhash 165/test_digestauth2_userhash
diff --git a/src/testcurl/Makefile.am b/src/testcurl/Makefile.am
index a9182ea2..34590e8f 100644
--- a/src/testcurl/Makefile.am
+++ b/src/testcurl/Makefile.am
@@ -171,6 +171,8 @@ check_PROGRAMS += \
171 test_digestauth_emu_ext \ 171 test_digestauth_emu_ext \
172 test_digestauth_emu_ext_oldapi \ 172 test_digestauth_emu_ext_oldapi \
173 test_digestauth2 \ 173 test_digestauth2 \
174 test_digestauth2_rfc2069 \
175 test_digestauth2_rfc2069_userdigest \
174 test_digestauth2_oldapi1 \ 176 test_digestauth2_oldapi1 \
175 test_digestauth2_oldapi2 \ 177 test_digestauth2_oldapi2 \
176 test_digestauth2_userhash \ 178 test_digestauth2_userhash \
@@ -296,6 +298,12 @@ test_digestauth_emu_ext_oldapi_SOURCES = \
296test_digestauth2_SOURCES = \ 298test_digestauth2_SOURCES = \
297 test_digestauth2.c mhd_has_param.h mhd_has_in_name.h 299 test_digestauth2.c mhd_has_param.h mhd_has_in_name.h
298 300
301test_digestauth2_rfc2069_SOURCES = \
302 test_digestauth2.c mhd_has_param.h mhd_has_in_name.h
303
304test_digestauth2_rfc2069_userdigest_SOURCES = \
305 test_digestauth2.c mhd_has_param.h mhd_has_in_name.h
306
299test_digestauth2_oldapi1_SOURCES = \ 307test_digestauth2_oldapi1_SOURCES = \
300 test_digestauth2.c mhd_has_param.h mhd_has_in_name.h 308 test_digestauth2.c mhd_has_param.h mhd_has_in_name.h
301 309
diff --git a/src/testcurl/test_digestauth2.c b/src/testcurl/test_digestauth2.c
index 19ae031f..6054af7d 100644
--- a/src/testcurl/test_digestauth2.c
+++ b/src/testcurl/test_digestauth2.c
@@ -273,6 +273,7 @@ static int test_oldapi;
273static int test_userhash; 273static int test_userhash;
274static int test_userdigest; 274static int test_userdigest;
275static int test_sha256; 275static int test_sha256;
276static int test_rfc2069;
276static int curl_uses_usehash; 277static int curl_uses_usehash;
277 278
278/* Static helper variables */ 279/* Static helper variables */
@@ -437,6 +438,8 @@ ahc_echo (void *cls,
437 struct MHD_DigestAuthInfo *dinfo; 438 struct MHD_DigestAuthInfo *dinfo;
438 const enum MHD_DigestAuthAlgo3 algo3 = 439 const enum MHD_DigestAuthAlgo3 algo3 =
439 test_sha256 ? MHD_DIGEST_AUTH_ALGO3_SHA256 : MHD_DIGEST_AUTH_ALGO3_MD5; 440 test_sha256 ? MHD_DIGEST_AUTH_ALGO3_SHA256 : MHD_DIGEST_AUTH_ALGO3_MD5;
441 const enum MHD_DigestAuthQOP qop =
442 test_rfc2069 ? MHD_DIGEST_AUTH_QOP_NONE : MHD_DIGEST_AUTH_QOP_AUTH;
440 443
441 dinfo = MHD_digest_auth_get_request_info3 (connection); 444 dinfo = MHD_digest_auth_get_request_info3 (connection);
442 if (NULL != dinfo) 445 if (NULL != dinfo)
@@ -520,13 +523,25 @@ ahc_echo (void *cls,
520 (int) dinfo->algo); 523 (int) dinfo->algo);
521 mhdErrorExitDesc ("Wrong 'algo'"); 524 mhdErrorExitDesc ("Wrong 'algo'");
522 } 525 }
523 else if (10 >= dinfo->cnonce_len) 526 if (! test_rfc2069)
524 { 527 {
525 fprintf (stderr, "Unexpected small 'cnonce_len': %ld. ", 528 if (10 >= dinfo->cnonce_len)
526 (long) dinfo->cnonce_len); 529 {
527 mhdErrorExitDesc ("Wrong 'cnonce_len'"); 530 fprintf (stderr, "Unexpected small 'cnonce_len': %ld. ",
531 (long) dinfo->cnonce_len);
532 mhdErrorExitDesc ("Wrong 'cnonce_len'");
533 }
534 }
535 else
536 {
537 if (0 != dinfo->cnonce_len)
538 {
539 fprintf (stderr, "'cnonce_len' is not zero: %ld. ",
540 (long) dinfo->cnonce_len);
541 mhdErrorExitDesc ("Wrong 'cnonce_len'");
542 }
528 } 543 }
529 else if (NULL == dinfo->opaque) 544 if (NULL == dinfo->opaque)
530 mhdErrorExitDesc ("'opaque' is NULL"); 545 mhdErrorExitDesc ("'opaque' is NULL");
531 else if (dinfo->opaque_len != MHD_STATICSTR_LEN_ (OPAQUE_VALUE)) 546 else if (dinfo->opaque_len != MHD_STATICSTR_LEN_ (OPAQUE_VALUE))
532 { 547 {
@@ -545,11 +560,11 @@ ahc_echo (void *cls,
545 dinfo->opaque); 560 dinfo->opaque);
546 mhdErrorExitDesc ("Wrong 'opaque'"); 561 mhdErrorExitDesc ("Wrong 'opaque'");
547 } 562 }
548 else if (MHD_DIGEST_AUTH_QOP_AUTH != dinfo->qop) 563 else if (qop != dinfo->qop)
549 { 564 {
550 fprintf (stderr, "Unexpected 'qop'.\n" 565 fprintf (stderr, "Unexpected 'qop'.\n"
551 "Expected: %d\tRecieved: %d. ", 566 "Expected: %d\tRecieved: %d. ",
552 (int) MHD_DIGEST_AUTH_QOP_AUTH, 567 (int) qop,
553 (int) dinfo->qop); 568 (int) dinfo->qop);
554 mhdErrorExitDesc ("Wrong 'qop'"); 569 mhdErrorExitDesc ("Wrong 'qop'");
555 } 570 }
@@ -651,14 +666,16 @@ ahc_echo (void *cls,
651 MHD_digest_auth_check3 (connection, REALM_VAL, username_ptr, 666 MHD_digest_auth_check3 (connection, REALM_VAL, username_ptr,
652 PASSWORD_VALUE, 667 PASSWORD_VALUE,
653 50 * TIMEOUTS_VAL, 668 50 * TIMEOUTS_VAL,
654 0, MHD_DIGEST_AUTH_MULT_QOP_AUTH, 669 0,
670 (enum MHD_DigestAuthMultiQOP) qop,
655 (enum MHD_DigestAuthMultiAlgo3) algo3); 671 (enum MHD_DigestAuthMultiAlgo3) algo3);
656 else 672 else
657 check_res = 673 check_res =
658 MHD_digest_auth_check_digest3 (connection, REALM_VAL, username_ptr, 674 MHD_digest_auth_check_digest3 (connection, REALM_VAL, username_ptr,
659 userdigest_bin, userdigest_bin_size, 675 userdigest_bin, userdigest_bin_size,
660 50 * TIMEOUTS_VAL, 676 50 * TIMEOUTS_VAL,
661 0, MHD_DIGEST_AUTH_MULT_QOP_AUTH, 677 0,
678 (enum MHD_DigestAuthMultiQOP) qop,
662 (enum MHD_DigestAuthMultiAlgo3) algo3); 679 (enum MHD_DigestAuthMultiAlgo3) algo3);
663 680
664 switch (check_res) 681 switch (check_res)
@@ -690,6 +707,9 @@ ahc_echo (void *cls,
690 "MHD_DAUTH_RESPONSE_WRONG"); 707 "MHD_DAUTH_RESPONSE_WRONG");
691 break; 708 break;
692 case MHD_DAUTH_WRONG_HEADER: 709 case MHD_DAUTH_WRONG_HEADER:
710 mhdErrorExitDesc ("MHD_digest_auth_check[_digest]3()' returned " \
711 "MHD_DAUTH_WRONG_HEADER");
712 break;
693 case MHD_DAUTH_WRONG_REALM: 713 case MHD_DAUTH_WRONG_REALM:
694 case MHD_DAUTH_WRONG_URI: 714 case MHD_DAUTH_WRONG_URI:
695 case MHD_DAUTH_WRONG_QOP: 715 case MHD_DAUTH_WRONG_QOP:
@@ -728,7 +748,7 @@ ahc_echo (void *cls,
728 res = 748 res =
729 MHD_queue_auth_required_response3 (connection, REALM_VAL, OPAQUE_VALUE, 749 MHD_queue_auth_required_response3 (connection, REALM_VAL, OPAQUE_VALUE,
730 "/", response, 0, 750 "/", response, 0,
731 MHD_DIGEST_AUTH_MULT_QOP_AUTH, 751 (enum MHD_DigestAuthMultiQOP) qop,
732 (enum MHD_DigestAuthMultiAlgo3) algo3, 752 (enum MHD_DigestAuthMultiAlgo3) algo3,
733 test_userhash, 0); 753 test_userhash, 0);
734 if (MHD_YES != res) 754 if (MHD_YES != res)
@@ -1183,6 +1203,7 @@ main (int argc, char *const *argv)
1183 test_userhash = has_in_name (argv[0], "_userhash"); 1203 test_userhash = has_in_name (argv[0], "_userhash");
1184 test_userdigest = has_in_name (argv[0], "_userdigest"); 1204 test_userdigest = has_in_name (argv[0], "_userdigest");
1185 test_sha256 = has_in_name (argv[0], "_sha256"); 1205 test_sha256 = has_in_name (argv[0], "_sha256");
1206 test_rfc2069 = has_in_name (argv[0], "_rfc2069");
1186 1207
1187 /* Wrong test types combinations */ 1208 /* Wrong test types combinations */
1188 if (1 == test_oldapi) 1209 if (1 == test_oldapi)
@@ -1192,6 +1213,11 @@ main (int argc, char *const *argv)
1192 } 1213 }
1193 if (test_oldapi) 1214 if (test_oldapi)
1194 { 1215 {
1216 if (test_userhash || test_rfc2069)
1217 return 99;
1218 }
1219 if (test_rfc2069)
1220 {
1195 if (test_userhash) 1221 if (test_userhash)
1196 return 99; 1222 return 99;
1197 } 1223 }