3939key_dsa = '/etc/ssh/ssh_host_dsa_key'
4040key_ed25519 = '/etc/ssh/ssh_host_ed25519_key'
4141trusted_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
4445def 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+
466484if __name__ == '__main__' :
467485 unittest .main (verbosity = 2 )
0 commit comments