[Web][Tests] Add mailbox group, identity sync, auth, Dovecot and SOGo module tests

This commit is contained in:
FreddleSpl0it committed 2026-10-27 10:15:00 +01:00
1 parent 2c5718c9c9
commit ad86403b87
19 files changed
+1997

No files matched your search

+11
View File
@@ -29,6 +29,17 @@ class ApiResponseTest extends TestCase
], $response->messages());
}
public function testWarningsKeepTheCallSuccessful(): void
{
$response = new ApiResponse();
$response->warning(['group_template_failed', 'Staff', 'a@example.org'], ['mailbox_group', 'edit', 'group', []]);
$this->assertSame([
['type' => 'warning', 'log' => ['mailbox_group', 'edit', 'group', []], 'msg' => ['group_template_failed', 'Staff', 'a@example.org']],
], $response->messages());
}
public function testSecretsAreMaskedInArrayLogParts(): void
{
$response = new ApiResponse(['password1', 'oauth_client_secret']);
+25
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Mailcow\Tests\Core;
use Mailcow\Core\AccessDenied;
use Mailcow\Core\Context;
use Mailcow\Tests\Support\LegacyAclCalls;
use PHPUnit\Framework\TestCase;
@@ -84,6 +85,30 @@ class ContextTest extends TestCase
$this->assertFalse($context->hasAcl('syncjobs'));
}
public function testAdminRightsComeFromTheRoleOrAccessAll(): void
{
$this->assertTrue((new Context('admin', 'admin'))->hasAdminRights());
$this->assertTrue((new Context('user', 'user@example.org', [], true))->hasAdminRights());
$this->assertFalse((new Context('domainadmin', 'da'))->hasAdminRights());
$this->assertFalse(Context::system()->hasAdminRights());
}
public function testReadOnlyApiKeysMayOnlyRead(): void
{
$readOnly = new Context('admin', 'admin', [], false, 'ro');
$readOnly->requireAdmin(false);
(new Context('admin', 'admin', [], false, 'rw'))->requireAdmin();
$this->expectException(AccessDenied::class);
$readOnly->requireAdmin();
}
public function testRequireAdminDeniesOtherRoles(): void
{
$this->expectException(AccessDenied::class);
(new Context('domainadmin', 'da'))->requireAdmin(false);
}
public function testBridgePassesUsernameAndRoleToTheLegacyFunctions(): void
{
$context = new Context('user', 'user@example.org');