Skip to content

Commit ea83763

Browse files
committed
test_totp_invalid_alphanumeric_code
1 parent 50600fb commit ea83763

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

vertica_python/tests/integration_tests/test_authentication.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,31 @@ def totp_invalid_format_scenario(self):
217217
cur.execute("DROP USER IF EXISTS totp_user")
218218
cur.execute("DROP AUTHENTICATION IF EXISTS totp_auth CASCADE")
219219

220+
def test_totp_invalid_alphanumeric_code(self):
221+
# Verify alphanumeric TOTP inputs return the explicit validation error
222+
with self._connect() as conn:
223+
cur = conn.cursor()
224+
225+
cur.execute("DROP USER IF EXISTS totp_user")
226+
cur.execute("DROP AUTHENTICATION IF EXISTS totp_auth CASCADE")
227+
228+
try:
229+
cur.execute("CREATE USER totp_user IDENTIFIED BY 'password' ENFORCEMFA")
230+
cur.execute("CREATE AUTHENTICATION totp_auth METHOD 'password' HOST '0.0.0.0/0'")
231+
cur.execute("GRANT AUTHENTICATION totp_auth TO totp_user")
232+
233+
self._conn_info['user'] = 'totp_user'
234+
self._conn_info['password'] = 'password'
235+
# Alphanumeric TOTP provided via driver parameter
236+
self._conn_info['totp'] = "ot123"
237+
238+
err_msg = "Invalid TOTP: Please enter a valid 6-digit numeric code"
239+
self.assertConnectionFail(err_msg=err_msg)
240+
241+
finally:
242+
cur.execute("DROP USER IF EXISTS totp_user")
243+
cur.execute("DROP AUTHENTICATION IF EXISTS totp_auth CASCADE")
244+
220245
# Negative Test: Wrong TOTP (Valid format, wrong value)
221246
def totp_wrong_code_scenario(self):
222247
with self._connect() as conn:

0 commit comments

Comments
 (0)