]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tests:gpo: drop unused mock requests module
authorDouglas Bagnall <douglas.bagnall@catalyst.net.nz>
Wed, 27 May 2026 22:37:34 +0000 (10:37 +1200)
committerStefan Metzmacher <metze@samba.org>
Thu, 28 May 2026 17:39:48 +0000 (17:39 +0000)
Since 4c2db6489be1364a8ce2841f7eedcd976fa1463b (for CVE-2026-3012)
gp_cert_auto_enroll_ext does not use the requests module, so for the
test we no longer need to intercept it using monkey patching.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
python/samba/tests/gpo.py

index 5bdee29b50af7f74e2f782790a14fe2ece07e961..35432b5c9620005522426304aeb8ab466ae53d31 100644 (file)
@@ -69,7 +69,6 @@ import ldb as _ldb
 from samba.auth import system_session
 import json
 from shutil import which
-import requests
 from cryptography import x509
 from cryptography.hazmat.primitives import hashes
 from cryptography.hazmat.backends import default_backend
@@ -103,22 +102,6 @@ def dummy_certificate():
 
     return cert.public_bytes(encoding=Encoding.DER)
 
-# Dummy requests structure for Certificate Auto Enrollment
-class dummy_requests(object):
-    class exceptions(object):
-        ConnectionError = Exception
-
-    def __init__(self, want_exception=False):
-        self.want_exception = want_exception
-
-    def get(self, url=None, params=None):
-        if self.want_exception:
-            raise self.exceptions.ConnectionError
-
-        dummy = requests.Response()
-        dummy._content = dummy_certificate()
-        dummy.headers = {'Content-Type': 'application/x-x509-ca-cert'}
-        return dummy
 
 realm = os.environ.get('REALM')
 policies = realm + '/POLICIES'
@@ -6925,7 +6908,6 @@ class GPOTests(tests.TestCase):
         machine_creds.set_machine_account()
 
         # Initialize the group policy extension
-        cae.requests = dummy_requests(want_exception=True)
         ext = cae.gp_cert_auto_enroll_ext(self.lp, machine_creds,
                                           machine_creds.get_username(), store)
 
@@ -7032,7 +7014,6 @@ class GPOTests(tests.TestCase):
         machine_creds.set_machine_account()
 
         # Initialize the group policy extension
-        cae.requests = dummy_requests()
         ext = cae.gp_cert_auto_enroll_ext(self.lp, machine_creds,
                                           machine_creds.get_username(), store)
 
@@ -7633,7 +7614,6 @@ class GPOTests(tests.TestCase):
         machine_creds.set_machine_account()
 
         # Initialize the group policy extension
-        cae.requests = dummy_requests()
         ext = cae.gp_cert_auto_enroll_ext(self.lp, machine_creds,
                                           machine_creds.get_username(), store)