From 14bd3c7dc256e850d38b8e389b0232a1289ab89e Mon Sep 17 00:00:00 2001 From: Jiri Hnidek Date: Thu, 18 Jan 2024 14:20:17 +0100 Subject: [PATCH 1/4] fix: Use ConfigParser and not SafeConfigParser * Card ID: CCT-263 * The SafeConfigParser was deprecated in Python 3.2. This class was renamed to ConfigParser --- virtwho/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/virtwho/config.py b/virtwho/config.py index 3acf2074..602e0da8 100644 --- a/virtwho/config.py +++ b/virtwho/config.py @@ -25,7 +25,7 @@ import uuid import requests -from configparser import SafeConfigParser +from configparser import ConfigParser from configparser import DuplicateOptionError, NoOptionError, Error, MissingSectionHeaderError from virtwho import log, SAT5, SAT6 @@ -236,10 +236,10 @@ class DefaultDestinationInfo(Info): default_destination_info.name = "default_destination" -class StripQuotesConfigParser(SafeConfigParser): +class StripQuotesConfigParser(ConfigParser): def get(self, section, option, **kwargs): - # Don't call super, SafeConfigParser is not inherited from object - value = SafeConfigParser.get(self, section, option, **kwargs) + # Don't call super, ConfigParser is not inherited from object + value = ConfigParser.get(self, section, option, **kwargs) for quote in ('"', "'"): # Strip the quotes only when the value starts with quote, # ends with quote but doesn't contain it inside From 2ffc96bf906817270f734038145bcac87877a113 Mon Sep 17 00:00:00 2001 From: Jiri Hnidek Date: Thu, 18 Jan 2024 14:54:48 +0100 Subject: [PATCH 2/4] fix: stylish issue discovered by flake8 --- tests/test_satellite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_satellite.py b/tests/test_satellite.py index c339a260..70070c95 100644 --- a/tests/test_satellite.py +++ b/tests/test_satellite.py @@ -32,7 +32,7 @@ from base import TestBase -from virtwho.config import DestinationToSourceMapper, EffectiveConfig, ConfigSection,\ +from virtwho.config import DestinationToSourceMapper, EffectiveConfig, ConfigSection, \ parse_file, Satellite5DestinationInfo, VirtConfigSection from virtwho.manager import Manager from virtwho.manager.satellite import Satellite, SatelliteError From 7896f0fe6db0c5d3eaa087f30802833ba233ccc9 Mon Sep 17 00:00:00 2001 From: Jiri Hnidek Date: Fri, 19 Jan 2024 09:45:41 +0100 Subject: [PATCH 3/4] fix: use ssl.SSLContext.wrap_socket for wrapping socket * ssl.wrap_socket() was marked as deprecated in Python 3.7 * It stopped to work in Python 3.12 * We use it only for unit tests --- tests/complex/fake_sam.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/complex/fake_sam.py b/tests/complex/fake_sam.py index 94274092..b5967f9c 100644 --- a/tests/complex/fake_sam.py +++ b/tests/complex/fake_sam.py @@ -103,7 +103,10 @@ def __init__(self, queue, port=None, code=None, host='localhost'): raise OSError("No such file %s" % certfile) if not os.access(keyfile, os.R_OK): raise OSError("No such file %s" % keyfile) - self.server.socket = ssl.wrap_socket(self.server.socket, certfile=certfile, keyfile=keyfile, server_side=True) + ssl_ctx = ssl.create_default_context() + ssl_ctx.load_cert_chain(certfile=certfile, keyfile=keyfile) + ssl_ctx.check_hostname = False + self.server.socket = ssl_ctx.wrap_socket(self.server.socket, server_side=True) self.tempdir = tempfile.mkdtemp() config_name = os.path.join(self.tempdir, 'rhsm.conf') From 32bd8acac96e9ef98b23130c84c2c774d0e7d158 Mon Sep 17 00:00:00 2001 From: Jiri Hnidek Date: Fri, 19 Jan 2024 10:01:53 +0100 Subject: [PATCH 4/4] fix: disable complex tests for ESX * Such tests should not be part of unit tests, because these tests looks like more like integration tests --- tests/complex/test_esx_complex.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/complex/test_esx_complex.py b/tests/complex/test_esx_complex.py index 32b2b6c7..fe46b0d2 100644 --- a/tests/complex/test_esx_complex.py +++ b/tests/complex/test_esx_complex.py @@ -21,12 +21,14 @@ import os import tempfile import shutil +import pytest import virtwhotest from fake_esx import FakeEsx +@pytest.mark.skip(reason="This is not unit test. It is integration test. We should not do it here.") class EsxTest(virtwhotest.TestBase): """ Class for complex testing of obtaining host-to-guest mapping from fake ESX server