setAccessible(true); return $ref->invoke($job, $url, $token); } beforeEach(function () { Cache::flush(); }); it('fetches the story payload over the hardened path', function () { seedPublicIpForStory('peer.example'); Http::fake([ 'https://peer.example/story' => Http::response('{"id":"https://peer.example/s/1"}', 200, [ 'Content-Type' => 'application/json', ]), ]); $payload = callFetchStoryPayload('https://peer.example/story', 'bearcap-token-1234567890'); expect($payload)->toBeArray() ->and($payload['id'])->toBe('https://peer.example/s/1'); }); it('refuses a payload fetch that redirects to a private address', function () { seedPublicIpForStory('peer.example'); Http::fake([ 'https://peer.example/story' => Http::response('', 302, [ 'Location' => 'http://169.254.169.254/latest/meta-data/', ]), '169.254.169.254/*' => Http::response('SECRET', 200), ]); $payload = callFetchStoryPayload('https://peer.example/story', 'bearcap-token-1234567890'); expect($payload)->toBeNull(); Http::assertNotSent(function ($request) { return str_contains($request->url(), '169.254.169.254'); }); });