Переглянути джерело

Updated tests to use new digest auth functions

Evgeny Grin (Karlson2k) 3 роки тому
батько
коміт
a09b252494

+ 4 - 5
src/testcurl/test_digestauth.c

@@ -265,7 +265,7 @@ ahc_echo (void *cls,
   const char *password = "testpass";
   const char *realm = "[email protected]";
   enum MHD_Result ret;
-  int ret_i;
+  enum MHD_DigestAuthResult ret_e;
   static int already_called_marker;
   (void) cls; (void) url;                         /* Unused. Silent compiler warning. */
   (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
@@ -298,15 +298,14 @@ ahc_echo (void *cls,
     MHD_destroy_response (response);
     return ret;
   }
-  ret_i = MHD_digest_auth_check2 (connection,
+  ret_e = MHD_digest_auth_check3 (connection,
                                   realm,
                                   username,
                                   password,
                                   300,
                                   MHD_DIGEST_ALG_MD5);
   MHD_free (username);
-  if ( (ret_i == MHD_INVALID_NONCE) ||
-       (ret_i == MHD_NO) )
+  if (ret_e != MHD_DAUTH_OK)
   {
     response = MHD_create_response_from_buffer (strlen (DENIED),
                                                 DENIED,
@@ -317,7 +316,7 @@ ahc_echo (void *cls,
                                          realm,
                                          MY_OPAQUE,
                                          response,
-                                         (MHD_INVALID_NONCE == ret_i) ?
+                                         (MHD_DAUTH_NONCE_STALE == ret_e) ?
                                          MHD_YES : MHD_NO,
                                          MHD_DIGEST_ALG_MD5);
     if (MHD_YES != ret)

+ 4 - 5
src/testcurl/test_digestauth_concurrent.c

@@ -276,7 +276,7 @@ ahc_echo (void *cls,
   const char *password = "testpass";
   const char *realm = "[email protected]";
   enum MHD_Result ret;
-  int ret_i;
+  enum MHD_DigestAuthResult ret_e;
   static int already_called_marker;
   (void) cls; (void) url;                         /* Unused. Silent compiler warning. */
   (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
@@ -309,15 +309,14 @@ ahc_echo (void *cls,
     MHD_destroy_response (response);
     return ret;
   }
-  ret_i = MHD_digest_auth_check2 (connection,
+  ret_e = MHD_digest_auth_check3 (connection,
                                   realm,
                                   username,
                                   password,
                                   300,
                                   MHD_DIGEST_ALG_MD5);
   MHD_free (username);
-  if ( (ret_i == MHD_INVALID_NONCE) ||
-       (ret_i == MHD_NO) )
+  if (ret_e != MHD_DAUTH_OK)
   {
     response = MHD_create_response_from_buffer (strlen (DENIED),
                                                 DENIED,
@@ -328,7 +327,7 @@ ahc_echo (void *cls,
                                          realm,
                                          MY_OPAQUE,
                                          response,
-                                         (MHD_INVALID_NONCE == ret_i) ?
+                                         (MHD_DAUTH_NONCE_STALE == ret_e) ?
                                          MHD_YES : MHD_NO,
                                          MHD_DIGEST_ALG_MD5);
     if (MHD_YES != ret)

+ 4 - 5
src/testcurl/test_digestauth_sha256.c

@@ -94,7 +94,7 @@ ahc_echo (void *cls,
   const char *password = "testpass";
   const char *realm = "[email protected]";
   enum MHD_Result ret;
-  int ret_i;
+  enum MHD_DigestAuthResult ret_e;
   static int already_called_marker;
   (void) cls; (void) url;                         /* Unused. Silent compiler warning. */
   (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
@@ -123,15 +123,14 @@ ahc_echo (void *cls,
     MHD_destroy_response (response);
     return ret;
   }
-  ret_i = MHD_digest_auth_check2 (connection,
+  ret_e = MHD_digest_auth_check3 (connection,
                                   realm,
                                   username,
                                   password,
                                   300,
                                   MHD_DIGEST_ALG_SHA256);
   MHD_free (username);
-  if ( (ret_i == MHD_INVALID_NONCE) ||
-       (ret_i == MHD_NO) )
+  if (ret_e != MHD_DAUTH_OK)
   {
     response = MHD_create_response_from_buffer (strlen (DENIED),
                                                 DENIED,
@@ -142,7 +141,7 @@ ahc_echo (void *cls,
                                          realm,
                                          MY_OPAQUE,
                                          response,
-                                         (MHD_INVALID_NONCE == ret_i) ?
+                                         (MHD_DAUTH_NONCE_STALE == ret_e) ?
                                          MHD_YES : MHD_NO,
                                          MHD_DIGEST_ALG_SHA256);
     MHD_destroy_response (response);

+ 8 - 8
src/testcurl/test_digestauth_with_arguments.c

@@ -87,7 +87,7 @@ ahc_echo (void *cls,
   const char *password = "testpass";
   const char *realm = "[email protected]";
   enum MHD_Result ret;
-  int ret_i;
+  enum MHD_DigestAuthResult ret_e;
   static int already_called_marker;
   (void) cls; (void) url;                         /* Unused. Silent compiler warning. */
   (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
@@ -115,13 +115,13 @@ ahc_echo (void *cls,
     MHD_destroy_response (response);
     return ret;
   }
-  ret_i = MHD_digest_auth_check (connection, realm,
-                                 username,
-                                 password,
-                                 300);
+  ret_e = MHD_digest_auth_check3 (connection, realm,
+                                  username,
+                                  password,
+                                  300,
+                                  MHD_DIGEST_ALG_MD5);
   MHD_free (username);
-  if ( (ret_i == MHD_INVALID_NONCE) ||
-       (ret_i == MHD_NO) )
+  if (ret_e != MHD_DAUTH_OK)
   {
     response = MHD_create_response_from_buffer (strlen (DENIED),
                                                 DENIED,
@@ -131,7 +131,7 @@ ahc_echo (void *cls,
     ret = MHD_queue_auth_fail_response2 (connection, realm,
                                          MY_OPAQUE,
                                          response,
-                                         (ret_i == MHD_INVALID_NONCE) ?
+                                         (ret_e == MHD_DAUTH_NONCE_STALE) ?
                                          MHD_YES : MHD_NO,
                                          MHD_DIGEST_ALG_MD5);
     MHD_destroy_response (response);