ldc-arcadia-api/tests/Unit/Application/Security/Config/SecurityConfigsTest.php

59 lines
2 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace Tests\Unit\Application\Security\Config;
use Application\Security\Config\DevClientCredentials;
use Application\Security\Config\HmacAuthConfig;
use Application\Security\Config\SecurityAlertMailConfig;
use Application\Security\Models\ValueObjects\ClientIdentifier;
use Application\Security\Models\ValueObjects\ClientName;
use Application\Security\Models\ValueObjects\ClientSecret;
use Application\Security\Models\ValueObjects\Entities\ClientId;
use Ramsey\Uuid\Uuid;
use Shared\ValueObjects\Email;
covers(
DevClientCredentials::class,
HmacAuthConfig::class,
SecurityAlertMailConfig::class,
);
describe('Security Config Objects Unit Tests', function (): void {
it('instantiates DevClientCredentials and HmacAuthConfig', function (): void {
// GIVEN
$id = new ClientId(Uuid::uuid7());
$name = new ClientName('Test Dev Client');
$identifier = new ClientIdentifier('arcadia_id_' . str_repeat('a', 32));
$secret = new ClientSecret('arcadia_sec_' . str_repeat('b', 88));
$credentials = new DevClientCredentials(
id: $id,
name: $name,
identifier: $identifier,
secret: $secret,
);
$hmacConfig = new HmacAuthConfig(
allowDevBypass: true,
devClient: $credentials,
);
// THEN
expect($hmacConfig->allowDevBypass)->toBeTrue()
->and($hmacConfig->devClient)->toBe($credentials)
->and($hmacConfig->devClient?->name->value)->toBe('Test Dev Client')
->and($hmacConfig->devClient?->identifier->value)->toBe($identifier->value);
});
it('instantiates SecurityAlertMailConfig with typed Email VO', function (): void {
// GIVEN
$email = new Email('security-team@arcadia.com');
$config = new SecurityAlertMailConfig($email);
// THEN
expect($config->recipientEmail->value)->toBe('security-team@arcadia.com');
});
});