diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..23f5f93 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,87 @@ +on: + pull_request: + push: + branches: + - '**' + +name: "Continuous Integration" + +jobs: + unit-tests: + name: "Unit Tests" + runs-on: "ubuntu-latest" + + strategy: + matrix: + php-version: + - "7.2" + - "7.3" + - "7.4" + - "8.0" + - "8.1" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP with extensions" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + ini-values: "memory_limit=-1" + php-version: "${{ matrix.php-version }}" + + - name: "Determine composer cache directory" + id: "determine-composer-cache-directory" + run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v1" + with: + path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" + key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-" + + - name: "Install dependencies with composer" + run: "composer install --no-interaction --no-progress --no-suggest" + + - name: "Run tests with phpunit/phpunit" + run: "vendor/bin/phpunit" + + psalm-tests: + name: "Psalm Tests" + runs-on: "ubuntu-latest" + + strategy: + matrix: + php-version: + - "8.1" + + steps: + - name: "Checkout" + uses: "actions/checkout@v2" + + - name: "Install PHP with extensions" + uses: "shivammathur/setup-php@v2" + with: + coverage: "none" + ini-values: "memory_limit=-1" + php-version: "${{ matrix.php-version }}" + + - name: "Determine composer cache directory" + id: "determine-composer-cache-directory" + run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" + + - name: "Cache dependencies installed with composer" + uses: "actions/cache@v1" + with: + path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" + key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('**/composer.json') }}" + restore-keys: "php-${{ matrix.php-version }}-composer-" + + - name: "Install dependencies with composer" + run: "composer install --no-interaction --no-progress --no-suggest" + + - name: "Run tests with Psalm" + run: "vendor/bin/psalm" + diff --git a/.gitignore b/.gitignore index de4a392..3b38eb3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /vendor /composer.lock +.phpunit.result.cache +phpunit.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 65fc4f0..0000000 --- a/.travis.yml +++ /dev/null @@ -1,21 +0,0 @@ -language: php - -matrix: - include: - - os: linux - dist: trusty - sudo: false - php: 7.2 - - os: linux - dist: trusty - sudo: false - php: 7.3 - -before_script: - - composer self-update - - composer install -script: - - if [[ $TEST_COVERAGE == 'true' ]]; then vendor/bin/phpunit --coverage-clover=coverage.clover ; else vendor/bin/phpunit ; fi -after_script: - - wget https://scrutinizer-ci.com/ocular.phar - - if [[ $TEST_COVERAGE == 'true' ]]; then php ocular.phar code-coverage:upload --format=php-clover coverage.clover ; fi diff --git a/composer.json b/composer.json index 4b4cf27..bc0da7e 100644 --- a/composer.json +++ b/composer.json @@ -33,11 +33,11 @@ } }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require-dev": { "acclimate/container": "^2", - "aura/di": "~4.0", - "phpunit/phpunit": "~7" + "phpunit/phpunit": "~8", + "vimeo/psalm": "~v4.15" }, "autoload-dev": { "psr-4": { diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..7c0333d --- /dev/null +++ b/psalm.xml @@ -0,0 +1,15 @@ + + + + + + + + + diff --git a/src/Verifier/PasswordVerifier.php b/src/Verifier/PasswordVerifier.php index 4765bea..1c1bf0f 100644 --- a/src/Verifier/PasswordVerifier.php +++ b/src/Verifier/PasswordVerifier.php @@ -53,7 +53,7 @@ public function __construct($algo) */ public function verify($plaintext, $hashvalue, array $extra = array()) { - if (is_string($this->algo)) { + if (is_string($this->algo) && $this->algo !== PASSWORD_BCRYPT) { return hash($this->algo, $plaintext) === $hashvalue; } else { return password_verify($plaintext, $hashvalue); diff --git a/tests/Adapter/HtpasswdAdapterTest.php b/tests/Adapter/HtpasswdAdapterTest.php index 95752e9..728c3e8 100644 --- a/tests/Adapter/HtpasswdAdapterTest.php +++ b/tests/Adapter/HtpasswdAdapterTest.php @@ -7,7 +7,7 @@ class HtpasswdAdapterTest extends \PHPUnit\Framework\TestCase { protected $adapter; - protected function setUp() + protected function setUp() : void { $file = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'fake.htpasswd'; $this->setAdapter($file); diff --git a/tests/Adapter/ImapAdapterTest.php b/tests/Adapter/ImapAdapterTest.php index a895b78..e85207e 100644 --- a/tests/Adapter/ImapAdapterTest.php +++ b/tests/Adapter/ImapAdapterTest.php @@ -9,7 +9,7 @@ class ImapAdapterTest extends \PHPUnit\Framework\TestCase protected $adapter; - protected function setUp() + protected function setUp() : void { $this->phpfunc = $this->getMockBuilder('Aura\Auth\Phpfunc') ->setMethods(array( diff --git a/tests/Adapter/LdapAdapterTest.php b/tests/Adapter/LdapAdapterTest.php index f0fb5de..f478cf2 100644 --- a/tests/Adapter/LdapAdapterTest.php +++ b/tests/Adapter/LdapAdapterTest.php @@ -9,7 +9,7 @@ class LdapAdapterTest extends \PHPUnit\Framework\TestCase protected $phpfunc; - protected function setUp() + protected function setUp() : void { $this->phpfunc = $this->getMockBuilder('Aura\Auth\Phpfunc') ->setMethods(array( diff --git a/tests/Adapter/NullAdapterTest.php b/tests/Adapter/NullAdapterTest.php index de891a2..0b56296 100644 --- a/tests/Adapter/NullAdapterTest.php +++ b/tests/Adapter/NullAdapterTest.php @@ -5,7 +5,7 @@ class NullAdapterTest extends \PHPUnit\Framework\TestCase { protected $adapter; - protected function setUp() + protected function setUp() : void { $this->adapter = new NullAdapter; } diff --git a/tests/Adapter/PdoAdapterTest.php b/tests/Adapter/PdoAdapterTest.php index cd56caf..aecca0e 100644 --- a/tests/Adapter/PdoAdapterTest.php +++ b/tests/Adapter/PdoAdapterTest.php @@ -10,7 +10,7 @@ class PdoAdapterTest extends \PHPUnit\Framework\TestCase protected $pdo; - protected function setUp() + protected function setUp() : void { if (false === extension_loaded('pdo_sqlite')) { $this->markTestSkipped("Cannot test this adapter with pdo_sqlite extension disabled."); diff --git a/tests/AuthFactoryTest.php b/tests/AuthFactoryTest.php index 017925d..f160dc3 100644 --- a/tests/AuthFactoryTest.php +++ b/tests/AuthFactoryTest.php @@ -10,7 +10,7 @@ class AuthFactoryTest extends \PHPUnit\Framework\TestCase { protected $factory; - protected function setUp() + protected function setUp() : void { $this->factory = new AuthFactory($_COOKIE); } diff --git a/tests/AuthTest.php b/tests/AuthTest.php index f14e2ca..4e8e6c3 100644 --- a/tests/AuthTest.php +++ b/tests/AuthTest.php @@ -10,7 +10,7 @@ class AuthTest extends \PHPUnit\Framework\TestCase protected $segment; - protected function setUp() + protected function setUp() : void { $this->segment = new FakeSegment; $this->auth = new Auth($this->segment); diff --git a/tests/ContainerTest.php b/tests/ContainerTest.php deleted file mode 100644 index 9ff9ff8..0000000 --- a/tests/ContainerTest.php +++ /dev/null @@ -1,57 +0,0 @@ - 'fake-file', - )), - array('Aura\Auth\Adapter\ImapAdapter', array( - 'mailbox' => 'fake-mailbox', - )), - array('Aura\Auth\Adapter\LdapAdapter', array( - 'server' => 'fake-server', - 'dnformat' => 'fake-dnformat', - )), - array('Aura\Auth\Adapter\PdoAdapter', array( - 'pdo' => new FakePdo, - 'verifier' => new \Aura\Auth\Verifier\PasswordVerifier('md5'), - )), - array('Aura\Auth\Auth'), - array('Aura\Auth\Service\LoginService'), - array('Aura\Auth\Service\LogoutService'), - array('Aura\Auth\Service\ResumeService'), - array('Aura\Auth\Session\Timer'), - array('Aura\Auth\Session\Session'), - ); - } -} diff --git a/tests/PhpfuncTest.php b/tests/PhpfuncTest.php index cb63f00..09f346b 100644 --- a/tests/PhpfuncTest.php +++ b/tests/PhpfuncTest.php @@ -5,7 +5,7 @@ class PhpfuncTest extends \PHPUnit\Framework\TestCase { protected $phpfunc; - protected function setUp() + protected function setUp() : void { $this->phpfunc = new Phpfunc; } diff --git a/tests/Service/LoginServiceTest.php b/tests/Service/LoginServiceTest.php index 156a179..72b1c9b 100644 --- a/tests/Service/LoginServiceTest.php +++ b/tests/Service/LoginServiceTest.php @@ -20,7 +20,7 @@ class LoginServiceTest extends \PHPUnit\Framework\TestCase protected $login_service; - protected function setUp() + protected function setUp() : void { $this->segment = new FakeSegment; $this->session = new FakeSession; diff --git a/tests/Service/LogoutServiceTest.php b/tests/Service/LogoutServiceTest.php index 664ecd8..3433700 100644 --- a/tests/Service/LogoutServiceTest.php +++ b/tests/Service/LogoutServiceTest.php @@ -22,7 +22,7 @@ class LogoutServiceTest extends \PHPUnit\Framework\TestCase protected $logout_service; - protected function setUp() + protected function setUp() : void { $this->segment = new FakeSegment; $this->session = new FakeSession; diff --git a/tests/Service/ResumeServiceTest.php b/tests/Service/ResumeServiceTest.php index b363fd5..40304c4 100644 --- a/tests/Service/ResumeServiceTest.php +++ b/tests/Service/ResumeServiceTest.php @@ -26,7 +26,7 @@ class ResumeServiceTest extends \PHPUnit\Framework\TestCase protected $resume_service; - protected function setUp() + protected function setUp() : void { $this->segment = new FakeSegment; $this->session = new FakeSession; diff --git a/tests/Session/NullSegmentTest.php b/tests/Session/NullSegmentTest.php index 55e12c2..6bb785f 100644 --- a/tests/Session/NullSegmentTest.php +++ b/tests/Session/NullSegmentTest.php @@ -5,7 +5,7 @@ class NullSegmentTest extends \PHPUnit\Framework\TestCase { protected $segment; - public function setUp() + public function setUp() : void { $this->segment = new NullSegment; } diff --git a/tests/Session/NullSessionTest.php b/tests/Session/NullSessionTest.php index 49fcce0..52aa4c5 100644 --- a/tests/Session/NullSessionTest.php +++ b/tests/Session/NullSessionTest.php @@ -5,7 +5,7 @@ class NullSessionTest extends \PHPUnit\Framework\TestCase { protected $session; - protected function setUp() + protected function setUp() : void { $this->session = new NullSession; } diff --git a/tests/Session/SegmentTest.php b/tests/Session/SegmentTest.php index 8024326..c377a0d 100644 --- a/tests/Session/SegmentTest.php +++ b/tests/Session/SegmentTest.php @@ -5,7 +5,7 @@ class SegmentTest extends \PHPUnit\Framework\TestCase { protected $segment; - public function setUp() + public function setUp() : void { $this->segment = new Segment(__CLASS__); } diff --git a/tests/Session/SessionTest.php b/tests/Session/SessionTest.php index ae2cb82..f54e97b 100644 --- a/tests/Session/SessionTest.php +++ b/tests/Session/SessionTest.php @@ -6,7 +6,7 @@ */ class SessionTest extends \PHPUnit\Framework\TestCase { - protected function setUp() + protected function setUp() : void { $this->setSession(); } diff --git a/tests/Session/TimerTest.php b/tests/Session/TimerTest.php index ae2993a..b0de613 100644 --- a/tests/Session/TimerTest.php +++ b/tests/Session/TimerTest.php @@ -7,7 +7,7 @@ class TimerTest extends \PHPUnit\Framework\TestCase { protected $timer; - protected function setUp() + protected function setUp() : void { $this->timer = new Timer(3600, 86400); } diff --git a/tests/Verifier/HtpasswdVerifierTest.php b/tests/Verifier/HtpasswdVerifierTest.php index e019853..e9d3763 100644 --- a/tests/Verifier/HtpasswdVerifierTest.php +++ b/tests/Verifier/HtpasswdVerifierTest.php @@ -3,7 +3,7 @@ class HtpasswdVerifierTest extends \PHPUnit\Framework\TestCase { - public function setUp() + public function setUp() : void { $this->verifier = new HtpasswdVerifier; }