|
14 | 14 | class TestSecurityCipher(object): |
15 | 15 | def test_passkey_encryption(self): |
16 | 16 | with mock.patch("sonic_py_common.security_cipher.ConfigDBConnector", new=ConfigDBConnector), \ |
17 | | - mock.patch("builtins.open", mock_open()) as mock_file: |
| 17 | + mock.patch("builtins.open",mock.mock_open()) as mock_file: |
18 | 18 | temp = security_cipher() |
19 | 19 |
|
20 | 20 | # Use patch to replace the built-in 'open' function with a mock |
21 | | - with mock.patch("builtins.open", mock_open()) as mock_file: |
| 21 | + with mock.patch("builtins.open", mock.mock_open()) as mock_file: |
22 | 22 | encrypt, err = temp.encrypt_passkey("TACPLUS", "passkey1", "TEST1") |
23 | 23 | assert encrypt != "passkey1" |
24 | 24 | assert err == None |
25 | 25 |
|
26 | 26 | def test_passkey_decryption(self): |
27 | 27 | with mock.patch("sonic_py_common.security_cipher.ConfigDBConnector", new=ConfigDBConnector), \ |
28 | | - mock.patch("builtins.open", mock_open()) as mock_file: |
| 28 | + mock.patch("builtins.open", mock.mock_open()) as mock_file: |
29 | 29 | temp = security_cipher() |
30 | 30 |
|
31 | 31 | # Use patch to replace the built-in 'open' function with a mock |
32 | | - with mock.patch("builtins.open", mock_open()) as mock_file: |
| 32 | + with mock.patch("builtins.open", mock.mock_open()) as mock_file: |
33 | 33 | encrypt, err = temp.encrypt_passkey("RADIUS", "passkey2", EXPECTED_PASSWD) |
34 | 34 | assert err == None |
35 | 35 |
|
36 | 36 | # Use patch to replace the built-in 'open' function with a mock |
37 | | - with mock.patch("builtins.open", mock_open(read_data=EXPECTED_PASSWD)) as mock_file: |
| 37 | + with mock.patch("builtins.open", mock.mock_open(read_data=EXPECTED_PASSWD)) as mock_file: |
38 | 38 | decrypt, err = temp.decrypt_passkey("RADIUS", encrypt) |
39 | 39 | assert err == None |
40 | 40 | assert decrypt == "passkey2" |
|
0 commit comments