- Add comprehensive health check system with multiple endpoints - Add Prometheus metrics endpoint - Add production logging configurations (5 strategies) - Add complete deployment documentation suite: * QUICKSTART.md - 30-minute deployment guide * DEPLOYMENT_CHECKLIST.md - Printable verification checklist * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference * production-logging.md - Logging configuration guide * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation * README.md - Navigation hub * DEPLOYMENT_SUMMARY.md - Executive summary - Add deployment scripts and automation - Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment - Update README with production-ready features All production infrastructure is now complete and ready for deployment.
63 lines
2.1 KiB
PHP
63 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use App\Framework\MagicLinks\MagicLinkToken;
|
|
|
|
describe('MagicLinkToken Value Object', function () {
|
|
it('creates valid token', function () {
|
|
$token = new MagicLinkToken('abcdefghijklmnopqrstuvwxyz123456');
|
|
|
|
expect($token->value)->toBe('abcdefghijklmnopqrstuvwxyz123456');
|
|
expect((string) $token)->toBe('abcdefghijklmnopqrstuvwxyz123456');
|
|
});
|
|
|
|
it('requires at least 16 characters', function () {
|
|
expect(fn() => new MagicLinkToken('short'))
|
|
->toThrow(\InvalidArgumentException::class, 'Token must be at least 16 characters long');
|
|
});
|
|
|
|
it('accepts exactly 16 characters', function () {
|
|
$token = new MagicLinkToken('1234567890123456');
|
|
|
|
expect($token->value)->toBe('1234567890123456');
|
|
});
|
|
|
|
it('accepts more than 16 characters', function () {
|
|
$longToken = str_repeat('a', 64);
|
|
$token = new MagicLinkToken($longToken);
|
|
|
|
expect($token->value)->toBe($longToken);
|
|
});
|
|
|
|
it('rejects empty string', function () {
|
|
expect(fn() => new MagicLinkToken(''))
|
|
->toThrow(\InvalidArgumentException::class, 'Token value cannot be empty');
|
|
});
|
|
|
|
it('compares tokens correctly', function () {
|
|
$token1 = new MagicLinkToken('abcdefghijklmnop');
|
|
$token2 = new MagicLinkToken('abcdefghijklmnop');
|
|
$token3 = new MagicLinkToken('different-token-');
|
|
|
|
expect($token1->equals($token2))->toBeTrue();
|
|
expect($token1->equals($token3))->toBeFalse();
|
|
});
|
|
|
|
it('uses constant-time comparison', function () {
|
|
$token1 = new MagicLinkToken('1234567890123456');
|
|
$token2 = new MagicLinkToken('1234567890123456');
|
|
|
|
// hash_equals is used internally, which is timing-safe
|
|
expect($token1->equals($token2))->toBeTrue();
|
|
});
|
|
|
|
it('converts to string', function () {
|
|
$tokenValue = 'test-token-value-123';
|
|
$token = new MagicLinkToken($tokenValue);
|
|
|
|
expect($token->__toString())->toBe($tokenValue);
|
|
expect((string) $token)->toBe($tokenValue);
|
|
});
|
|
});
|