tokenize('hentai-1080p/2026/Title/E01.mp4'); $time = $this->tokenize(now()->addHours(6)->toDateTimeString()); $this->getJson("/check/{$folder}/{$time}") ->assertOk() ->assertJson([ 'valid' => true, 'type' => 'file', ]) ->assertJsonPath('size', strlen('fake-content')); } public function test_valid_directory_is_recognized(): void { Storage::fake('local'); Storage::put('2026/Title/E01/720/manifest.mpd', 'fake-manifest'); $folder = $this->tokenize('2026/Title'); $time = $this->tokenize(now()->addHours(6)->toDateTimeString()); $this->getJson("/check/{$folder}/{$time}") ->assertOk() ->assertJson([ 'valid' => true, 'type' => 'directory', 'size' => null, ]); } public function test_missing_path_returns_404(): void { Storage::fake('local'); $folder = $this->tokenize('hentai/2026/Title/E01.mp4'); $time = $this->tokenize(now()->addHours(6)->toDateTimeString()); $this->getJson("/check/{$folder}/{$time}") ->assertStatus(404) ->assertJson(['valid' => false]); } public function test_expired_token_returns_410(): void { Storage::fake('local'); Storage::put('hentai/2026/Title/E01.mp4', 'fake-content'); $folder = $this->tokenize('hentai/2026/Title/E01.mp4'); $time = $this->tokenize(now()->subMinute()->toDateTimeString()); $this->getJson("/check/{$folder}/{$time}") ->assertStatus(410) ->assertJson(['valid' => false]); } public function test_invalid_token_returns_422(): void { Storage::fake('local'); $this->getJson('/check/not-a-token/not-a-token') ->assertStatus(422) ->assertJson(['valid' => false]); } public function test_path_traversal_is_rejected(): void { Storage::fake('local'); $folder = $this->tokenize('../../etc/passwd'); $time = $this->tokenize(now()->addHours(6)->toDateTimeString()); $this->getJson("/check/{$folder}/{$time}") ->assertStatus(422) ->assertJson(['valid' => false]); } }