You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.5 KiB
62 lines
1.5 KiB
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace UnitTestFiles\Test;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class SQL_Injection_Test extends TestCase {
|
|
|
|
/**
|
|
* @dataProvider dataProviderForTest
|
|
*/
|
|
public function testDangerious($a) {
|
|
$ret = \tts\safer_sql::get_safer_sql_text($a);
|
|
$this->assertTrue($ret['status'] == \tts\SQL_SAFETY_FLAG::dangerious);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider filterDataProviderForTest
|
|
*/
|
|
public function testSQLFiltering($a, $b) {
|
|
$ret = \tts\safer_sql::get_safer_sql_text($a);
|
|
$this->assertEquals($ret["text"], $b);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider safeDataProviderForTest
|
|
*/
|
|
public function testSafeSQL($a) {
|
|
$ret = \tts\safer_sql::get_safer_sql_text($a);
|
|
$this->assertTrue($ret['status'] == \tts\SQL_SAFETY_FLAG::good);
|
|
}
|
|
|
|
public function dataProviderForTest() {
|
|
return [
|
|
["admin: {\$ne : ''}"],
|
|
["' or 1=1-- -"],
|
|
["Drop database me;"],
|
|
["' \|\| DELETE 1=1; --"]
|
|
];
|
|
}
|
|
|
|
public function filterDataProviderForTest() {
|
|
return [
|
|
["/etc/password Hello", "etcpassword Hello"],
|
|
["--; Bob", " Bob"],
|
|
["&& Safe", " Safe"],
|
|
["Hello /var/log/apache", "Hello varlogapache"]
|
|
];
|
|
}
|
|
|
|
public function safeDataProviderForTest() {
|
|
return [
|
|
["John walks (down the road)."],
|
|
["Hey, Boy - Good Work!"],
|
|
["I think; I'm good!"],
|
|
["Go dancing by the river or play ball and see it."]
|
|
];
|
|
}
|
|
|
|
|
|
} |