@@ -49,6 +49,50 @@ def test_delete_credential_at(at_command_interface):
4949 at_command_interface .delete_credential (sectag = 42 , cred_type = CredType .CLIENT_CERT .value )
5050 at_command_interface .comms .write_line .assert_called_once_with ('AT%CMNG=3,42,1' )
5151
52+ def test_delete_credential_tls (tls_cred_shell_interface ):
53+ """Test deleting a credential that exists in TLS shell"""
54+ tls_cred_shell_interface .comms .write_line = Mock ()
55+ tls_cred_shell_interface .comms .expect_response .return_value = (True , '' )
56+ tls_cred_shell_interface .delete_credential (sectag = 42 , cred_type = CredType .ROOT_CA_CERT .value )
57+ tls_cred_shell_interface .comms .write_line .assert_called_once_with ('cred del 42 CA' )
58+
59+ def test_delete_credential_tls_not_found (tls_cred_shell_interface ):
60+ """Test deleting a credential that does not exist in TLS shell"""
61+ tls_cred_shell_interface .comms .write_line = Mock ()
62+ tls_cred_shell_interface .comms .expect_response .return_value = (False , '' )
63+ tls_cred_shell_interface .delete_credential (sectag = 42 , cred_type = CredType .ROOT_CA_CERT .value )
64+ tls_cred_shell_interface .comms .write_line .assert_called_once_with ('cred del 42 CA' )
65+
66+ def test_check_credential_exists_tls (tls_cred_shell_interface ):
67+ """Test checking a credential that exists in TLS shell"""
68+ tls_cred_shell_interface .comms .write_line = Mock ()
69+ tls_cred_shell_interface .comms .expect_response .return_value = (True , '42,CA,qLqL2kIyuj7FF9aFXQuhmc8kbMOHNYsM451gElqNyVQ=,0\r \n ' )
70+ result , hash = tls_cred_shell_interface .check_credential_exists (sectag = 42 , cred_type = CredType .ROOT_CA_CERT .value , get_hash = True )
71+ tls_cred_shell_interface .comms .write_line .assert_called_once_with ('cred list 42 CA' )
72+ assert hash == 'qLqL2kIyuj7FF9aFXQuhmc8kbMOHNYsM451gElqNyVQ='
73+ assert result == True
74+
75+ def test_check_credential_exists_tls_not_found (tls_cred_shell_interface ):
76+ """Test checking a credential that does not exist in TLS shell"""
77+ tls_cred_shell_interface .comms .write_line = Mock ()
78+ tls_cred_shell_interface .comms .expect_response .return_value = (False , '' )
79+ result , hash = tls_cred_shell_interface .check_credential_exists (sectag = 42 , cred_type = CredType .ROOT_CA_CERT .value , get_hash = True )
80+ tls_cred_shell_interface .comms .write_line .assert_called_once_with ('cred list 42 CA' )
81+ assert hash == None
82+ assert result == False
83+
84+ def test_write_credential_tls (tls_cred_shell_interface ):
85+ """Test writing a credential using TLSCredShellInterface"""
86+ tls_cred_shell_interface .comms .write_line = Mock ()
87+ tls_cred_shell_interface .comms .expect_response .side_effect = [
88+ (True , "" ),
89+ (True , "" )
90+ ]
91+ result = tls_cred_shell_interface .write_credential (sectag = 42 , cred_type = CredType .CLIENT_CERT .value , cred_text = 'test_value' )
92+ assert result == True
93+ assert tls_cred_shell_interface .comms .write_line .call_count >= 3
94+
95+
5296def test_check_credential_exists_at (at_command_interface ):
5397 """Test checking if a credential exists using ATCommandInterface"""
5498 at_command_interface .comms .write_line = Mock ()
0 commit comments