Skip to content

Commit

Permalink
Fix Python flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
edewata committed Jan 22, 2025
1 parent 7c7dd12 commit c0ceb9b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ca-ssnv2-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ jobs:
Loading deployment configuration from /usr/share/pki/server/examples/installation/ca.cfg.
Installing CA into /var/lib/pki/pki-tomcat.
Installation failed: pki_serial_number_range_start format not valid, expecting 0x...
Installation failed: pki_serial_number_range_start must start with 0x
EOF
Expand Down
4 changes: 2 additions & 2 deletions base/common/python/pki/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def __init__(self, parent, subsystem=None):
if isinstance(parent, pki.client.PKIConnection):

logger.warning(
'%s:%s: The PKIConnection parameter in AccountClient.__init__() has been deprecated. '
'Provide PKIClient instead.',
'%s:%s: The PKIConnection parameter in AccountClient.__init__() '
'has been deprecated. Provide PKIClient instead.',
inspect.stack()[1].filename, inspect.stack()[1].lineno)

self.subsystem_client = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ def check(self):

# Make a plain HTTPS GET to retrieve KRA transport cert, to test that
# the server is up AND is able to respond back
connection = pki.client.PKIConnection(protocol='https',
hostname='localhost',
port=https_port,
verify=False)
connection = pki.client.PKIConnection(
protocol='https',
hostname='localhost',
port=https_port,
verify=False)

system_cert_client = pki.systemcert.SystemCertClient(connection)

Expand Down
6 changes: 4 additions & 2 deletions base/server/python/pki/server/cli/acme.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,8 @@ def execute(self, argv, args=None):
print('Enter ID of the authority for issuing ACME certificates '
'(empty for main CA, subCA ID otherwise).')
authority_id = config.get('authority-id')
authority_id = pki.util.read_text(' Authority ID', default=authority_id, required=True)
authority_id = pki.util.read_text(
' Authority ID', default=authority_id, required=True)
if authority_id:
pki.util.set_property(config, 'authority-id', authority_id)

Expand All @@ -1222,7 +1223,8 @@ def execute(self, argv, args=None):
print('Enter DN of the authority for issuing ACME certificates '
'(empty for main CA, subCA DN otherwise).')
authority_dn = config.get('authority-dn')
authority_dn = pki.util.read_text(' Authority ID', default=authority_id, required=True)
authority_dn = pki.util.read_text(
' Authority ID', default=authority_id, required=True)
if authority_dn:
pki.util.set_property(config, 'authority-dn', authority_dn)

Expand Down
2 changes: 1 addition & 1 deletion base/server/python/pki/server/cli/cert.py
Original file line number Diff line number Diff line change
Expand Up @@ -1250,7 +1250,7 @@ def execute(self, argv, args=None):
if args.cert:
all_certs = False
fix_certs.append(args.cert)

if args.extra_cert:
# TODO: add support for hex serial number
try:
Expand Down
19 changes: 9 additions & 10 deletions base/server/python/pki/server/deployment/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,39 +1264,38 @@ def configure_ca(self, subsystem):
serial_number_range_start = self.mdict.get('pki_serial_number_range_start')
if serial_number_range_start:
if not serial_number_range_start.startswith('0x'):
raise Exception('pki_serial_number_range_start format not valid, expecting 0x...')
raise Exception('pki_serial_number_range_start must start with 0x')
subsystem.set_config('dbs.beginSerialNumber', serial_number_range_start)

serial_number_range_end = self.mdict.get('pki_serial_number_range_end')
if serial_number_range_end:
if not serial_number_range_end.startswith('0x'):
raise Exception('pki_serial_number_range_end format not valid, expecting 0x...')
raise Exception('pki_serial_number_range_end must start with 0x')
subsystem.set_config('dbs.endSerialNumber', serial_number_range_end)

serial_increment = self.mdict.get('pki_serial_number_range_increment')
if serial_increment:
if not serial_increment.startswith('0x'):
raise Exception('pki_serial_number_range_increment format not valid, expecting 0x...')
raise Exception('pki_serial_number_range_increment must start with 0x')
subsystem.set_config('dbs.serialIncrement', serial_increment)

serial_minimum = self.mdict.get('pki_serial_number_range_minimum')
if serial_minimum:
if not serial_minimum.startswith('0x'):
raise Exception('pki_serial_number_range_minimum format not valid, expecting 0x...')
raise Exception('pki_serial_number_range_minimum must start with 0x')
subsystem.set_config('dbs.serialLowWaterMark', serial_minimum)

serial_transfer = self.mdict.get('pki_serial_number_range_transfer')
if serial_transfer:
if not serial_transfer.startswith('0x'):
raise Exception('pki_serial_number_range_transfer format not valid, expecting 0x...')
raise Exception('pki_serial_number_range_transfer must start with 0x')
subsystem.set_config('dbs.serialCloneTransferNumber', serial_transfer)

subsystem.set_config('dbs.serialRangeDN', 'ou=certificateRepository,ou=ranges_v2')

else: # random
subsystem.set_config('dbs.cert.id.length', self.mdict['pki_cert_id_length'])


replica_number_range_start = self.mdict.get('pki_replica_number_range_start')
if replica_number_range_start:
subsystem.set_config('dbs.beginReplicaNumber', replica_number_range_start)
Expand Down Expand Up @@ -5191,10 +5190,10 @@ def restore_selinux_contexts(self):
# The restocon API is not working in RHEL
# (see https://issues.redhat.com/browse/RHEL-73348).
#
#selinux.restorecon(self.instance.base_dir, True)
#selinux.restorecon(config.PKI_DEPLOYMENT_LOG_ROOT, True)
#selinux.restorecon(self.instance.actual_logs_dir, True)
#selinux.restorecon(self.instance.actual_conf_dir, True)
# selinux.restorecon(self.instance.base_dir, True)
# selinux.restorecon(config.PKI_DEPLOYMENT_LOG_ROOT, True)
# selinux.restorecon(self.instance.actual_logs_dir, True)
# selinux.restorecon(self.instance.actual_conf_dir, True)
folders = [
self.instance.base_dir,
config.PKI_DEPLOYMENT_LOG_ROOT,
Expand Down

0 comments on commit c0ceb9b

Please sign in to comment.