Validate cell characters and digit/period sanity
Halt import on control characters or a ':'/'/' inside an issuer or account (they collide with the OATH issuer:account separator and period/ prefix), on a composed name over 64 bytes with a clearer per-field message, and on a digit count outside 6-8 or a non-positive period.
This commit is contained in:
24
test_oath.py
24
test_oath.py
@@ -173,6 +173,30 @@ class TestValidateInput(unittest.TestCase):
|
||||
self.assertTrue(any("sha512" in p.lower() or "algorithm" in p.lower()
|
||||
for p in problems))
|
||||
|
||||
def test_control_char_in_account_reported(self):
|
||||
problems = validate_input([cred(account="a\x01b")])
|
||||
self.assertTrue(any("control" in p.lower() for p in problems))
|
||||
|
||||
def test_colon_in_issuer_reported(self):
|
||||
problems = validate_input([cred(issuer="Goo:gle")])
|
||||
self.assertTrue(any(":" in p and "issuer" in p.lower() for p in problems))
|
||||
|
||||
def test_slash_in_account_reported(self):
|
||||
problems = validate_input([cred(account="a/b")])
|
||||
self.assertTrue(any("/" in p and "account" in p.lower() for p in problems))
|
||||
|
||||
def test_digits_out_of_range_reported(self):
|
||||
problems = validate_input([cred(digits=9)])
|
||||
self.assertTrue(any("digit" in p.lower() for p in problems))
|
||||
|
||||
def test_bad_period_reported(self):
|
||||
problems = validate_input([cred(period=0)])
|
||||
self.assertTrue(any("period" in p.lower() for p in problems))
|
||||
|
||||
def test_tab_is_control_char(self):
|
||||
problems = validate_input([cred(issuer="Goo\tgle")])
|
||||
self.assertTrue(any("control" in p.lower() for p in problems))
|
||||
|
||||
|
||||
class TestLoadCredentials(unittest.TestCase):
|
||||
def _make_xlsx(self, rows):
|
||||
|
||||
Reference in New Issue
Block a user