Ver código fonte

test_authentication: do not use SHA-256 if libcurl does not support it

Evgeny Grin (Karlson2k) 1 ano atrás
pai
commit
28d50dbd7a

+ 12 - 0
src/tests/client_server/libtest_convenience_server_reply.c

@@ -35,6 +35,14 @@
 #include <curl/curl.h>
 #include <assert.h>
 
+#ifndef CURL_VERSION_BITS
+#  define CURL_VERSION_BITS(x,y,z) ((x) << 16 | (y) << 8 | (z))
+#endif
+#ifndef CURL_AT_LEAST_VERSION
+#  define CURL_AT_LEAST_VERSION(x,y,z) \
+        (LIBCURL_VERSION_NUM >= CURL_VERSION_BITS (x, y, z))
+#endif
+
 const struct MHD_Action *
 MHDT_server_reply_text (
   void *cls,
@@ -799,7 +807,11 @@ MHDT_server_reply_check_digest_auth (
   const char *password;
   enum MHD_DigestAuthResult dar;
   const char *realm = "test-realm";
+#if CURL_AT_LEAST_VERSION (7,57,0)
   enum MHD_DigestAuthAlgo algo = MHD_DIGEST_AUTH_ALGO_SHA256;
+#else
+  enum MHD_DigestAuthAlgo algo = MHD_DIGEST_AUTH_ALGO_MD5;
+#endif
   size_t digest_len = MHD_digest_get_hash_size (algo);
 
   if (0 == digest_len)