mirror of
https://github.com/flarum/core.git
synced 2025-08-11 02:44:04 +02:00
Run API Client requests through middleware (#2783)
- Add integration tests for login and registration - Use URL instead of controller - Add fluent API - Allow setting parent request, user, session
This commit is contained in:
committed by
GitHub
parent
b0a26eb78c
commit
104a31ba30
@@ -79,4 +79,20 @@ class ThrottleApiTest extends TestCase
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function throttling_applies_to_api_client()
|
||||
{
|
||||
$this->extend((new Extend\ThrottleApi)->set('blockRegistration', function ($request) {
|
||||
if ($request->getAttribute('routeName') === 'users.create') {
|
||||
return true;
|
||||
}
|
||||
}));
|
||||
|
||||
$response = $this->send($this->request('POST', '/register')->withAttribute('bypassCsrfToken', true));
|
||||
|
||||
$this->assertEquals(429, $response->getStatusCode());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user