Files
portal/app/tests/Feature/Auth/UnauthenticatedApiResponseTest.php
T
Дмитрий e8e5c82b86
Accessibility (Pa11y live) / a11y (push) Has been cancelled
SAST — Semgrep / Semgrep SAST scan (push) Has been cancelled
fix(приёмка): FN-RESET + FN-LOGIN-ROUTE + диагностируемость FN-SESSION
FN-RESET: письмо сброса строило именованный роут password.reset которого нет в SPA.
ResetPassword::createUrlUsing → /reset/{token}?email= в AppServiceProvider boot.

FN-LOGIN-ROUTE: гость без Accept json на auth:sanctum уводил в именованный роут
login которого нет → 500. redirectGuestsTo /login + render AuthenticationException
→ 401 JSON для api/*.

FN-SESSION: chromium.launch стоял вне try/catch — отказ запуска браузера маскировался
unhandled-rejection в opaque exit 1 двойник login-rejected. launch в try + top-level
catch → чистый exit 4 + JSON stderr в refresh-session.js и manage-project.js.

Тесты: PasswordResetUrlTest, UnauthenticatedApiResponseTest, node:test launch-failure
в обоих playwright-скриптах. Разбор FN-SESSION + ops-долг playwright install под
www-data + поправки отчёта приёмки + новая находка FN-INN-LOOKUP.

Прод не трогался. Накат — позже вместе с остальным.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-22 08:49:19 +03:00

28 lines
1.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
use Illuminate\Foundation\Testing\DatabaseTransactions;
uses(DatabaseTransactions::class);
// FN-LOGIN-ROUTE (приёмка 22.06.2026): неаутентифицированный запрос к auth:sanctum
// роуту, который НЕ просит JSON (нет Accept: application/json — прямой заход
// браузером/ботом), уводит Laravel в редирект на route('login'), которого в SPA
// нет → «Route [login] not defined» (500). Должно отдавать 401 JSON для /api/*.
test('гость без Accept:json на /api/auth/me получает 401 JSON, не route(login)-ошибку', function () {
// get() без Accept:application/json — expectsJson() === false, как у прямого
// браузерного/ботового захода. Заголовок Accept по умолчанию не JSON.
$r = $this->get('/api/auth/me', ['Accept' => 'text/html']);
$r->assertStatus(401);
$r->assertHeader('Content-Type', 'application/json');
expect($r->json('message'))->not->toBeEmpty();
});
test('гость c Accept:json на /api/auth/me получает 401 JSON (регрессия — уже работало)', function () {
$r = $this->getJson('/api/auth/me');
$r->assertStatus(401);
});