Re-usable ACL checks on teams (#5925)

This commit is contained in:
Kevin Papst
2026-04-26 17:06:59 +02:00
committed by GitHub
parent 7a559a09e6
commit 20c7b03bd9
14 changed files with 1393 additions and 149 deletions

View File

@@ -79,7 +79,7 @@ class ConfigurationTest extends TestCase
self::assertInstanceOf(TwigFunction::class, $functions[0]);
self::assertSame('config', $functions[0]->getName());
$environment = $this->createEnvironment(['template' => '{{ config(\'theme.branding.company\') }}']);
$environment = $this->createEnvironment(['template' => '{{ config("theme.branding.company") }}']);
$environment->addExtension($sut);
self::assertSame('Acme Inc.', $environment->render('template'));
@@ -105,9 +105,9 @@ class ConfigurationTest extends TestCase
public static function provideSandboxAllowedTemplates(): iterable
{
yield 'avatar urls' => ['{{ config(\'themeAllowAvatarUrls\') ? \'1\' : \'0\' }}', '1'];
yield 'branding logo' => ['{{ config(\'theme.branding.logo\') }}', 'logo.png'];
yield 'branding company' => ['{{ config(\'theme.branding.company\') }}', 'Acme Inc.'];
yield 'avatar urls' => ['{{ config("themeAllowAvatarUrls") ? "1" : "0" }}', '1'];
yield 'branding logo' => ['{{ config("theme.branding.logo") }}', 'logo.png'];
yield 'branding company' => ['{{ config("theme.branding.company") }}', 'Acme Inc.'];
}
#[DataProvider('provideSandboxAllowedTemplates')]
@@ -140,7 +140,7 @@ class ConfigurationTest extends TestCase
public function testSandboxRejectsNonWhitelistedConfigAccess(): void
{
$environment = $this->createEnvironment(['template' => '{{ config(\'showAbout\') ? \'1\' : \'0\' }}'], true);
$environment = $this->createEnvironment(['template' => '{{ config("showAbout") ? "1" : "0" }}'], true);
$environment->addExtension($this->createExtension($this->getDefaultSettings()));
$this->expectException(SecurityError::class);

View File

@@ -77,4 +77,22 @@ class ContextTest extends TestCase
$sut = $this->getSut($this->getDefaultSettings(), ['X-Requested-With' => 'Kimai']);
self::assertTrue($sut->isJavascriptRequest());
}
public function testDeprecatedGetBrandingAlwaysReturnsNull(): void
{
$sut = $this->getSut($this->getDefaultSettings());
$previousHandler = set_error_handler(static function (int $type, string $message): true {
self::assertSame(E_USER_DEPRECATED, $type);
self::assertSame('Use config() instead of "kimai_context" to access system configurations', $message);
return true;
});
try {
self::assertNull($sut->getBranding('legacyAccess'));
} finally {
restore_error_handler();
}
}
}