MCPcopy Create free account
hub / github.com/dbcli/mycli / test_corrupted_pad

Function test_corrupted_pad

test/pytests/test_config.py:74–97  ·  view source on GitHub ↗

Tests that a login path file with a corrupted pad is partially read.

()

Source from the content-addressed store, hash-verified

72
73
74def test_corrupted_pad():
75 """Tests that a login path file with a corrupted pad is partially read."""
76 buf = open_bmylogin_cnf(LOGIN_PATH_FILE)
77
78 # Skip past the login key
79 buf.seek(24)
80
81 # Skip option group
82 len_buf = buf.read(4)
83 (cipher_len,) = struct.unpack("<i", len_buf)
84 buf.read(cipher_len)
85
86 # Corrupt the pad for the user line
87 len_buf = buf.read(4)
88 (cipher_len,) = struct.unpack("<i", len_buf)
89 buf.read(cipher_len - 1)
90 buf.write(b"\0")
91
92 buf.seek(0)
93 mylogin_cnf = TextIOWrapper(read_and_decrypt_mylogin_cnf(buf))
94 contents = mylogin_cnf.read()
95 for word in ("[test]", "password", "host", "port"):
96 assert word in contents
97 assert "user" not in contents
98
99
100def test_get_mylogin_cnf_path(monkeypatch):

Callers

nothing calls this directly

Calls 4

open_bmylogin_cnfFunction · 0.85
readMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected