From 9c0f1b819a2961abe2498badb6c0e424bc589819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Bu=C3=9Fmann?= Date: Sat, 18 May 2024 00:31:22 +0200 Subject: [PATCH] fix: KeyDumpSigner for PHP < 8 --- .github/workflows/continuous-integration.yml | 81 ++++++++++--------- composer.json | 3 +- phpunit.xml | 1 + test/ext/KeyDumpSigner5.php | 29 +++++++ .../KeyDumpSigner8.php} | 0 test/src/KeyDumpSignerLoader.php | 12 +++ 6 files changed, 86 insertions(+), 40 deletions(-) create mode 100644 test/ext/KeyDumpSigner5.php rename test/{src/KeyDumpSigner.php => ext/KeyDumpSigner8.php} (100%) create mode 100644 test/src/KeyDumpSignerLoader.php diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index b66c96f..fd16cb6 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -1,48 +1,48 @@ -name: 'CI' +name: CI on: pull_request: push: branches: - - 'main' + - main env: COMPOSER_ROOT_VERSION: '1.99.99' jobs: lint: - name: 'Lint' - runs-on: 'ubuntu-latest' + name: Lint + runs-on: ubuntu-latest steps: - - uses: 'actions/checkout@v2' - - uses: 'shivammathur/setup-php@v2' + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 with: php-version: '7.4' - coverage: 'none' - ini-values: 'memory_limit=-1' - tools: 'composer:v2' - - uses: 'ramsey/composer-install@v1' + coverage: none + ini-values: memory_limit=-1 + tools: composer:v2 + - uses: ramsey/composer-install@v3 - name: 'Lint the PHP source code' - run: './vendor/bin/parallel-lint src test' + run: ./vendor/bin/parallel-lint src test coding-standards: - name: 'Coding Standards' - runs-on: 'ubuntu-latest' + name: Coding Standards + runs-on: ubuntu-latest steps: - - uses: 'actions/checkout@v2' - - uses: 'shivammathur/setup-php@v2' + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 with: php-version: '7.4' - coverage: 'none' - ini-values: 'memory_limit=-1' - tools: 'composer:v2' - - uses: 'ramsey/composer-install@v1' - - name: 'Check coding standards' - run: './vendor/bin/phpcs src --standard=psr2 -sp --colors' + coverage: none + ini-values: memory_limit=-1 + tools: composer:v2 + - uses: ramsey/composer-install@v3 + - name: Check coding standards + run: ./vendor/bin/phpcs src --standard=psr2 -sp --colors unit-tests: - name: 'Unit Tests' - runs-on: 'ubuntu-latest' + name: Unit Tests + runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental }} strategy: fail-fast: false @@ -55,30 +55,33 @@ jobs: - '7.3' - '7.4' - '8.0' + - '8.1' + - '8.2' + - '8.4' dependencies: - - 'lowest' - - 'highest' + - lowest + - highest experimental: - false include: - - php-version: '8.1' - experimental: true + - php-version: '8.3' + experimental: false composer-options: '--ignore-platform-reqs' steps: - - uses: 'actions/checkout@v2' - - uses: 'shivammathur/setup-php@v2' + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 with: php-version: '${{ matrix.php-version }}' - coverage: 'pcov' - ini-values: 'memory_limit=-1' - tools: 'composer:v2' - - name: 'Prepare for tests' - run: 'mkdir -p build/logs' - - uses: 'ramsey/composer-install@v1' + coverage: pcov + ini-values: memory_limit=-1 + tools: composer:v2 + - name: Prepare for tests + run: mkdir -p build/logs + - uses: ramsey/composer-install@v3 with: dependency-versions: '${{ matrix.dependencies }}' composer-options: '${{ matrix.composer-options }}' - - name: 'Run unit tests' - run: './vendor/bin/phpunit --colors=always --coverage-clover build/logs/clover.xml' - - name: 'Publish coverage report to Codecov' - uses: 'codecov/codecov-action@v1' + - name: Run unit tests + run: ./vendor/bin/phpunit --colors=always --coverage-clover build/logs/clover.xml + - name: Publish coverage report to Codecov + uses: codecov/codecov-action@v4 diff --git a/composer.json b/composer.json index 60aa342..a3319de 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,8 @@ "phpunit/phpunit": "^5.7 || ^6.0 || ^9.3", "mockery/mockery": "^1.3", "php-parallel-lint/php-parallel-lint": "^1.3", - "squizlabs/php_codesniffer": "^2.3 || ^3.0" + "squizlabs/php_codesniffer": "^2.3 || ^3.0", + "composer/semver": "^3.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index 1116871..e19357f 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -17,6 +17,7 @@ ./test/ + ./test/ext/ diff --git a/test/ext/KeyDumpSigner5.php b/test/ext/KeyDumpSigner5.php new file mode 100644 index 0000000..2935be8 --- /dev/null +++ b/test/ext/KeyDumpSigner5.php @@ -0,0 +1,29 @@ +getAlgorithmId(); + } + + public function verify($expected, $payload, $key) + { + return $expected === $key->contents(); + } + + public function sign($payload, $key) + { + return new Signature($key->contents()); + } +} diff --git a/test/src/KeyDumpSigner.php b/test/ext/KeyDumpSigner8.php similarity index 100% rename from test/src/KeyDumpSigner.php rename to test/ext/KeyDumpSigner8.php diff --git a/test/src/KeyDumpSignerLoader.php b/test/src/KeyDumpSignerLoader.php new file mode 100644 index 0000000..6b546d1 --- /dev/null +++ b/test/src/KeyDumpSignerLoader.php @@ -0,0 +1,12 @@ +