Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
266 changes: 132 additions & 134 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,142 @@ on: # yamllint disable-line rule:truthy
workflow_dispatch:

jobs:
phplinter:
name: 'PHP-Linter'
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.2', '8.3', '8.4']

uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_phplinter.yml@v1.9.2
with:
php-version: ${{ matrix.php-version }}

linter:
name: Linter
runs-on: ['ubuntu-latest']
name: 'Linter'
strategy:
fail-fast: false

uses: simplesamlphp/simplesamlphp-test-framework/.github/workflows/reusable_linter.yml@v1.9.2
with:
enable_eslinter: false
enable_jsonlinter: true
enable_stylelinter: false
enable_yamllinter: true

unit-tests-linux:
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
runs-on: ${{ matrix.operating-system }}
needs: [phplinter, linter]
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2', '8.3', '8.4']

steps:
- name: Setup PHP, with composer and extensions
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, \
memcached, openssl, pcre, posix, spl, xml
tools: composer
ini-values: error_reporting=E_ALL
coverage: pcov

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- uses: actions/checkout@v4

- name: Get composer cache directory
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"

- name: Cache composer dependencies
uses: actions/cache@v4
with:
fetch-depth: 0

- name: Lint Code Base
uses: super-linter/super-linter/slim@v7
env:
SAVE_SUPER_LINTER_OUTPUT: false
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: 'tools/linters'
LOG_LEVEL: NOTICE
VALIDATE_ALL_CODEBASE: true
VALIDATE_CSS: true
VALIDATE_JAVASCRIPT_ES: true
VALIDATE_JSON: true
VALIDATE_PHP_BUILTIN: true
VALIDATE_YAML: true
VALIDATE_XML: true
VALIDATE_GITHUB_ACTIONS: true
path: $COMPOSER_CACHE
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Run unit tests with coverage
if: ${{ matrix.php-versions == '8.4' }}
run: vendor/bin/phpunit

- name: Run unit tests (no coverage)
if: ${{ matrix.php-versions != '8.4' }}
run: vendor/bin/phpunit --no-coverage

- name: Save coverage data
if: ${{ matrix.php-versions == '8.4' }}
uses: actions/upload-artifact@v4
with:
name: coverage-data
path: ${{ github.workspace }}/build

unit-tests-windows:
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
runs-on: ${{ matrix.operating-system }}
needs: [phplinter, linter]
strategy:
fail-fast: true
matrix:
operating-system: [windows-latest]
php-versions: ['8.1', '8.2', '8.3', '8.4']

steps:
- name: Setup PHP, with composer and extensions
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, memcached-3.3.0, \
openssl, pcre, posix, spl, xml
tools: composer
ini-values: error_reporting=E_ALL
coverage: none

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- uses: actions/checkout@v4

- name: Get composer cache directory
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: $COMPOSER_CACHE
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix

- name: Run unit tests
run: vendor/bin/phpunit --no-coverage

quality:
name: Quality control
Expand All @@ -50,7 +162,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
# Should be the higest supported version, so we can use the newest tools
php-version: '8.3'
php-version: '8.4'
tools: composer, composer-require-checker, composer-unused, phpcs, psalm
# optional performance gain for psalm: opcache
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, \
Expand Down Expand Up @@ -150,120 +262,6 @@ jobs:
- name: Security check for updated dependencies
run: composer audit

unit-tests-linux:
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
runs-on: ${{ matrix.operating-system }}
needs: [linter, quality, security]
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2', '8.3']

steps:
- name: Setup PHP, with composer and extensions
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, \
memcached, openssl, pcre, posix, spl, xml
tools: composer
ini-values: error_reporting=E_ALL
coverage: pcov

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- uses: actions/checkout@v4

- name: Get composer cache directory
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$GITHUB_ENV"

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: $COMPOSER_CACHE
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader

- name: Run unit tests with coverage
if: ${{ matrix.php-versions == '8.3' }}
run: vendor/bin/phpunit

- name: Run unit tests (no coverage)
if: ${{ matrix.php-versions != '8.3' }}
run: vendor/bin/phpunit --no-coverage

- name: Save coverage data
if: ${{ matrix.php-versions == '8.3' }}
uses: actions/upload-artifact@v4
with:
name: coverage-data
path: ${{ github.workspace }}/build

unit-tests-windows:
name: "Unit tests, PHP ${{ matrix.php-versions }}, ${{ matrix.operating-system }}"
runs-on: ${{ matrix.operating-system }}
needs: [linter, quality, security]
strategy:
fail-fast: true
matrix:
operating-system: [windows-latest]
php-versions: ['8.1']
#php-versions: ['8.1', '8.2', '8.3'] Waiting for memcached-3.2.1

steps:
- name: Setup PHP, with composer and extensions
# https://github.com/shivammathur/setup-php
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: ctype, date, dom, fileinfo, filter, hash, intl, mbstring, memcached-3.2.0, openssl, pcre, posix, spl, xml
tools: composer
ini-values: error_reporting=E_ALL
coverage: none

- name: Setup problem matchers for PHP
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Set git to use LF
run: |
git config --global core.autocrlf false
git config --global core.eol lf

- uses: actions/checkout@v4

- name: Get composer cache directory
run: echo COMPOSER_CACHE="$(composer config cache-files-dir)" >> "$env:GITHUB_ENV"

- name: Cache composer dependencies
uses: actions/cache@v4
with:
path: $COMPOSER_CACHE
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader --ignore-platform-req=ext-posix

- name: Run unit tests
run: vendor/bin/phpunit --no-coverage

coverage:
name: Code coverage
runs-on: [ubuntu-latest]
Expand Down
2 changes: 1 addition & 1 deletion phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
By default it is less stringent about long lines than other coding standards
</description>

<file>config-templates</file>
<file>config</file>
<file>src</file>
<file>tests</file>
<!-- Use this to exclude paths. You can have multiple patterns -->
Expand Down
9 changes: 0 additions & 9 deletions psalm-dev.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@
</ignoreFiles>
</projectFiles>

<issueHandlers>
<!-- Ignore UnresolvableInclude on CLI-scripts -->
<UnresolvableInclude>
<errorLevel type="suppress">
<file name="tests/bootstrap.php" />
</errorLevel>
</UnresolvableInclude>
</issueHandlers>

<stubs>
<file name="vendor/simplesamlphp/simplesamlphp-test-framework/stubs/memcache.php" />
<file name="vendor/simplesamlphp/simplesamlphp-test-framework/stubs/memcached.php" />
Expand Down
2 changes: 1 addition & 1 deletion psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
reportMixedIssues="false"
>
<projectFiles>
<directory name="config-templates" />
<directory name="config" />
<directory name="src" />
</projectFiles>

Expand Down
10 changes: 7 additions & 3 deletions routing/routes/routes.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---

memcookie-main:
path: /
defaults: { _controller: 'SimpleSAML\Module\memcookie\Controller\Memcookie::main' }
methods: [GET]
path: /
defaults: {
_controller: 'SimpleSAML\Module\memcookie\Controller\Memcookie::main'
}
methods: [GET]
5 changes: 2 additions & 3 deletions tests/src/Controller/MemcookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@
*
* @package SimpleSAML\Test
*/
class MemcookieTest extends TestCase
final class MemcookieTest extends TestCase

Check failure on line 21 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

UnusedClass

tests/src/Controller/MemcookieTest.php:21:13: UnusedClass: Class SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest is never used (see https://psalm.dev/075)

Check failure on line 21 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

UnusedClass

tests/src/Controller/MemcookieTest.php:21:13: UnusedClass: Class SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest is never used (see https://psalm.dev/075)
{
/** @var \SimpleSAML\Configuration */
protected Configuration $authsources;

Check warning on line 24 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

PropertyNotSetInConstructor

tests/src/Controller/MemcookieTest.php:24:29: PropertyNotSetInConstructor: Property SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::$authsources is not defined in constructor of SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest or in any methods called in the constructor (see https://psalm.dev/074)

Check warning on line 24 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

PropertyNotSetInConstructor

tests/src/Controller/MemcookieTest.php:24:29: PropertyNotSetInConstructor: Property SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::$authsources is not defined in constructor of SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest or in any methods called in the constructor (see https://psalm.dev/074)

/** @var \SimpleSAML\Configuration */
protected Configuration $config;

Check warning on line 27 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

PropertyNotSetInConstructor

tests/src/Controller/MemcookieTest.php:27:29: PropertyNotSetInConstructor: Property SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::$config is not defined in constructor of SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest or in any methods called in the constructor (see https://psalm.dev/074)

Check warning on line 27 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

PropertyNotSetInConstructor

tests/src/Controller/MemcookieTest.php:27:29: PropertyNotSetInConstructor: Property SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::$config is not defined in constructor of SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest or in any methods called in the constructor (see https://psalm.dev/074)

/** @var \SimpleSAML\Utils\HTTP */
protected Utils\Http $http_utils;

Check warning on line 30 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

PropertyNotSetInConstructor

tests/src/Controller/MemcookieTest.php:30:26: PropertyNotSetInConstructor: Property SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::$http_utils is not defined in constructor of SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest or in any methods called in the constructor (see https://psalm.dev/074)

Check warning on line 30 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

PropertyNotSetInConstructor

tests/src/Controller/MemcookieTest.php:30:26: PropertyNotSetInConstructor: Property SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::$http_utils is not defined in constructor of SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest or in any methods called in the constructor (see https://psalm.dev/074)

/** @var \SimpleSAML\Configuration */
protected Configuration $module_config;

Check warning on line 33 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

PropertyNotSetInConstructor

tests/src/Controller/MemcookieTest.php:33:29: PropertyNotSetInConstructor: Property SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::$module_config is not defined in constructor of SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest or in any methods called in the constructor (see https://psalm.dev/074)

Check warning on line 33 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

PropertyNotSetInConstructor

tests/src/Controller/MemcookieTest.php:33:29: PropertyNotSetInConstructor: Property SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::$module_config is not defined in constructor of SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest or in any methods called in the constructor (see https://psalm.dev/074)

/** @var \SimpleSAML\Session */
protected Session $session;

Check warning on line 36 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

PropertyNotSetInConstructor

tests/src/Controller/MemcookieTest.php:36:23: PropertyNotSetInConstructor: Property SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::$session is not defined in constructor of SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest or in any methods called in the constructor (see https://psalm.dev/074)

Check warning on line 36 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

PropertyNotSetInConstructor

tests/src/Controller/MemcookieTest.php:36:23: PropertyNotSetInConstructor: Property SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::$session is not defined in constructor of SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest or in any methods called in the constructor (see https://psalm.dev/074)


/**
* Set up for each test.
* @return void
*/
protected function setUp(): void

Check failure on line 43 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

MissingOverrideAttribute

tests/src/Controller/MemcookieTest.php:43:5: MissingOverrideAttribute: Method SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::setup should have the "Override" attribute (see https://psalm.dev/358)

Check failure on line 43 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

MissingOverrideAttribute

tests/src/Controller/MemcookieTest.php:43:5: MissingOverrideAttribute: Method SimpleSAML\Test\Module\memcookie\Controller\MemcookieTest::setup should have the "Override" attribute (see https://psalm.dev/358)
{
parent::setUp();

Expand Down Expand Up @@ -68,12 +68,12 @@
Configuration::setPreLoadedConfig($this->authsources, 'authsources.php', 'simplesaml');

$this->http_utils = new class () extends Utils\HTTP {
public function setCookie(string $name, ?string $value, array $params = null, bool $throw = true): void
public function setCookie(string $name, ?string $value, ?array $params = null, bool $throw = true): void

Check failure on line 71 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

MissingOverrideAttribute

tests/src/Controller/MemcookieTest.php:71:13: MissingOverrideAttribute: Method SimpleSAML\Test\Module\memcookie\Controller\_home_runner_work_simplesamlphp_module_memcookie_simplesamlphp_module_memcookie_tests_src_Controller_MemcookieTest_php_70_1763::setcookie should have the "Override" attribute (see https://psalm.dev/358)

Check failure on line 71 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

MissingOverrideAttribute

tests/src/Controller/MemcookieTest.php:71:13: MissingOverrideAttribute: Method SimpleSAML\Test\Module\memcookie\Controller\_home_runner_work_simplesamlphp_module_memcookie_simplesamlphp_module_memcookie_tests_src_Controller_MemcookieTest_php_70_1763::setcookie should have the "Override" attribute (see https://psalm.dev/358)
{
// stub
}

public function redirectTrustedURL(string $url, array $parameters = []): void

Check failure on line 76 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

MissingOverrideAttribute

tests/src/Controller/MemcookieTest.php:76:13: MissingOverrideAttribute: Method SimpleSAML\Test\Module\memcookie\Controller\_home_runner_work_simplesamlphp_module_memcookie_simplesamlphp_module_memcookie_tests_src_Controller_MemcookieTest_php_70_1763::redirecttrustedurl should have the "Override" attribute (see https://psalm.dev/358)

Check failure on line 76 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

MissingOverrideAttribute

tests/src/Controller/MemcookieTest.php:76:13: MissingOverrideAttribute: Method SimpleSAML\Test\Module\memcookie\Controller\_home_runner_work_simplesamlphp_module_memcookie_simplesamlphp_module_memcookie_tests_src_Controller_MemcookieTest_php_70_1763::redirecttrustedurl should have the "Override" attribute (see https://psalm.dev/358)
{
// stub
}
Expand Down Expand Up @@ -121,18 +121,17 @@
$c = new Controller\Memcookie($this->config, $this->session);
$c->setHttpUtils($this->http_utils);
$c->setAuthSimple(new class ('admin') extends Auth\Simple {
public function requireAuth(array $params = []): void

Check failure on line 124 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

MissingOverrideAttribute

tests/src/Controller/MemcookieTest.php:124:13: MissingOverrideAttribute: Method SimpleSAML\Test\Module\memcookie\Controller\_home_runner_work_simplesamlphp_module_memcookie_simplesamlphp_module_memcookie_tests_src_Controller_MemcookieTest_php_123_3473::requireauth should have the "Override" attribute (see https://psalm.dev/358)

Check failure on line 124 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

MissingOverrideAttribute

tests/src/Controller/MemcookieTest.php:124:13: MissingOverrideAttribute: Method SimpleSAML\Test\Module\memcookie\Controller\_home_runner_work_simplesamlphp_module_memcookie_simplesamlphp_module_memcookie_tests_src_Controller_MemcookieTest_php_123_3473::requireauth should have the "Override" attribute (see https://psalm.dev/358)
{
// stub
}

public function getAttributes(): array

Check failure on line 129 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

MissingOverrideAttribute

tests/src/Controller/MemcookieTest.php:129:13: MissingOverrideAttribute: Method SimpleSAML\Test\Module\memcookie\Controller\_home_runner_work_simplesamlphp_module_memcookie_simplesamlphp_module_memcookie_tests_src_Controller_MemcookieTest_php_123_3473::getattributes should have the "Override" attribute (see https://psalm.dev/358)

Check failure on line 129 in tests/src/Controller/MemcookieTest.php

View workflow job for this annotation

GitHub Actions / Quality control

MissingOverrideAttribute

tests/src/Controller/MemcookieTest.php:129:13: MissingOverrideAttribute: Method SimpleSAML\Test\Module\memcookie\Controller\_home_runner_work_simplesamlphp_module_memcookie_simplesamlphp_module_memcookie_tests_src_Controller_MemcookieTest_php_123_3473::getattributes should have the "Override" attribute (see https://psalm.dev/358)
{
return ['uid' => ['dduck']];
}
});

/** @var \SimpleSAML\HTTP\RunnableResponse $response */
$response = $c->main($request);

$this->assertInstanceOf(RunnableResponse::class, $response);
Expand Down
7 changes: 7 additions & 0 deletions tools/linters/.yaml-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---

extends: default

rules:
line-length:
max: 120
Loading