From ce44d621215ab718d643834367d312a0a4e74e24 Mon Sep 17 00:00:00 2001 From: andrecs <12188364+andrecsilva@users.noreply.github.com> Date: Tue, 24 Oct 2023 14:14:56 -0300 Subject: [PATCH] Removed sample database file, adjusted tests --- integration_tests/test_sql_parameterization.py | 10 +++++----- tests/samples/my_db.db | Bin 8192 -> 0 bytes tests/samples/sql_injection.py | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 tests/samples/my_db.db diff --git a/integration_tests/test_sql_parameterization.py b/integration_tests/test_sql_parameterization.py index 6e8cd9da..f27063fa 100644 --- a/integration_tests/test_sql_parameterization.py +++ b/integration_tests/test_sql_parameterization.py @@ -11,9 +11,9 @@ class TestSQLQueryParameterization(BaseIntegrationTest): original_code, expected_new_code = original_and_expected_from_code_path( code_path, [ - (7, """ b = " WHERE name =?"\n"""), - (8, """ c = " AND phone = ?"\n"""), - (9, """ r = cursor.execute(a + b + c, (name, phone, ))\n"""), + (9, """ b = " WHERE name =?"\n"""), + (10, """ c = " AND phone = ?"\n"""), + (11, """ r = cursor.execute(a + b + c, (name, phone, ))\n"""), ], ) @@ -21,7 +21,7 @@ class TestSQLQueryParameterization(BaseIntegrationTest): expected_diff =( """--- \n""" """+++ \n""" - """@@ -5,9 +5,9 @@\n""" + """@@ -7,9 +7,9 @@\n""" """ \n""" """ def foo(cursor: sqlite3.Cursor, name: str, phone: str):\n""" """ a = "SELECT * FROM Users"\n""" @@ -36,6 +36,6 @@ class TestSQLQueryParameterization(BaseIntegrationTest): """ \n""") # fmt: on - expected_line_change = "10" + expected_line_change = "12" change_description = SQLQueryParameterization.CHANGE_DESCRIPTION num_changed_files = 1 diff --git a/tests/samples/my_db.db b/tests/samples/my_db.db deleted file mode 100644 index 9a18d91146cc9f9a981c9c7312704910f3d639e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8192 zcmeI#y$ZrG5C`x}6*pqxA_@hlQW%hfVb z;wsZ!EK|1|1YT2|?fK4 diff --git a/tests/samples/sql_injection.py b/tests/samples/sql_injection.py index 483aa8ee..3ef768ad 100644 --- a/tests/samples/sql_injection.py +++ b/tests/samples/sql_injection.py @@ -1,6 +1,8 @@ import sqlite3 -connection = sqlite3.connect("tests/samples/my_db.db") +connection = sqlite3.connect(":memory:") +connection.cursor().execute("CREATE TABLE Users (name, phone)") +connection.cursor().execute("INSERT INTO Users VALUES ('Jenny','867-5309')") def foo(cursor: sqlite3.Cursor, name: str, phone: str):