Skip to content

Commit 387d4ba

Browse files
committed
T6013: fix code format
1 parent 4b14d9d commit 387d4ba

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

smoketest/scripts/cli/test_service_ssh.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
key_dsa = '/etc/ssh/ssh_host_dsa_key'
4040
key_ed25519 = '/etc/ssh/ssh_host_ed25519_key'
4141
trusted_user_ca_key = '/etc/ssh/trusted_user_ca_key'
42-
authorized_principals = '/etc/ssh/authorized_principals'
42+
authorized_principals_dir = '/etc/ssh/authorized_principals'
43+
4344

4445
def get_config_value(key):
4546
tmp = read_file(SSHD_CONF)
@@ -381,21 +382,23 @@ def test_ssh_trusted_user_ca_key(self):
381382
trusted_user_ca_key_config = get_config_value('TrustedUserCAKeys')
382383
self.assertIn(trusted_user_ca_key, trusted_user_ca_key_config)
383384
authorize_principals_file_config = get_config_value('AuthorizedPrincipalsFile')
384-
self.assertIn("none", authorize_principals_file_config)
385+
self.assertIn('none', authorize_principals_file_config)
385386

386387
with open(trusted_user_ca_key, 'r') as file:
387388
ca_key_contents = file.read()
388389
self.assertIn(ca_root_cert_data, ca_key_contents)
389390

390-
self.cli_delete(base_path + ['trusted-user-ca-key', 'ca-certificate', ca_cert_name])
391+
self.cli_delete(
392+
base_path + ['trusted-user-ca-key', 'ca-certificate', ca_cert_name]
393+
)
391394
self.cli_delete(['pki', 'ca', ca_cert_name])
392395
self.cli_commit()
393396

394397
# Verify the CA key is removed
395398
trusted_user_ca_key_config = get_config_value('TrustedUserCAKeys')
396399
self.assertNotIn(trusted_user_ca_key, trusted_user_ca_key_config)
397400
authorize_principals_file_config = get_config_value('AuthorizedPrincipalsFile')
398-
self.assertNotIn("none", authorize_principals_file_config)
401+
self.assertNotIn('none', authorize_principals_file_config)
399402

400403
def test_ssh_trusted_user_ca_key_and_bind_user_with_principal(self):
401404
ca_cert_name = 'test_ca'
@@ -435,13 +438,19 @@ def test_ssh_trusted_user_ca_key_and_bind_user_with_principal(self):
435438
for principal in principals:
436439
self.cli_set(
437440
base_path
438-
+ ['trusted-user-ca-key', 'bind-user', bind_user, 'principal', principal]
441+
+ [
442+
'trusted-user-ca-key',
443+
'bind-user',
444+
bind_user,
445+
'principal',
446+
principal,
447+
]
439448
)
440449
self.cli_commit()
441450

442451
trusted_user_ca_key_config = get_config_value('TrustedUserCAKeys')
443452
self.assertIn(trusted_user_ca_key, trusted_user_ca_key_config)
444-
authorized_principals_file = f'{authorized_principals}/{bind_user}'
453+
authorized_principals_file = f'{authorized_principals_dir}/{bind_user}'
445454
self.assertTrue(os.path.exists(authorized_principals_file))
446455

447456
with open(authorized_principals_file, 'r') as file:
@@ -452,16 +461,25 @@ def test_ssh_trusted_user_ca_key_and_bind_user_with_principal(self):
452461
for principal in principals:
453462
self.cli_delete(
454463
base_path
455-
+ ['trusted-user-ca-key', 'bind-user', bind_user, 'principal', principal]
464+
+ [
465+
'trusted-user-ca-key',
466+
'bind-user',
467+
bind_user,
468+
'principal',
469+
principal,
470+
]
456471
)
457472

458-
self.cli_delete(base_path + ['trusted-user-ca-key', 'ca-certificate', ca_cert_name])
473+
self.cli_delete(
474+
base_path + ['trusted-user-ca-key', 'ca-certificate', ca_cert_name]
475+
)
459476
self.cli_delete(['pki', 'ca', ca_cert_name])
460477
self.cli_delete(['system', 'login', 'user', test_user])
461478
self.cli_commit()
462479

463480
# Verify the authorized principals file is removed
464481
self.assertFalse(os.path.exists(authorized_principals_file))
465482

483+
466484
if __name__ == '__main__':
467485
unittest.main(verbosity=2)

src/conf_mode/service_ssh.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def cleanup_authorized_principal_dir(valid_users: list[str]):
6262
if not os.listdir(authorized_principal):
6363
os.rmdir(authorized_principal)
6464

65+
6566
def handle_trusted_user_ca_key(ssh: dict):
6667
if 'trusted_user_ca_key' not in ssh:
6768
if os.path.exists(trusted_user_ca_key):
@@ -131,7 +132,8 @@ def get_config(config=None):
131132
)
132133
login_users_base = ['system', 'login', 'user']
133134
login_users = conf.get_config_dict(
134-
login_users_base, key_mangling=('-', '_'),
135+
login_users_base,
136+
key_mangling=('-', '_'),
135137
no_tag_node_value_mangle=True,
136138
get_first_key=True,
137139
)

0 commit comments

Comments
 (0)