refactor(core): centralize reserved system user identity

Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
2026-08-28 19:36:43 -04:00
parent 964128e051
commit 52166feca2
3 changed files with 48 additions and 8 deletions
@@ -11,6 +11,7 @@ namespace KTXF\Mail\Provider;
use KTXF\Mail\Service\ServiceBaseInterface; use KTXF\Mail\Service\ServiceBaseInterface;
use KTXF\Resource\Provider\ResourceProviderBaseInterface; use KTXF\Resource\Provider\ResourceProviderBaseInterface;
use KTXF\Resource\SystemIdentity;
/** /**
* Provider Base Interface * Provider Base Interface
@@ -24,15 +25,9 @@ interface ProviderBaseInterface extends ResourceProviderBaseInterface{
public const JSON_TYPE = 'mail:provider'; public const JSON_TYPE = 'mail:provider';
/** /**
* Reserved user identifier for system-owned mail services * @deprecated Use SystemIdentity::USER.
*
* Services stored under this user id belong to the tenant itself rather
* than any real user (e.g. accounts used to deliver system-generated
* messages such as verification codes and password resets).
*
* @since 2026.07.01
*/ */
public const USER_SYSTEM = 'system'; public const USER_SYSTEM = SystemIdentity::USER;
/** /**
* Finds a service that handles a specific email address * Finds a service that handles a specific email address
+20
View File
@@ -0,0 +1,20 @@
<?php
declare(strict_types=1);
namespace KTXF\Resource;
/**
* Reserved identities used by tenant-scoped internal services.
*/
final class SystemIdentity
{
/**
* User identifier for resources owned by the tenant rather than a person.
*/
public const USER = 'system';
private function __construct()
{
}
}
@@ -0,0 +1,25 @@
<?php
declare(strict_types=1);
namespace KTXT\Unit\Resource;
use KTXF\Mail\Provider\ProviderBaseInterface;
use KTXF\Resource\SystemIdentity;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
final class SystemIdentityTest extends TestCase
{
#[Test]
public function exposesTheReservedSystemUser(): void
{
self::assertSame('system', SystemIdentity::USER);
}
#[Test]
public function retainsTheLegacyMailAlias(): void
{
self::assertSame(SystemIdentity::USER, ProviderBaseInterface::USER_SYSTEM);
}
}