Skip to content

Commit 4705a62

Browse files
committed
adding travis and scrutinizer yaml configs
adding empty codeception tests
1 parent 92636b9 commit 4705a62

File tree

8 files changed

+166
-101
lines changed

8 files changed

+166
-101
lines changed

.scrutinizer.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
tools:
2+
external_code_coverage: true
3+
checks:
4+
php:
5+
code_rating: true
6+
duplication: true
7+
filter:
8+
paths:
9+
- src/*

.travis.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
language: php
2+
3+
php:
4+
- 5.4
5+
- 5.5
6+
- 5.6
7+
- hhvm
8+
9+
matrix:
10+
allow_failures:
11+
- php: hhvm
12+
13+
branches:
14+
except:
15+
- gh-pages
16+
17+
18+
19+
install:
20+
- wget http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar
21+
- composer global require "fxp/composer-asset-plugin:1.0.0-beta2"
22+
- composer install
23+
24+
25+
before_script:
26+
- sudo chmod 777 /etc/hosts
27+
- echo 127.0.0.1 mining > /etc/hosts
28+
- export DISPLAY=:99.0
29+
- sh -e /etc/init.d/xvfb start
30+
- sleep 5
31+
- java -jar selenium-server-standalone-2.42.2.jar -port 4444 &
32+
- "mysql -e 'create database mpos;'"
33+
- echo "USE mysql;\nUPDATE user SET password=PASSWORD('mining') WHERE user='travis';\nFLUSH PRIVILEGES;\n" | mysql -u root
34+
- nohup php -S bone:8000 public/index.php &
35+
36+
script:
37+
- php vendor/bin/codecept run --coverage-xml --env travis
38+
39+
after_script:
40+
- wget https://scrutinizer-ci.com/ocular.phar
41+
- php ocular.phar code-coverage:upload --format=php-clover tests/_output/coverage.xml
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
use Codeception\Util\Stub;
4+
5+
class SecurityCSRFTokenTest extends \Codeception\TestCase\Test
6+
{
7+
public function _before()
8+
{
9+
10+
}
11+
12+
public function _after()
13+
{
14+
15+
}
16+
17+
18+
/**
19+
* Tests if a CSRF token succeeds for a matching user and type
20+
*/
21+
public function testCSRFToken_success() {
22+
// global $config;
23+
// global $user;
24+
// global $csrftoken;
25+
//
26+
// // no delay
27+
// // TODO: simulate delay without a sleep ? test length
28+
// $created_token = $csrftoken->getBasic($user->getCurrentIP(), 'test-token');
29+
// $test_token = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token);
30+
// $this->assertTrue($test_token);
31+
}
32+
33+
/**
34+
* Tests if a CSRF token correctly fails
35+
*/
36+
public function testCSRFToken_fail() {
37+
// global $config;
38+
// global $user;
39+
// global $csrftoken;
40+
//
41+
// // differing user
42+
// $created_token = $csrftoken->getBasic('not the same', 'test-token');
43+
// $test_token = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token);
44+
// $this->assertFalse($test_token);
45+
//
46+
// // differing type
47+
// $created_token2 = $csrftoken->getBasic($user->getCurrentIP(), 'not the same');
48+
// $test_token2 = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token2);
49+
// $this->assertFalse($test_token2);
50+
//
51+
// // token slightly shortened
52+
// $created_token3 = $csrftoken->getBasic($user->getCurrentIP(), 'test-token');
53+
// $created_token3 = substr($created_token3, 0, (strlen($created_token3)-1));
54+
// $test_token3 = $csrftoken->checkBasic($user->getCurrentIP(), 'test-token', $created_token3);
55+
// $this->assertFalse($test_token3);
56+
}
57+
}
58+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
class Security_Sessions extends \Codeception\TestCase\Test
4+
{
5+
/**
6+
* Tests if our current session checking will throw errors or take a malformed id
7+
*/
8+
public function testSessions_destruction_malformed_id()
9+
{
10+
// global $config;
11+
//
12+
// $malformed_ids = array(
13+
// "",
14+
// "'",
15+
// "9881o1ke7ia4k5*p1k28e6utg0"
16+
// );
17+
//
18+
// foreach ($malformed_ids as $mid) {
19+
// session_set_cookie_params(time()+$config['cookie']['duration'], $config['cookie']['path'], $config['cookie']['domain'], $config['cookie']['secure'], $config['cookie']['httponly']);
20+
// $session_start = @session_start();
21+
// if (!$session_start) {
22+
// session_destroy();
23+
// session_regenerate_id(true);
24+
// session_start();
25+
// }
26+
// @setcookie(session_name(), session_id(), time()+$config['cookie']['duration'], $config['cookie']['path'], $config['cookie']['domain'], $config['cookie']['secure'], $config['cookie']['httponly']);
27+
// $this->assertNotEquals($mid, session_id());
28+
// }
29+
}
30+
}
31+
32+
?>

tests/unit/SecurityTokensTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
class Security_Tokens extends \Codeception\TestCase\Test
4+
{
5+
/**
6+
* Tests tokens CRUD
7+
*/
8+
public function testTokens_CRUD()
9+
{
10+
// global $config;
11+
// global $mysqli;
12+
// $mysqli = new DBConnection($config);
13+
// global $tokentype;
14+
// global $oToken;
15+
// // grab token types first so we can test them all
16+
// $token_types = $tokentype->getAll();
17+
//
18+
// foreach ($token_types as $tt)
19+
// {
20+
// // create
21+
// $create_token = $oToken->createToken($tt['name'], 1);
22+
// $this->assertStringMatchesFormat('%x', $create_token);
23+
// $this->assertGreaterThan(16, strlen($create_token));
24+
// }
25+
}
26+
}

tests/unit/securityregress/Security_CSRFToken.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

tests/unit/securityregress/Security_Sessions.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/unit/securityregress/Security_Tokens.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)