diff options
author | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-07-22 19:24:43 +0300 |
---|---|---|
committer | Evgeny Grin (Karlson2k) <k2k@narod.ru> | 2022-07-25 16:20:50 +0300 |
commit | aa49d6053c6d97cac0d10f9e39993962103dfb37 (patch) | |
tree | fa12dc1ff6bda8ef916305b55ae91377eb15cb1e | |
parent | 5da848a157202cc8ebfc0dbdc39ec4529160d36e (diff) | |
download | libmicrohttpd-aa49d6053c6d97cac0d10f9e39993962103dfb37.tar.gz libmicrohttpd-aa49d6053c6d97cac0d10f9e39993962103dfb37.zip |
test_digestauth_emu_ext: cosmetics, additional check
-rw-r--r-- | src/testcurl/test_digestauth_emu_ext.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/testcurl/test_digestauth_emu_ext.c b/src/testcurl/test_digestauth_emu_ext.c index 740f43eb..2cd2519f 100644 --- a/src/testcurl/test_digestauth_emu_ext.c +++ b/src/testcurl/test_digestauth_emu_ext.c | |||
@@ -237,7 +237,7 @@ _checkCURLE_OK_func (CURLcode code, const char *curlFunc, | |||
237 | #define USERNAME "titkos szuper" "\xC3\xBC" "gyn" "\xC3\xB6" "k" | 237 | #define USERNAME "titkos szuper" "\xC3\xBC" "gyn" "\xC3\xB6" "k" |
238 | /* percent-encoded username */ | 238 | /* percent-encoded username */ |
239 | #define USERNAME_PCTENC "titkos%20szuper%C3%BCgyn%C3%B6k" | 239 | #define USERNAME_PCTENC "titkos%20szuper%C3%BCgyn%C3%B6k" |
240 | #define PASSWORD "fake pass" | 240 | #define PASSWORD_VALUE "fake pass" |
241 | #define OPAQUE_VALUE "opaque-content" | 241 | #define OPAQUE_VALUE "opaque-content" |
242 | #define NONCE_EMU "badbadbadbadbadbadbadbadbadbadbadbadbadbadba" | 242 | #define NONCE_EMU "badbadbadbadbadbadbadbadbadbadbadbadbadbadba" |
243 | #define CNONCE_EMU "utututututututututututututututututututututs=" | 243 | #define CNONCE_EMU "utututututututututututututututututututututs=" |
@@ -354,6 +354,14 @@ ahc_echo (void *cls, | |||
354 | creds = MHD_digest_auth_get_username3 (connection); | 354 | creds = MHD_digest_auth_get_username3 (connection); |
355 | if (NULL == creds) | 355 | if (NULL == creds) |
356 | mhdErrorExitDesc ("MHD_digest_auth_get_username3() returned NULL"); | 356 | mhdErrorExitDesc ("MHD_digest_auth_get_username3() returned NULL"); |
357 | else if (MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED != creds->uname_type) | ||
358 | { | ||
359 | fprintf (stderr, "Unexpected 'uname_type'.\n" | ||
360 | "Expected: %d\tRecieved: %d. ", | ||
361 | (int) MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED, | ||
362 | (int) creds->uname_type); | ||
363 | mhdErrorExitDesc ("Wrong 'uname_type'"); | ||
364 | } | ||
357 | else if (NULL == creds->username) | 365 | else if (NULL == creds->username) |
358 | mhdErrorExitDesc ("'username' is NULL"); | 366 | mhdErrorExitDesc ("'username' is NULL"); |
359 | else if (creds->username_len != MHD_STATICSTR_LEN_ (USERNAME)) | 367 | else if (creds->username_len != MHD_STATICSTR_LEN_ (USERNAME)) |
@@ -377,7 +385,12 @@ ahc_echo (void *cls, | |||
377 | mhdErrorExitDesc ("'userhash_bin' is NOT NULL"); | 385 | mhdErrorExitDesc ("'userhash_bin' is NOT NULL"); |
378 | else if (0 != creds->userhash_bin_size) | 386 | else if (0 != creds->userhash_bin_size) |
379 | mhdErrorExitDesc ("'userhash_bin_size' is NOT zero"); | 387 | mhdErrorExitDesc ("'userhash_bin_size' is NOT zero"); |
380 | else if (MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED != creds->uname_type) | 388 | MHD_free (creds); |
389 | |||
390 | dinfo = MHD_digest_auth_get_request_info3 (connection); | ||
391 | if (NULL == dinfo) | ||
392 | mhdErrorExitDesc ("MHD_digest_auth_get_username3() returned NULL"); | ||
393 | else if (MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED != dinfo->uname_type) | ||
381 | { | 394 | { |
382 | fprintf (stderr, "Unexpected 'uname_type'.\n" | 395 | fprintf (stderr, "Unexpected 'uname_type'.\n" |
383 | "Expected: %d\tRecieved: %d. ", | 396 | "Expected: %d\tRecieved: %d. ", |
@@ -385,11 +398,6 @@ ahc_echo (void *cls, | |||
385 | (int) creds->uname_type); | 398 | (int) creds->uname_type); |
386 | mhdErrorExitDesc ("Wrong 'uname_type'"); | 399 | mhdErrorExitDesc ("Wrong 'uname_type'"); |
387 | } | 400 | } |
388 | MHD_free (creds); | ||
389 | |||
390 | dinfo = MHD_digest_auth_get_request_info3 (connection); | ||
391 | if (NULL == dinfo) | ||
392 | mhdErrorExitDesc ("MHD_digest_auth_get_username3() returned NULL"); | ||
393 | else if (NULL == dinfo->username) | 401 | else if (NULL == dinfo->username) |
394 | mhdErrorExitDesc ("'username' is NULL"); | 402 | mhdErrorExitDesc ("'username' is NULL"); |
395 | else if (dinfo->username_len != MHD_STATICSTR_LEN_ (USERNAME)) | 403 | else if (dinfo->username_len != MHD_STATICSTR_LEN_ (USERNAME)) |
@@ -413,14 +421,6 @@ ahc_echo (void *cls, | |||
413 | mhdErrorExitDesc ("'userhash_bin' is NOT NULL"); | 421 | mhdErrorExitDesc ("'userhash_bin' is NOT NULL"); |
414 | else if (0 != dinfo->userhash_bin_size) | 422 | else if (0 != dinfo->userhash_bin_size) |
415 | mhdErrorExitDesc ("'userhash_bin_size' is NOT zero"); | 423 | mhdErrorExitDesc ("'userhash_bin_size' is NOT zero"); |
416 | else if (MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED != dinfo->uname_type) | ||
417 | { | ||
418 | fprintf (stderr, "Unexpected 'uname_type'.\n" | ||
419 | "Expected: %d\tRecieved: %d. ", | ||
420 | (int) MHD_DIGEST_AUTH_UNAME_TYPE_EXTENDED, | ||
421 | (int) dinfo->uname_type); | ||
422 | mhdErrorExitDesc ("Wrong 'uname_type'"); | ||
423 | } | ||
424 | else if (MHD_DIGEST_AUTH_ALGO3_MD5 != dinfo->algo) | 424 | else if (MHD_DIGEST_AUTH_ALGO3_MD5 != dinfo->algo) |
425 | { | 425 | { |
426 | fprintf (stderr, "Unexpected 'algo'.\n" | 426 | fprintf (stderr, "Unexpected 'algo'.\n" |
@@ -485,7 +485,8 @@ ahc_echo (void *cls, | |||
485 | } | 485 | } |
486 | MHD_free (dinfo); | 486 | MHD_free (dinfo); |
487 | 487 | ||
488 | check_res = MHD_digest_auth_check3 (connection, REALM, USERNAME, PASSWORD, | 488 | check_res = MHD_digest_auth_check3 (connection, REALM, USERNAME, |
489 | PASSWORD_VALUE, | ||
489 | 300, MHD_DIGEST_ALG_MD5); | 490 | 300, MHD_DIGEST_ALG_MD5); |
490 | 491 | ||
491 | switch (check_res) | 492 | switch (check_res) |
@@ -563,7 +564,8 @@ ahc_echo (void *cls, | |||
563 | } | 564 | } |
564 | MHD_free (username); | 565 | MHD_free (username); |
565 | 566 | ||
566 | check_res = MHD_digest_auth_check (connection, REALM, USERNAME, PASSWORD, | 567 | check_res = MHD_digest_auth_check (connection, REALM, USERNAME, |
568 | PASSWORD_VALUE, | ||
567 | 300); | 569 | 300); |
568 | 570 | ||
569 | if (MHD_INVALID_NONCE != check_res) | 571 | if (MHD_INVALID_NONCE != check_res) |