1
0
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:
Alexander Skvortsov
2021-05-10 17:41:38 -04:00
committed by GitHub
parent b0a26eb78c
commit 104a31ba30
13 changed files with 427 additions and 93 deletions

View File

@@ -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());
}
}