Mailgun-461: Validate limits (#565)

* Check limit for paginated domains

* Check limit for paginated events

* Check limit for paginated rotues

* Check limit for paginated tags

* Check limit for paginated mailing lists

* Replace unexpected Assert
This commit is contained in:
David Garcia 2019-02-18 15:43:59 +00:00 committed by Tobias Nyholm
parent 7e438f4b4e
commit abf2a0ae55
5 changed files with 10 additions and 2 deletions

View File

@ -40,6 +40,8 @@ class Domain extends HttpApi
*/
public function index(int $limit = 100, int $skip = 0)
{
Assert::range($limit, 1, 1000);
$params = [
'limit' => $limit,
'skip' => $skip,

View File

@ -30,6 +30,10 @@ class Event extends HttpApi
{
Assert::stringNotEmpty($domain);
if (array_key_exists('limit', $params)) {
Assert::range($params['limit'], 1, 300);
}
$response = $this->httpGet(sprintf('/v3/%s/events', $domain), $params);
return $this->hydrateResponse($response, EventResponse::class);

View File

@ -40,8 +40,7 @@ class MailingList extends HttpApi
*/
public function pages(int $limit = 100)
{
Assert::integer($limit);
Assert::greaterThan($limit, 0);
Assert::range($limit, 1, 1000);
$params = [
'limit' => $limit,

View File

@ -37,6 +37,7 @@ class Route extends HttpApi
{
Assert::greaterThan($limit, 0);
Assert::greaterThanEq($skip, 0);
Assert::range($limit, 1, 1000);
$params = [
'limit' => $limit,

View File

@ -38,6 +38,8 @@ class Tag extends HttpApi
public function index(string $domain, int $limit = 100)
{
Assert::stringNotEmpty($domain);
Assert::range($limit, 1, 1000);
$params = [
'limit' => $limit,
];