From 4705a62822cefcfd0f74bbe438d4e381c3681c80 Mon Sep 17 00:00:00 2001 From: delboy1978uk Date: Sun, 21 Dec 2014 14:33:14 +0000 Subject: [PATCH] adding travis and scrutinizer yaml configs adding empty codeception tests --- .scrutinizer.yml | 9 +++ .travis.yml | 41 +++++++++++++ tests/unit/SecurityCSRFTokenTest.php | 58 +++++++++++++++++++ tests/unit/SecuritySessionsTest.php | 32 ++++++++++ tests/unit/SecurityTokensTest.php | 26 +++++++++ .../securityregress/Security_CSRFToken.php | 45 -------------- .../securityregress/Security_Sessions.php | 30 ---------- .../unit/securityregress/Security_Tokens.php | 26 --------- 8 files changed, 166 insertions(+), 101 deletions(-) create mode 100644 .scrutinizer.yml create mode 100644 .travis.yml create mode 100644 tests/unit/SecurityCSRFTokenTest.php create mode 100644 tests/unit/SecuritySessionsTest.php create mode 100644 tests/unit/SecurityTokensTest.php delete mode 100644 tests/unit/securityregress/Security_CSRFToken.php delete mode 100644 tests/unit/securityregress/Security_Sessions.php delete mode 100644 tests/unit/securityregress/Security_Tokens.php diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 00000000..1e5d52a2 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,9 @@ +tools: + external_code_coverage: true +checks: + php: + code_rating: true + duplication: true +filter: + paths: + - src/* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..c0599b6e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,41 @@ +language: php + +php: + - 5.4 + - 5.5 + - 5.6 + - hhvm + +matrix: + allow_failures: + - php: hhvm + +branches: + except: + - gh-pages + + + +install: + - wget http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar + - composer global require "fxp/composer-asset-plugin:1.0.0-beta2" + - composer install + + +before_script: + - sudo chmod 777 /etc/hosts + - echo 127.0.0.1 mining > /etc/hosts + - export DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - sleep 5 + - java -jar selenium-server-standalone-2.42.2.jar -port 4444 & + - "mysql -e 'create database mpos;'" + - echo "USE mysql;\nUPDATE user SET password=PASSWORD('mining') WHERE user='travis';\nFLUSH PRIVILEGES;\n" | mysql -u root + - nohup php -S bone:8000 public/index.php & + +script: + - php vendor/bin/codecept run --coverage-xml --env travis + +after_script: + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover tests/_output/coverage.xml \ No newline at end of file diff --git a/tests/unit/SecurityCSRFTokenTest.php b/tests/unit/SecurityCSRFTokenTest.php new file mode 100644 index 00000000..78abd57f --- /dev/null +++ b/tests/unit/SecurityCSRFTokenTest.php @@ -0,0 +1,58 @@ +getBasic($user->getCurrentIP(), 'test-token'); +// $test_token = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token); +// $this->assertTrue($test_token); + } + + /** + * Tests if a CSRF token correctly fails + */ + public function testCSRFToken_fail() { +// global $config; +// global $user; +// global $csrftoken; +// +// // differing user +// $created_token = $csrftoken->getBasic('not the same', 'test-token'); +// $test_token = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token); +// $this->assertFalse($test_token); +// +// // differing type +// $created_token2 = $csrftoken->getBasic($user->getCurrentIP(), 'not the same'); +// $test_token2 = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token2); +// $this->assertFalse($test_token2); +// +// // token slightly shortened +// $created_token3 = $csrftoken->getBasic($user->getCurrentIP(), 'test-token'); +// $created_token3 = substr($created_token3, 0, (strlen($created_token3)-1)); +// $test_token3 = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token3); +// $this->assertFalse($test_token3); + } +} + diff --git a/tests/unit/SecuritySessionsTest.php b/tests/unit/SecuritySessionsTest.php new file mode 100644 index 00000000..533f5516 --- /dev/null +++ b/tests/unit/SecuritySessionsTest.php @@ -0,0 +1,32 @@ +assertNotEquals($mid, session_id()); +// } + } +} + +?> \ No newline at end of file diff --git a/tests/unit/SecurityTokensTest.php b/tests/unit/SecurityTokensTest.php new file mode 100644 index 00000000..528b23ef --- /dev/null +++ b/tests/unit/SecurityTokensTest.php @@ -0,0 +1,26 @@ +getAll(); +// +// foreach ($token_types as $tt) +// { +// // create +// $create_token = $oToken->createToken($tt['name'], 1); +// $this->assertStringMatchesFormat('%x', $create_token); +// $this->assertGreaterThan(16, strlen($create_token)); +// } + } +} \ No newline at end of file diff --git a/tests/unit/securityregress/Security_CSRFToken.php b/tests/unit/securityregress/Security_CSRFToken.php deleted file mode 100644 index 4193223f..00000000 --- a/tests/unit/securityregress/Security_CSRFToken.php +++ /dev/null @@ -1,45 +0,0 @@ -getBasic($user->getCurrentIP(), 'test-token'); - $test_token = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token); - $this->assertTrue($test_token); - } - - /** - * Tests if a CSRF token correctly fails - */ - function testCSRFToken_fail() { - global $config; - global $user; - global $csrftoken; - - // differing user - $created_token = $csrftoken->getBasic('not the same', 'test-token'); - $test_token = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token); - $this->assertFalse($test_token); - - // differing type - $created_token2 = $csrftoken->getBasic($user->getCurrentIP(), 'not the same'); - $test_token2 = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token2); - $this->assertFalse($test_token2); - - // token slightly shortened - $created_token3 = $csrftoken->getBasic($user->getCurrentIP(), 'test-token'); - $created_token3 = substr($created_token3, 0, (strlen($created_token3)-1)); - $test_token3 = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token3); - $this->assertFalse($test_token3); - } -} - -?> \ No newline at end of file diff --git a/tests/unit/securityregress/Security_Sessions.php b/tests/unit/securityregress/Security_Sessions.php deleted file mode 100644 index 3654a033..00000000 --- a/tests/unit/securityregress/Security_Sessions.php +++ /dev/null @@ -1,30 +0,0 @@ -assertNotEquals($mid, session_id()); - } - } -} - -?> \ No newline at end of file diff --git a/tests/unit/securityregress/Security_Tokens.php b/tests/unit/securityregress/Security_Tokens.php deleted file mode 100644 index a6cf381b..00000000 --- a/tests/unit/securityregress/Security_Tokens.php +++ /dev/null @@ -1,26 +0,0 @@ -getAll(); - - foreach ($token_types as $tt) - { - // create - $create_token = $oToken->createToken($tt['name'], 1); - $this->assertStringMatchesFormat('%x', $create_token); - $this->assertGreaterThan(16, strlen($create_token)); - } - } -} \ No newline at end of file