Release 2.26 (#5189)

* bring back deprecated methods
* bump packages
* fix SAML redirect
* config flag for break times
* use class constant instead of string in attributes
* throw if all tags were not found - fixes #4792
This commit is contained in:
Kevin Papst
2024-12-05 10:42:07 +01:00
committed by GitHub
parent 70741eebfd
commit 82a3b99a31
39 changed files with 437 additions and 397 deletions

View File

@@ -10,11 +10,13 @@
namespace App\Tests\Controller\Auth;
use App\Configuration\SamlConfiguration;
use App\Configuration\SamlConfigurationInterface;
use App\Configuration\SystemConfiguration;
use App\Controller\Auth\SamlController;
use App\Saml\SamlAuthFactory;
use App\Tests\Configuration\TestConfigLoader;
use App\Tests\Mocks\Saml\SamlAuthFactoryFactory;
use App\Tests\Mocks\SecurityFactory;
use App\Tests\Mocks\SystemConfigurationFactory;
use OneLogin\Saml2\Auth;
use PHPUnit\Framework\TestCase;
@@ -28,19 +30,14 @@ use Symfony\Component\Security\Http\SecurityRequestAttributes;
*/
class SamlControllerTest extends TestCase
{
/**
* @param array $settings
* @param array $loaderSettings
* @return SystemConfiguration
*/
protected function getSystemConfigurationMock(array $settings, array $loaderSettings = [])
protected function getSystemConfigurationMock(array $settings, array $loaderSettings = []): SystemConfiguration
{
$loader = new TestConfigLoader($loaderSettings);
return SystemConfigurationFactory::create($loader, $settings);
}
protected function getDefaultSettings(bool $activated = true)
protected function getDefaultSettings(bool $activated = true): array
{
return [
'saml' => [
@@ -66,10 +63,15 @@ class SamlControllerTest extends TestCase
$factory = $this->getMockBuilder(SamlAuthFactory::class)->disableOriginalConstructor()->getMock();
$sut = new SamlController($factory, $this->getSamlConfiguration());
$sut = $this->getSut($factory, $this->getSamlConfiguration());
$sut->assertionConsumerServiceAction();
}
public function getSut(SamlAuthFactory $authFactory, SamlConfigurationInterface $samlConfiguration): SamlController
{
return new SamlController($authFactory, $samlConfiguration, (new SecurityFactory($this))->create());
}
public function testMetadataAction(): void
{
$expectedXmlString = <<<EOD
@@ -101,7 +103,7 @@ class SamlControllerTest extends TestCase
$factory = $this->getMockBuilder(SamlAuthFactory::class)->disableOriginalConstructor()->getMock();
$factory->expects($this->once())->method('create')->willReturn($oauth);
$sut = new SamlController($factory, $this->getSamlConfiguration());
$sut = $this->getSut($factory, $this->getSamlConfiguration());
$result = $sut->metadataAction();
self::assertEquals('xml', $result->headers->get('Content-Type'));
@@ -129,7 +131,7 @@ class SamlControllerTest extends TestCase
$factory = $this->getMockBuilder(SamlAuthFactory::class)->disableOriginalConstructor()->getMock();
$sut = new SamlController($factory, $this->getSamlConfiguration());
$sut = $this->getSut($factory, $this->getSamlConfiguration());
$sut->loginAction($request);
}
@@ -140,7 +142,7 @@ class SamlControllerTest extends TestCase
$factory = $this->getMockBuilder(SamlAuthFactory::class)->disableOriginalConstructor()->getMock();
$sut = new SamlController($factory, $this->getSamlConfiguration(false));
$sut = $this->getSut($factory, $this->getSamlConfiguration(false));
$sut->loginAction(new Request());
}
@@ -151,7 +153,7 @@ class SamlControllerTest extends TestCase
$factory = $this->getMockBuilder(SamlAuthFactory::class)->disableOriginalConstructor()->getMock();
$sut = new SamlController($factory, $this->getSamlConfiguration(false));
$sut = $this->getSut($factory, $this->getSamlConfiguration(false));
$sut->metadataAction();
}
@@ -162,7 +164,7 @@ class SamlControllerTest extends TestCase
$factory = $this->getMockBuilder(SamlAuthFactory::class)->disableOriginalConstructor()->getMock();
$sut = new SamlController($factory, $this->getSamlConfiguration(false));
$sut = $this->getSut($factory, $this->getSamlConfiguration(false));
$sut->logoutAction();
}
@@ -173,7 +175,7 @@ class SamlControllerTest extends TestCase
$factory = $this->getMockBuilder(SamlAuthFactory::class)->disableOriginalConstructor()->getMock();
$sut = new SamlController($factory, $this->getSamlConfiguration(false));
$sut = $this->getSut($factory, $this->getSamlConfiguration(false));
$sut->assertionConsumerServiceAction();
}
}