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
15 changes: 15 additions & 0 deletions .docheader
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright %regexp:\d{4}% SURFnet %regexp:(B.V.|bv)%
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
26 changes: 10 additions & 16 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
name: test-integration
on: [ push ]
on:
pull_request:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
matrix:
php-versions: [ '8.2']
experimental: [false]
include:
- php-versions: '8.1'
experimental: true
- php-versions: '8.3'
experimental: true
- php-versions: '8.4'
experimental: true
php-versions: ['8.2', '8.3', '8.4', '8.5']
timeout-minutes: 30
name: PHP ${{ matrix.php-versions }} on Ubuntu latest. Experimental == ${{ matrix.experimental }}
name: PHP ${{ matrix.php-versions }} on Ubuntu latest.
steps:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: Checkout
uses: actions/checkout@master
uses: actions/checkout@v6
- name: Install dependencies
run: composer install
continue-on-error: ${{ matrix.experimental }}
- name: Run CI tests
run: composer check
continue-on-error: ${{ matrix.experimental }}
run: composer check-ci
- name: Output log files on failure
if: failure()
run: tail -2000 /var/log/syslog
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.idea/
composer.lock
/cache.properties
.phpunit.result.cache
var/cache/
var/qa/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 6.0.0
- Add support for Symfony 7.4
- Drop support for Symfony 5.4
- Minimal PHP version bumped to 8.2

## 5.3.0
- Add SSO registration bypass field to the institution configuration
-
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Step-up Middleware Client Bundle
[![Build status](https://github.com/OpenConext/Stepup-Middleware-clientbundle/actions/workflows/test-integration.yml/badge.svg)](https://github.com/OpenConext/Stepup-Middleware-clientbundle/actions/workflows/test-integration.yml)

A Symfony 6 bundle to consume the Step-up Middleware API. See [Stepup-Deploy](https://github.com/OpenConext/Stepup-Deploy) for an overview.
A Symfony bundle to consume the Step-up Middleware API. See [Stepup-Deploy](https://github.com/OpenConext/Stepup-Deploy) for an overview.

## Requirements

Expand Down
5 changes: 5 additions & 0 deletions ci/qa/docheader
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

cd $(dirname $0)/../../

./vendor/bin/docheader --no-ansi check src/ tests/
10 changes: 0 additions & 10 deletions ci/qa/phpcpd

This file was deleted.

2 changes: 1 addition & 1 deletion ci/qa/phplint.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
path: [./src, ./tests]
jobs: 10
cache: /var/qa/phplint.cache
cache-dir: var/cache/qa/phplint.cache
extensions:
- php
exclude:
Expand Down
1 change: 1 addition & 0 deletions ci/qa/phpmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<exclude name="BooleanArgumentFlag" />
<exclude name="ElseExpression" />
<exclude name="StaticAccess" />
<exclude name="UnusedPrivateField" />
</rule>

<rule ref="rulesets/unusedcode.xml">
Expand Down
2 changes: 1 addition & 1 deletion ci/qa/phpunit
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ cd $(dirname $0)/../../

# PHPUnit Bridge should always be used in Symfony applications. (https://symfony.com/doc/current/components/phpunit_bridge.html)
# This will create a phpunit executable in /bin/ instead of /vendor/bin/
./vendor/bin/phpunit -c ci/qa/phpunit.xml
./vendor/bin/phpunit -c ci/qa/phpunit.xml $@
46 changes: 21 additions & 25 deletions ci/qa/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="../../vendor/autoload.php"
cacheDirectory="../../var/cache/qa/phpunit.cache"
>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
<server name="KERNEL_CLASS" value="App\Kernel"/>
</php>
<testsuites>
<testsuite name="Unit">
<directory>../../src/Surfnet/StepupMiddlewareClient/Tests</directory>
<directory>../../src/Surfnet/StepupMiddlewareClientBundle/Tests</directory>
</testsuite>

</testsuites>
<coverage processUncoveredFiles="true">
<include>
<directory>../../src</directory>
</include>
<exclude>
<directory>../../src/Surfnet/StepupMiddlewareClient/Tests</directory>
<directory>../../src/Surfnet/StepupMiddlewareClientBundle/Tests</directory> </exclude>
</coverage>
<listeners>
<listener class="\Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
<listener class="\Mockery\Adapter\Phpunit\TestListener"/>
</listeners>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=0&amp;max[self]=0"/>
<server name="KERNEL_CLASS" value="App\Kernel"/>
</php>
<testsuites>
<testsuite name="Unit">
<directory>../../src/Surfnet/StepupMiddlewareClient/Tests</directory>
<directory>../../src/Surfnet/StepupMiddlewareClientBundle/Tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory>../../src</directory>
</include>
<exclude>
<directory>../../src/Surfnet/StepupMiddlewareClient/Tests</directory>
<directory>../../src/Surfnet/StepupMiddlewareClientBundle/Tests</directory>
</exclude>
</source>
</phpunit>
22 changes: 22 additions & 0 deletions ci/qa/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\Php74\Rector\Property\RestoreDefaultNullToNullableTypePropertyRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/../../src',
])
->withPhpSets()
->withAttributesSets(all: true)
->withComposerBased(twig: true, doctrine: true, phpunit: true, symfony: true)
->withSkip([
ClassPropertyAssignToConstructorPromotionRector::class,
RestoreDefaultNullToNullableTypePropertyRector::class,
])
->withPHPStanConfigs([__DIR__.'/phpstan.neon'])
->withPreparedSets(deadCode: true)
;
5 changes: 5 additions & 0 deletions ci/qa/rector.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env sh

# Ensure we run from project root
cd "$(dirname "$0")/../../" || exit 1
./vendor/bin/rector --config=ci/qa/rector.php "$@"
55 changes: 32 additions & 23 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "surfnet/stepup-middleware-client-bundle",
"description": "Symfony 5|6 bundle for consuming the Step-up Middleware API.",
"description": "Symfony bundle for consuming the Step-up Middleware API.",
"license": "Apache-2.0",
"minimum-stability": "stable",
"autoload": {
Expand All @@ -10,46 +10,54 @@
}
},
"require": {
"php": "^8.1",
"psr/log": "~2.0",
"surfnet/stepup-bundle": "^6.0",
"symfony/config": "^5.4|^6.3",
"symfony/dependency-injection": "^5.4|^6.3",
"symfony/framework-bundle": "^5.4|^6.3",
"symfony/http-kernel": "^5.4|^6.3",
"symfony/validator": "^5.4|^6.3",
"php": "^8.2",
"beberlei/assert": "^3.3",
"brick/math": "^0.14.1",
"guzzlehttp/guzzle": "^7.8",
"beberlei/assert": "~2.0",
"psr/log": "^3.0",
"ramsey/uuid": "^4.7",
"brick/math": "^0.11.0"
"surfnet/stepup-bundle": "^7.0.1",
"surfnet/stepup-saml-bundle": "^7.0.1",
"symfony/config": "^6.4|^7.4",
"symfony/dependency-injection": "^6.4|^7.4",
"symfony/framework-bundle": "^6.4|^7.4",
"symfony/http-kernel": "^6.4|^7.4",
"symfony/validator": "^6.4|^7.4"
},
"require-dev": {
"matthiasnoback/symfony-config-test": "^4.0|^v5.0.0",
"malukenho/docheader": "^1.1",
"matthiasnoback/symfony-config-test": "^6.1",
"mockery/mockery": "^1.6",
"overtrue/phplint": "*",
"overtrue/phplint": "^9.7.1",
"phpmd/phpmd": "^2.13",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-symfony": "^1.3",
"phpunit/phpunit": "^9.6",
"sebastian/phpcpd": "^6.0",
"slevomat/coding-standard": "^8.13",
"squizlabs/php_codesniffer": "^3.7.1",
"symfony/phpunit-bridge": "^5.4|^6.3"
"phpstan/phpstan": "^2",
"phpstan/phpstan-symfony": "^2",
"phpunit/phpunit": "^11.5.46",
"rector/rector": "^2",
"slevomat/coding-standard": "^8.26",
"squizlabs/php_codesniffer": "^4.0",
"symfony/phpunit-bridge": "^6.4|^7.4"
},
"scripts": {
"check": [
"@check-ci",
"@rector"
],
"check-ci": [
"@composer-validate",
"@license-headers",
"@phplint",
"@phpcpd",
"@phpcs",
"@phpmd",
"@phpstan",
"@test"
],
"license-headers": "./ci/qa/docheader",
"composer-validate": "./ci/qa/validate",
"rector": "./ci/qa/rector.sh --dry-run",
"rector-fix": "./ci/qa/rector.sh",
"phplint": "./ci/qa/phplint",
"phpcs": "./ci/qa/phpcs",
"phpcpd": "./ci/qa/phpcpd",
"phpmd": "./ci/qa/phpmd",
"phpstan": "./ci/qa/phpstan",
"phpstan-baseline": "./ci/qa/phpstan-update-baseline",
Expand All @@ -61,5 +69,6 @@
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
},
"type": "library"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

declare(strict_types = 1);

/**
* Copyright 2016 SURFnet bv
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

namespace Surfnet\StepupMiddlewareClient\Configuration\Dto;

use Assert;
Expand All @@ -22,9 +38,6 @@ public function __construct(string $institution)
$this->institution = $institution;
}

/**
* @return string
*/
public function getInstitution(): string
{
return $this->institution;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public function __construct(private readonly ApiService $apiService)

/**
* @param string $id The RA's locations ID.
* @return null|array
* @throws AccessDeniedToResourceException When the consumer isn't authorised to access given resource.
* @throws ResourceReadException When the server doesn't respond with the resource.
* @throws MalformedResponseException When the server doesn't respond with (well-formed) JSON.
Expand Down
2 changes: 0 additions & 2 deletions src/Surfnet/StepupMiddlewareClient/Dto/HttpQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ interface HttpQuery
{
/**
* Return the Http Query string as should be used, MUST include the '?' prefix.
*
* @return string
*/
public function toHttpQuery(): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@
class AccessDeniedToResourceException extends RuntimeException implements ApiErrorException
{
/**
* @param string $resource
* @param string[] $errors
* @param int $code
* @param null|Exception $previous
*/
public function __construct(string $resource, private readonly array $errors, $code = 0, Exception $previous = null)
public function __construct(string $resource, private readonly array $errors, $code = 0, ?Exception $previous = null)
{
$message = sprintf("Access denied to resource '%s': are you properly authorised?", $resource);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class InvalidArgumentException extends \InvalidArgumentException implements Step
* @param string $expected description of expected type
* @param $parameterName
* @param mixed $parameter the parameter that is not of the expected type.
* @return self
*/
public static function invalidType(string $expected, $parameterName, mixed $parameter): self
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ class ResourceReadException extends RuntimeException implements ApiErrorExceptio
/**
* @param string[] $errors
* @param int $code
* @param null|Exception $previous
*/
public function __construct(string $message, private readonly array $errors, $code = 0, Exception $previous = null)
public function __construct(string $message, private readonly array $errors, $code = 0, ?Exception $previous = null)
{
parent::__construct($message, $code, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function toHttpQuery(): string
);
}

private function assertNonEmptyString(string $value, string $parameterName, string $message = null): void
private function assertNonEmptyString(string $value, string $parameterName, ?string $message = null): void
{
$message = sprintf(
$message ?: '"%s" must be a non-empty string, "%s" given',
Expand Down
Loading