Skip to content

Commit b37e940

Browse files
committed
wip
Signed-off-by: Mior Muhammad Zaki <[email protected]>
1 parent 4cf3a48 commit b37e940

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

tests/Browser/Auth/AuthenticationTest.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use App\Models\User;
4+
use Illuminate\Support\Facades\RateLimiter;
45

56
test('login screen can be rendered', function () {
67
visit(route('login'))
@@ -21,3 +22,43 @@
2122

2223
$this->assertAuthenticated();
2324
});
25+
26+
test('users can not authenticate with invalid password', function () {
27+
$user = User::factory()->create();
28+
29+
visit(route('login'))
30+
->fill('email', $user->email)
31+
->fill('password', 'wrong-password')
32+
->press('Log in')
33+
->assertUrlIs(route('login'))
34+
->assertSee('These credentials do not match our records.');
35+
36+
$this->assertGuest();
37+
});
38+
39+
test('users can logout', function () {
40+
$user = User::factory()->create();
41+
42+
$this->actingAs($user);
43+
44+
visit(route('dashboard'))
45+
->click($user->name)
46+
->click('Log out')
47+
->assertUrlIs(route('home'));
48+
49+
$this->assertGuest();
50+
});
51+
52+
test('users are rate limited', function () {
53+
$user = User::factory()->create();
54+
55+
RateLimiter::increment(implode('|', [$user->email, '127.0.0.1']), amount: 10);
56+
57+
visit(route('login'))
58+
->fill('email', $user->email)
59+
->fill('password', 'wrong-password')
60+
->press('Log in')
61+
->assertUrlIs(route('login'))
62+
->assertSee('Too many login attempts. Please try again in');
63+
});
64+

tests/Browser/WelcomeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
});
1111

1212
test('guests can browse to register page from welcome page', function () {
13-
visit('/')
13+
visit(route('home'))
1414
->click('Register')
1515
->assertUrlIs(route('register'))
1616
->assertNoConsoleLogs()
@@ -20,7 +20,7 @@
2020
});
2121

2222
test('guests can browse to login page from welcome page', function () {
23-
visit('/')
23+
visit(route('home'))
2424
->click('Log in')
2525
->assertUrlIs(route('login'))
2626
->assertNoConsoleLogs()

0 commit comments

Comments
 (0)