test(back): 套餐表单 back hidden input 仅在 back 非空时渲染(护栏)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlanFormBackHiddenInputConditionalTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function loginAsPlatformAdmin(): void
|
||||
{
|
||||
$this->seed();
|
||||
|
||||
$this->post('/admin/login', [
|
||||
'email' => 'platform.admin@demo.local',
|
||||
'password' => 'Platform@123456',
|
||||
])->assertRedirect('/admin');
|
||||
}
|
||||
|
||||
public function test_create_form_should_not_render_back_hidden_input_when_back_is_empty(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$res = $this->get('/admin/plans/create?back=' . urlencode('https://evil.example.com/?x=1'));
|
||||
$res->assertOk();
|
||||
|
||||
// PlanController 会将 unsafe back 清洗为空,因此页面不应渲染 back hidden input
|
||||
$res->assertDontSee('name="back"', false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user