From 795d8db2e2e218099c8e28c02bf918e004a64d6f Mon Sep 17 00:00:00 2001 From: Brandon Savage Date: Tue, 14 Dec 2021 20:45:14 -0500 Subject: [PATCH 1/5] Making compatible with PHP 7.4 and 8.0. --- composer.json | 3 +- src/Verifier/PasswordVerifier.php | 2 +- tests/Adapter/HtpasswdAdapterTest.php | 2 +- tests/Adapter/ImapAdapterTest.php | 2 +- tests/Adapter/LdapAdapterTest.php | 2 +- tests/Adapter/NullAdapterTest.php | 2 +- tests/Adapter/PdoAdapterTest.php | 2 +- tests/AuthFactoryTest.php | 2 +- tests/AuthTest.php | 2 +- tests/ContainerTest.php | 57 ------------------------- tests/PhpfuncTest.php | 2 +- tests/Service/LoginServiceTest.php | 2 +- tests/Service/LogoutServiceTest.php | 2 +- tests/Service/ResumeServiceTest.php | 2 +- tests/Session/NullSegmentTest.php | 2 +- tests/Session/NullSessionTest.php | 2 +- tests/Session/SegmentTest.php | 2 +- tests/Session/SessionTest.php | 2 +- tests/Session/TimerTest.php | 2 +- tests/Verifier/HtpasswdVerifierTest.php | 2 +- 20 files changed, 19 insertions(+), 77 deletions(-) delete mode 100644 tests/ContainerTest.php diff --git a/composer.json b/composer.json index 4b4cf27..af91ed3 100644 --- a/composer.json +++ b/composer.json @@ -36,8 +36,7 @@ "minimum-stability": "dev", "require-dev": { "acclimate/container": "^2", - "aura/di": "~4.0", - "phpunit/phpunit": "~7" + "phpunit/phpunit": "~8" }, "autoload-dev": { "psr-4": { 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; } From f1a998bc5fa591a0146a0b16bd069734eafb47fb Mon Sep 17 00:00:00 2001 From: Brandon Savage Date: Tue, 14 Dec 2021 20:58:10 -0500 Subject: [PATCH 2/5] Adding Psalm and GitHub Actions to replace Travis, which is no longer valid. --- .github/workflows/continuous-integration.yml | 86 ++++++++++++++++++++ .gitignore | 2 + .travis.yml | 21 ----- composer.json | 3 +- psalm.xml | 15 ++++ 5 files changed, 105 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/continuous-integration.yml delete mode 100644 .travis.yml create mode 100644 psalm.xml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 0000000..e5e285b --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,86 @@ +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" + + 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.0" + + 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 af91ed3..94c1093 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,8 @@ } ], "require": { - "php": ">=7.2.0" + "php": ">=7.2.0", + "vimeo/psalm": "4.x-dev" }, "autoload": { "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 @@ + + + + + + + + + From 058805451680fc050cb561bf27c544a9d1620bba Mon Sep 17 00:00:00 2001 From: Brandon Savage Date: Tue, 14 Dec 2021 20:59:34 -0500 Subject: [PATCH 3/5] Fixing indentation in GitHub Actions. --- .github/workflows/continuous-integration.yml | 72 ++++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e5e285b..f17d872 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -47,40 +47,40 @@ jobs: - name: "Run tests with phpunit/phpunit" run: "vendor/bin/phpunit" - psalm-tests: - name: "Psalm Tests" - runs-on: "ubuntu-latest" - - strategy: - matrix: - php-version: - - "8.0" - - 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" + psalm-tests: + name: "Psalm Tests" + runs-on: "ubuntu-latest" + + strategy: + matrix: + php-version: + - "8.0" + + 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" From 1e7aedf5e94ecd28b204aaa8e6ce62e06ffc37f0 Mon Sep 17 00:00:00 2001 From: Brandon Savage Date: Wed, 15 Dec 2021 09:42:13 -0500 Subject: [PATCH 4/5] Moving Psalm from dependency to dev dependency. Marking package deps as require stable. --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 94c1093..bc0da7e 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,7 @@ } ], "require": { - "php": ">=7.2.0", - "vimeo/psalm": "4.x-dev" + "php": ">=7.2.0" }, "autoload": { "psr-4": { @@ -34,10 +33,11 @@ } }, - "minimum-stability": "dev", + "minimum-stability": "stable", "require-dev": { "acclimate/container": "^2", - "phpunit/phpunit": "~8" + "phpunit/phpunit": "~8", + "vimeo/psalm": "~v4.15" }, "autoload-dev": { "psr-4": { From 927b0729380d1e5ba3e215737e980c51f50df6c5 Mon Sep 17 00:00:00 2001 From: Brandon Savage Date: Wed, 15 Dec 2021 09:43:18 -0500 Subject: [PATCH 5/5] Adding 8.1 as a dependency since we want to support it. --- .github/workflows/continuous-integration.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index f17d872..23f5f93 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -18,6 +18,7 @@ jobs: - "7.3" - "7.4" - "8.0" + - "8.1" steps: - name: "Checkout" @@ -54,7 +55,7 @@ jobs: strategy: matrix: php-version: - - "8.0" + - "8.1" steps: - name: "Checkout"