Skip to content

Commit

Permalink
Merge pull request #405 from candlepin/jhnidek/fix_configparser_issue
Browse files Browse the repository at this point in the history
fix: Use ConfigParser and not SafeConfigParser
  • Loading branch information
m-horky authored Jan 22, 2024
2 parents 8837211 + 32bd8ac commit 89db8ff
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
5 changes: 4 additions & 1 deletion tests/complex/fake_sam.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 2 additions & 0 deletions tests/complex/test_esx_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/test_satellite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions virtwho/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 89db8ff

Please sign in to comment.