|
6 | 6 | use Illuminate\Support\Facades\Cache; |
7 | 7 | use Illuminate\Support\Facades\RateLimiter; |
8 | 8 | use PHPUnit\Framework\Attributes\Test; |
| 9 | +use Statamic\Facades\User; |
9 | 10 | use Tests\PreventSavingStacheItemsToDisk; |
10 | 11 | use Tests\TestCase; |
11 | 12 |
|
@@ -143,6 +144,42 @@ public function cp_passkey_endpoint_is_rate_limited() |
143 | 144 | $this->post('/cp/auth/passkeys')->assertRateLimited(); |
144 | 145 | } |
145 | 146 |
|
| 147 | + #[Test] |
| 148 | + public function elevated_session_confirm_endpoint_is_rate_limited() |
| 149 | + { |
| 150 | + $this->actingAs(tap(User::make()->email('foo@bar.com'))->save()); |
| 151 | + |
| 152 | + collect(range(1, 4))->each(fn () => $this->post('/!/auth/elevated-session')->assertNotRateLimited()); |
| 153 | + $this->post('/!/auth/elevated-session')->assertRateLimited(); |
| 154 | + } |
| 155 | + |
| 156 | + #[Test] |
| 157 | + public function cp_elevated_session_confirm_endpoint_is_rate_limited() |
| 158 | + { |
| 159 | + $this->actingAs(tap(User::make()->email('foo@bar.com')->makeSuper())->save()); |
| 160 | + |
| 161 | + collect(range(1, 4))->each(fn () => $this->post('/cp/elevated-session')->assertNotRateLimited()); |
| 162 | + $this->post('/cp/elevated-session')->assertRateLimited(); |
| 163 | + } |
| 164 | + |
| 165 | + #[Test] |
| 166 | + public function elevated_session_passkey_options_endpoint_is_rate_limited() |
| 167 | + { |
| 168 | + $this->actingAs(tap(User::make()->email('foo@bar.com'))->save()); |
| 169 | + |
| 170 | + collect(range(1, 30))->each(fn () => $this->get('/!/auth/elevated-session/passkey-options')->assertNotRateLimited()); |
| 171 | + $this->get('/!/auth/elevated-session/passkey-options')->assertRateLimited(); |
| 172 | + } |
| 173 | + |
| 174 | + #[Test] |
| 175 | + public function cp_elevated_session_passkey_options_endpoint_is_rate_limited() |
| 176 | + { |
| 177 | + $this->actingAs(tap(User::make()->email('foo@bar.com')->makeSuper())->save()); |
| 178 | + |
| 179 | + collect(range(1, 30))->each(fn () => $this->get('/cp/elevated-session/passkey-options')->assertNotRateLimited()); |
| 180 | + $this->get('/cp/elevated-session/passkey-options')->assertRateLimited(); |
| 181 | + } |
| 182 | + |
146 | 183 | #[Test] |
147 | 184 | public function cp_and_frontend_passkeys_have_independent_buckets() |
148 | 185 | { |
|
0 commit comments