From 43233000543984eda49768edde65076fb9c2468c Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Sun, 18 Nov 2012 20:26:25 +0000 Subject: dropped old tests referring to unexisting components (NOTE: this includes what seems a test suite for an older version of SQLMap) --- tests/unit/Testing/Data/Analysis/AllTests.php | 32 --- .../Analysis/TDbStatementAnalysisParameterTest.php | 76 ------- .../Data/Analysis/TDbStatementAnalysisTest.php | 62 ------ .../Analysis/TSimpleDbStatementAnalysisTest.php | 229 --------------------- 4 files changed, 399 deletions(-) delete mode 100644 tests/unit/Testing/Data/Analysis/AllTests.php delete mode 100644 tests/unit/Testing/Data/Analysis/TDbStatementAnalysisParameterTest.php delete mode 100644 tests/unit/Testing/Data/Analysis/TDbStatementAnalysisTest.php delete mode 100644 tests/unit/Testing/Data/Analysis/TSimpleDbStatementAnalysisTest.php (limited to 'tests/unit/Testing') diff --git a/tests/unit/Testing/Data/Analysis/AllTests.php b/tests/unit/Testing/Data/Analysis/AllTests.php deleted file mode 100644 index 557dc9c6..00000000 --- a/tests/unit/Testing/Data/Analysis/AllTests.php +++ /dev/null @@ -1,32 +0,0 @@ -addTestSuite('TDbStatementAnalysisParameterTest'); - $suite->addTestSuite('TDbStatementAnalysisTest'); - $suite->addTestSuite('TSimpleDbStatementAnalysisTest'); - - return $suite; - } -} - -if(PHPUnit_MAIN_METHOD == 'Testing_Data_Analysis_AllTests::main') { - Testing_Data_Analysis_AllTests::main(); -} -?> diff --git a/tests/unit/Testing/Data/Analysis/TDbStatementAnalysisParameterTest.php b/tests/unit/Testing/Data/Analysis/TDbStatementAnalysisParameterTest.php deleted file mode 100644 index d75d5bb5..00000000 --- a/tests/unit/Testing/Data/Analysis/TDbStatementAnalysisParameterTest.php +++ /dev/null @@ -1,76 +0,0 @@ -analyserParameter = new TDbStatementAnalysisParameter(); - } - - public function tearDown() - { - $this->analyserParameter = null; - } - - public function testConstruct() { - $this->analyserParameter = new TDbStatementAnalysisParameter(); - self::assertInternalType('string', $this->analyserParameter->getStatement()); - self::assertEquals('', $this->analyserParameter->getStatement()); - self::assertEquals(TDbStatementClassification::UNKNOWN, $this->analyserParameter->getDefaultClassification()); - self::assertNull($this->analyserParameter->getDriverName()); - - $this->analyserParameter = new TDbStatementAnalysisParameter('SELECT 1', TDbStatementClassification::SQL, 'mysql'); - self::assertInternalType('string', $this->analyserParameter->getStatement()); - self::assertEquals('SELECT 1', $this->analyserParameter->getStatement()); - self::assertEquals(TDbStatementClassification::SQL, $this->analyserParameter->getDefaultClassification()); - self::assertEquals('mysql', $this->analyserParameter->getDriverName()); - } - - public function testStatement() { - self::assertInternalType('string', $this->analyserParameter->getStatement()); - self::assertEquals('', $this->analyserParameter->getStatement()); - - $this->analyserParameter->setStatement('SELECT 1'); - self::assertInternalType('string', $this->analyserParameter->getStatement()); - self::assertEquals('SELECT 1', $this->analyserParameter->getStatement()); - - $this->analyserParameter->setStatement(null); - self::assertInternalType('string', $this->analyserParameter->getStatement()); - self::assertEquals('', $this->analyserParameter->getStatement()); - } - - public function testDriverName() { - self::assertNull($this->analyserParameter->getDriverName()); - - $this->analyserParameter->setDriverName('mysql'); - self::assertEquals('mysql', $this->analyserParameter->getDriverName()); - - $this->analyserParameter->setDriverName('mssql'); - self::assertEquals('mssql', $this->analyserParameter->getDriverName()); - - $this->analyserParameter->setDriverName(null); - self::assertNull($this->analyserParameter->getDriverName()); - } - - public function testDefaultClassification() { - self::assertEquals(TDbStatementClassification::UNKNOWN, $this->analyserParameter->getDefaultClassification()); - - $this->analyserParameter->setDefaultClassification(TDbStatementClassification::SQL); - self::assertEquals(TDbStatementClassification::SQL, $this->analyserParameter->getDefaultClassification()); - - $this->analyserParameter->setDefaultClassification(TDbStatementClassification::DML); - self::assertEquals(TDbStatementClassification::DML, $this->analyserParameter->getDefaultClassification()); - - $this->analyserParameter->setDefaultClassification(null); - self::assertEquals(TDbStatementClassification::UNKNOWN, $this->analyserParameter->getDefaultClassification()); - } -} -?> \ No newline at end of file diff --git a/tests/unit/Testing/Data/Analysis/TDbStatementAnalysisTest.php b/tests/unit/Testing/Data/Analysis/TDbStatementAnalysisTest.php deleted file mode 100644 index 70437816..00000000 --- a/tests/unit/Testing/Data/Analysis/TDbStatementAnalysisTest.php +++ /dev/null @@ -1,62 +0,0 @@ -analyser = new TDbStatementAnalysis(); - } - - public function tearDown() - { - $this->analyser = null; - } - - public function testStaticClassificationAnalysis() - { - $parameter = new TDbStatementAnalysisParameter(); - self::assertEquals(TDbStatementClassification::UNKNOWN, TDbStatementAnalysis::doClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter('SELECT 1'); - self::assertEquals(TDbStatementClassification::UNKNOWN, TDbStatementAnalysis::doClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter('SELECT 1', TDbStatementClassification::SQL); - self::assertEquals(TDbStatementClassification::SQL, TDbStatementAnalysis::doClassificationAnalysis($parameter)); - } - - public function testDriverName() - { - self::assertNull($this->analyser->getDriverName()); - - $this->analyser->setDriverName('mysql'); - self::assertEquals('mysql', $this->analyser->getDriverName()); - - $this->analyser->setDriverName('mssql'); - self::assertEquals('mssql', $this->analyser->getDriverName()); - - $this->analyser->setDriverName(null); - self::assertNull($this->analyser->getDriverName()); - } - - public function testClassificationAnalysis() - { - $parameter = new TDbStatementAnalysisParameter(); - self::assertEquals(TDbStatementClassification::UNKNOWN, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter('SELECT 1'); - self::assertEquals(TDbStatementClassification::UNKNOWN, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter('SELECT 1', TDbStatementClassification::SQL); - self::assertEquals(TDbStatementClassification::SQL, $this->analyser->getClassificationAnalysis($parameter)); - } - -} -?> \ No newline at end of file diff --git a/tests/unit/Testing/Data/Analysis/TSimpleDbStatementAnalysisTest.php b/tests/unit/Testing/Data/Analysis/TSimpleDbStatementAnalysisTest.php deleted file mode 100644 index 09ab0f48..00000000 --- a/tests/unit/Testing/Data/Analysis/TSimpleDbStatementAnalysisTest.php +++ /dev/null @@ -1,229 +0,0 @@ -analyser = new TSimpleDbStatementAnalysis(); - } - - public function tearDown() - { - $this->analyser = null; - } - - public function testDriverName() - { - self::assertNull($this->analyser->getDriverName()); - - $this->analyser->setDriverName('mysql'); - self::assertEquals('mysql', $this->analyser->getDriverName()); - - $this->analyser->setDriverName('mssql'); - self::assertEquals('mssql', $this->analyser->getDriverName()); - - $this->analyser->setDriverName(null); - self::assertNull($this->analyser->getDriverName()); - } - - public function testClassificationAnalysisDDL() - { - $parameter = new TDbStatementAnalysisParameter('CREATE DATABASE `prado_system_data_sqlmap` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci'); - self::assertEquals(TDbStatementClassification::DDL, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter('DROP TABLE IF EXISTS `dynamicparametertest1`'); - self::assertEquals(TDbStatementClassification::DDL, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter(' - CREATE TABLE `dynamicparametertest1` ( - `testname` varchar(50) NOT NULL, - `teststring` varchar(50) NOT NULL, - `testinteger` int(11) NOT NULL - ) ENGINE=MyISAM DEFAULT CHARSET=utf8 - '); - self::assertEquals(TDbStatementClassification::DDL, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter(' - CREATE TABLE `tab3` - /* 1 multiline comment in one line */ - SELECT - t1.*, - t2.`foo` AS `bar` - FROM - # 1 single line shell comment - `tab1` t1 - # 2 single line shell comment - RIGHT JOIN `tab2` t2 ON ( - t2.tab1_id=t1.tab1_ref - AND - t2.`disabled` IS NULL - AND - (t2.`flags`&?)=? - ) - -- 1 single line comment - WHERE - /* - 2 multiline comment - in two lines - */ - t1.`idx`=? - AND - -- 2 single line comment - t1.`disabled`IS NULL - GROUP BY - t2.`foo` - HAVING - t2.tab1_id=1, - t2.disabled IS NULL - ORDER BY - `bar` DESC - '); - self::assertEquals(TDbStatementClassification::DDL, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter('DROP TABLE `tab3`'); - self::assertEquals(TDbStatementClassification::DDL, $this->analyser->getClassificationAnalysis($parameter)); - } - - public function testClassificationAnalysisDML() - { - $parameter = new TDbStatementAnalysisParameter('TRUNCATE TABLE `dynamicparametertest1`'); - self::assertEquals(TDbStatementClassification::DML, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter(' - UPDATE `dynamicparametertest1` SET - `testinteger`=FLOOR(7 + (RAND() * 5)) - WHERE - `testname` IN( - SELECT `testname` FROM `dynamicparametertest2` - ) - '); - self::assertEquals(TDbStatementClassification::DML, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter(' - INSERT INTO `tab3` - /* 1 multiline comment in one line */ - SELECT - t1.*, - t2.`foo` AS `bar` - FROM - # 1 single line shell comment - `tab1` t1 - # 2 single line shell comment - RIGHT JOIN `tab2` t2 ON ( - t2.tab1_id=t1.tab1_ref - AND - t2.`disabled` IS NULL - AND - (t2.`flags`&?)=? - ) - -- 1 single line comment - WHERE - /* - 2 multiline comment - in two lines - */ - t1.`idx`=? - AND - -- 2 single line comment - t1.`disabled`IS NULL - GROUP BY - t2.`foo` - HAVING - t2.tab1_id=1, - t2.disabled IS NULL - ORDER BY - `bar` DESC - '); - self::assertEquals(TDbStatementClassification::DML, $this->analyser->getClassificationAnalysis($parameter)); - } - - public function testClassificationAnalysisSQL() - { - $parameter = new TDbStatementAnalysisParameter(' - /* 1 multiline comment in one line */ - SELECT - t1.*, - t2.`foo` AS `bar` - FROM - # 1 single line shell comment - `tab1` t1 - # 2 single line shell comment - RIGHT JOIN `tab2` t2 ON ( - t2.tab1_id=t1.tab1_ref - AND - t2.`disabled` IS NULL - AND - (t2.`flags`&?)=? - ) - -- 1 single line comment - WHERE - /* - 2 multiline comment - in two lines - */ - t1.`idx`=? - AND - -- 2 single line comment - t1.`disabled`IS NULL - GROUP BY - t2.`foo` - HAVING - t2.tab1_id=1, - t2.disabled IS NULL - ORDER BY - `bar` DESC - '); - self::assertEquals(TDbStatementClassification::SQL, $this->analyser->getClassificationAnalysis($parameter)); - } - - public function testClassificationAnalysisDCL() - { - $parameter = new TDbStatementAnalysisParameter(' - GRANT ALL ON `prado_system_data_sqlmap`.* - TO "prado_unitest"@"localhost" - IDENTIFIED BY "prado_system_data_sqlmap_unitest"'); - self::assertEquals(TDbStatementClassification::DCL, $this->analyser->getClassificationAnalysis($parameter)); - } - - public function testClassificationAnalysisTCL() - { - $parameter = new TDbStatementAnalysisParameter('START TRANSACTION'); - self::assertEquals(TDbStatementClassification::TCL, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter('BEGIN'); - self::assertEquals(TDbStatementClassification::TCL, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter('COMMIT'); - self::assertEquals(TDbStatementClassification::TCL, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter('RELEASE SAVEPOINT'); - self::assertEquals(TDbStatementClassification::TCL, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter('XA START'); - self::assertEquals(TDbStatementClassification::TCL, $this->analyser->getClassificationAnalysis($parameter)); - } - - public function testClassificationAnalysisUNKNOWN() - { - $parameter = new TDbStatementAnalysisParameter('CALL `sp_my_storedprocedure`("foobar")'); - self::assertEquals(TDbStatementClassification::UNKNOWN, $this->analyser->getClassificationAnalysis($parameter)); - } - - public function testClassificationAnalysisCONTEXT() - { - $parameter = new TDbStatementAnalysisParameter('SET NAMES "utf8"'); - self::assertEquals(TDbStatementClassification::CONTEXT, $this->analyser->getClassificationAnalysis($parameter)); - - $parameter = new TDbStatementAnalysisParameter('USE `prado_system_data_sqlmap`'); - self::assertEquals(TDbStatementClassification::CONTEXT, $this->analyser->getClassificationAnalysis($parameter)); - } -} -?> \ No newline at end of file -- cgit v1.2.3