feat: clear alumb
This commit is contained in:
@@ -112,7 +112,7 @@ class DeviceAlbumStorageTest extends TestCase
|
||||
public function clear_photos_removes_rows_and_files(): void
|
||||
{
|
||||
Storage::fake('local');
|
||||
$admin = Admin::query()->create(['username' => 'admin', 'password' => 'admin123']);
|
||||
$admin = Admin::query()->create(['username' => 'admin', 'password' => 'admin123', 'is_super' => 1]);
|
||||
$device = Device::query()->create(['device_id' => 'dev-clear']);
|
||||
|
||||
$path = 'c2/photos/dev-clear/abc_hit.jpg';
|
||||
@@ -157,6 +157,36 @@ class DeviceAlbumStorageTest extends TestCase
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function normal_admin_and_agent_cannot_clear_photos(): void
|
||||
{
|
||||
Storage::fake('local');
|
||||
$staff = Admin::query()->create(['username' => 'staff', 'password' => 'admin123', 'is_super' => 0]);
|
||||
$agent = User::query()->create(['username' => 'agent_clear', 'password' => 'secret12', 'status' => 1]);
|
||||
Channel::query()->create([
|
||||
'channel_id' => 'cccccccccccccccccccccccccccccccc',
|
||||
'user_id' => $agent->id,
|
||||
'status' => 1,
|
||||
]);
|
||||
$device = Device::query()->create([
|
||||
'device_id' => 'dev-no-clear',
|
||||
'channel_id' => 'cccccccccccccccccccccccccccccccc',
|
||||
]);
|
||||
|
||||
$this->actingAs($staff, 'admin')
|
||||
->postJson(route('admin.devices.photos.clear', $device))
|
||||
->assertForbidden();
|
||||
|
||||
$this->actingAs($agent, 'agent')
|
||||
->postJson(route('user.devices.photos.clear', $device))
|
||||
->assertForbidden();
|
||||
|
||||
$this->actingAs($staff, 'admin')
|
||||
->get(route('admin.devices.show', ['device' => $device, 'tab' => 'photos']))
|
||||
->assertOk()
|
||||
->assertDontSee('清理相册数据');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function photo_endpoint_serves_png_as_is(): void
|
||||
{
|
||||
@@ -192,7 +222,7 @@ class DeviceAlbumStorageTest extends TestCase
|
||||
$this->markTestSkipped('sips is required to generate and convert HEIC');
|
||||
}
|
||||
Storage::fake('local');
|
||||
$admin = Admin::query()->create(['username' => 'admin', 'password' => 'admin123']);
|
||||
$admin = Admin::query()->create(['username' => 'admin', 'password' => 'admin123', 'is_super' => 1]);
|
||||
$device = Device::query()->create(['device_id' => 'dev-heic']);
|
||||
|
||||
$jpg = sys_get_temp_dir().'/album_'.uniqid().'.jpg';
|
||||
|
||||
Reference in New Issue
Block a user