From af223569ea7c1202d380848404a82cb47c5928b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= Date: Thu, 11 Jul 2024 09:47:37 +0200 Subject: [PATCH] tests: Adapt to CURL without NTLM support If CURL is built without NTLM support (e.g. if libcurl-minimal RPM package is installed instead of libcurl on Fedora), tests/test_handle.c failed: /home/test/librepo/tests/test_handle.c:61:F:Main:test_handle:0: Assertion 'lr_handle_setopt(h, ((void *)0), LRO_HTTPAUTHMETHODS, LR_AUTH_NTLM)' failed The cause is that the test exhibing NTLM authentication also checks that lr_handle_setopt() succeeds. This patch stops checking a return value of lr_handle_setopt() in case of LR_AUTH_NTLM because a meaning of the test is checking for memory leaks. A similar issue was in python/tests/test_handle.py: ERROR: test_handle_setget_attr (tests.test_handle.TestCaseHandle.test_handle_setget_attr) No exception should be raised. ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/test/librepo/tests/python/tests/test_handle.py", line 477, in test_handle_setget_attr h.httpauthmethods = librepo.LR_AUTH_NTLM ^^^^^^^^^^^^^^^^^ File "/home/test/librepo/redhat-linux-build/librepo/python/librepo/__init__.py", line 1537, in __setattr__ self.setopt(ATTR_TO_LRO[attr], val) ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/test/librepo/redhat-linux-build/librepo/python/librepo/__init__.py", line 1529, in setopt _librepo.Handle.setopt(self, option, val) ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^ librepo.LibrepoException: (8, 'curl error: A requested feature, protocol or option was not found built-in in this libcurl due to a build-time decision.', 'An Curl handle error') This patch ignores excpetions with that error message. (I did not find a way of accessing fields of exception value directly.) --- tests/python/tests/test_handle.py | 16 ++++++++++++---- tests/test_handle.c | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/python/tests/test_handle.py b/tests/python/tests/test_handle.py index 36ae590d..a84de641 100644 --- a/tests/python/tests/test_handle.py +++ b/tests/python/tests/test_handle.py @@ -474,14 +474,22 @@ def test_handle_setget_attr(self): self.assertEqual(h.httpheader, None) self.assertEqual(h.httpauthmethods, librepo.LR_AUTH_BASIC) - h.httpauthmethods = librepo.LR_AUTH_NTLM - self.assertEqual(h.httpauthmethods, librepo.LR_AUTH_NTLM) + try: + h.httpauthmethods = librepo.LR_AUTH_NTLM + except librepo.LibrepoException as exception: + if not "not found built-in" in str(exception): + raise exception + self.assertEqual(h.httpauthmethods, librepo.LR_AUTH_NTLM) h.httpauthmethods = None self.assertEqual(h.httpauthmethods, librepo.LR_AUTH_BASIC) self.assertEqual(h.proxyauthmethods, librepo.LR_AUTH_BASIC) - h.proxyauthmethods = librepo.LR_AUTH_NTLM - self.assertEqual(h.proxyauthmethods, librepo.LR_AUTH_NTLM) + try: + h.proxyauthmethods = librepo.LR_AUTH_NTLM + except librepo.LibrepoException as exception: + if not "not found built-in" in str(exception): + raise exception + self.assertEqual(h.proxyauthmethods, librepo.LR_AUTH_NTLM) h.proxyauthmethods = None self.assertEqual(h.proxyauthmethods, librepo.LR_AUTH_BASIC) diff --git a/tests/test_handle.c b/tests/test_handle.c index 180cf49a..6da97090 100644 --- a/tests/test_handle.c +++ b/tests/test_handle.c @@ -58,7 +58,7 @@ START_TEST(test_handle) ck_assert(lr_handle_setopt(h, NULL, LRO_PROXY_SSLCLIENTCERT, "/etc/proxy_cert.pem")); ck_assert(lr_handle_setopt(h, NULL, LRO_PROXY_SSLCLIENTKEY, "/etc/proxy_cert.key")); ck_assert(lr_handle_setopt(h, NULL, LRO_PROXY_SSLCACERT, "/etc/proxy_ca.pem")); - ck_assert(lr_handle_setopt(h, NULL, LRO_HTTPAUTHMETHODS, LR_AUTH_NTLM)); + (void)lr_handle_setopt(h, NULL, LRO_HTTPAUTHMETHODS, LR_AUTH_NTLM); ck_assert(lr_handle_setopt(h, NULL, LRO_PROXYAUTHMETHODS, LR_AUTH_DIGEST)); lr_handle_free(h); }