feat(external): SmtpLivenessProbe — живость почты Yandex 360
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Services\External\SmtpLivenessProbe;
|
||||
|
||||
it('зелёный, когда сокет открылся и вернул баннер 220', function () {
|
||||
$probe = new SmtpLivenessProbe(fn () => "220 smtp.yandex.ru ESMTP\r\n");
|
||||
$r = $probe->check();
|
||||
expect($r->serviceKey)->toBe('email');
|
||||
expect($r->light)->toBe('green');
|
||||
});
|
||||
|
||||
it('красный, когда соединитель бросил (порт недоступен)', function () {
|
||||
$probe = new SmtpLivenessProbe(function () {
|
||||
throw new RuntimeException('Connection refused');
|
||||
});
|
||||
$r = $probe->check();
|
||||
expect($r->light)->toBe('red');
|
||||
expect($r->detail)->toContain('refused');
|
||||
});
|
||||
|
||||
it('красный, когда баннер не 220', function () {
|
||||
$probe = new SmtpLivenessProbe(fn () => "554 blocked\r\n");
|
||||
expect($probe->check()->light)->toBe('red');
|
||||
});
|
||||
Reference in New Issue
Block a user