create(['title' => 'Sommerfest', 'published_at' => now()->subHour(), 'must_read' => true]); app(Settings::class)->set('portal.quick_links', [['label' => 'Vivendi PEP', 'url' => 'https://pep.example.com', 'icon' => 'calendar', 'pinned' => true, 'new_tab' => true]]); $token = User::factory()->create()->createToken('App')->plainTextToken; $this->withToken($token)->getJson('/api/v1/feed')->assertOk() ->assertJsonPath('items.0.title', 'Sommerfest') ->assertJsonPath('items.0.like.url', "/api/v1/news/{$post->slug}/like"); $this->withToken($token)->getJson('/api/v1/tasks')->assertOk()->assertJsonPath('data.0.title', '„Sommerfest“ lesen und bestätigen'); $this->withToken($token)->getJson('/api/v1/apps')->assertOk()->assertJsonPath('data.0.label', 'Vivendi PEP'); $this->withToken($token)->getJson('/api/v1/menu')->assertOk()->assertJsonFragment(['label' => 'Neuigkeiten', 'href' => '/neuigkeiten']); } public function test_web_session_opens_a_portal_page_embedded_once(): void { $user = User::factory()->create(); $token = $user->createToken('App')->plainTextToken; $url = $this->withToken($token)->postJson('/api/v1/web-session', ['path' => '/termine'])->assertOk()->json('data.url'); $this->withToken($token)->postJson('/api/v1/web-session', ['path' => 'https://boese.example.com'])->assertUnprocessable(); $this->withToken($token)->postJson('/api/v1/web-session', ['path' => '//boese.example.com'])->assertUnprocessable(); $this->app['auth']->forgetGuards(); $path = parse_url($url, PHP_URL_PATH); $this->withoutToken()->get($path)->assertRedirect('/termine'); $this->assertAuthenticatedAs($user); $this->get('/termine')->assertInertia(fn (Assert $page) => $page->where('embedded', true)); // Nur einmal gültig $this->post('/logout'); $this->get($path)->assertForbidden(); } }