get(route('login')); $response->assertOk(); }); test('users can authenticate using the login screen', function () { $user = User::factory()->create(); $response = $this->post(route('login.store'), [ 'email' => $user->email, 'password' => 'password', ]); $this->assertAuthenticated(); $response->assertRedirect(route('app.calendar', absolute: false)); }); test('users can not authenticate with invalid password', function () { $user = User::factory()->create(); $this->post(route('login.store'), [ 'email' => $user->email, 'password' => 'wrong-password', ]); $this->assertGuest(); }); test('users can logout', function () { $user = User::factory()->create(); $response = $this->actingAs($user)->post(route('logout')); $this->assertGuest(); $response->assertRedirect('/'); }); test('users are rate limited', function () { $user = User::factory()->create(); $throttleKey = Str::transliterate(Str::lower($user->email).'|127.0.0.1'); RateLimiter::hit($throttleKey, 60); RateLimiter::hit($throttleKey, 60); RateLimiter::hit($throttleKey, 60); RateLimiter::hit($throttleKey, 60); RateLimiter::hit($throttleKey, 60); $response = $this->post(route('login.store'), [ 'email' => $user->email, 'password' => 'wrong-password', ]); $response->assertSessionHasErrors('email'); });