Отключаем RateLimiter для запросов, что идут с хоста старого сервера авторизации, но включаем для остальных (фикс для beforeAction)

This commit is contained in:
ErickSkrauch
2016-09-08 19:06:44 +03:00
parent c2eee9b67d
commit d2fd803b0d
3 changed files with 60 additions and 1 deletions

View File

@ -11,7 +11,7 @@ use yii\web\Request;
class RateLimiterTest extends TestCase {
public function testCheckRateLimiterWithValidServerId() {
public function testCheckRateLimiterWithOldAuthserver() {
/** @var Connection|\PHPUnit_Framework_MockObject_MockObject $redis */
$redis = $this->getMockBuilder(Connection::class)
->setMethods(['executeCommand'])
@ -34,6 +34,30 @@ class RateLimiterTest extends TestCase {
$filter->checkRateLimit(null, new Request(), null, null);
}
public function testCheckRateLimiterWithValidServerId() {
/** @var Connection|\PHPUnit_Framework_MockObject_MockObject $redis */
$redis = $this->getMockBuilder(Connection::class)
->setMethods(['executeCommand'])
->getMock();
$redis->expects($this->never())
->method('executeCommand');
Yii::$app->set('redis', $redis);
/** @var Request|\PHPUnit_Framework_MockObject_MockObject $request */
$request = $this->getMockBuilder(Request::class)
->setMethods(['getHostInfo'])
->getMock();
$request->expects($this->any())
->method('getHostInfo')
->will($this->returnValue('http://authserver.ely.by'));
$filter = new RateLimiter();
$filter->checkRateLimit(null, $request, null, null);
}
/**
* @expectedException \yii\web\TooManyRequestsHttpException
*/