From 7712955de7bef4bc245ba1a9f2f4603908679449 Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 21 Dec 2022 02:51:58 -0500 Subject: [PATCH] Bad SQL Unit Testing. --- UnitTestFiles/Test/SQL_Injection_Test.php | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 UnitTestFiles/Test/SQL_Injection_Test.php diff --git a/UnitTestFiles/Test/SQL_Injection_Test.php b/UnitTestFiles/Test/SQL_Injection_Test.php new file mode 100644 index 0000000..ffbf3a3 --- /dev/null +++ b/UnitTestFiles/Test/SQL_Injection_Test.php @@ -0,0 +1,44 @@ +expectException(\Exception::class); + \tts\safer_sql::get_safer_sql_text($a); + } + + /** + * @dataProvider safeDataProviderForTest + */ + public function testSafeSQL($a) { + $this->expectNotToPerformAssertions(); + \tts\safer_sql::get_safer_sql_text($a); + } + + public function dataProviderForTest() { + return [ + ["admin: {\$ne : ''}"], + ["' or 1=1-- -"], + ["Drop database me;"], + ["' \|\| DELETE 1=1; --"] + ]; + } + + public function safeDataProviderForTest() { + return [ + ["John walks (down the road)."], + ["Hey, Boy - Good Work!"], + ["I think; I'm good!"] + ]; + } + + +} \ No newline at end of file