forked from BookStackApp/BookStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApiConfigTest.php
More file actions
56 lines (42 loc) · 1.54 KB
/
Copy pathApiConfigTest.php
File metadata and controls
56 lines (42 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Tests\Api;
use Tests\TestCase;
class ApiConfigTest extends TestCase
{
use TestsApi;
protected $endpoint = '/api/books';
public function test_default_item_count_reflected_in_listing_requests()
{
$this->actingAsApiEditor();
config()->set(['api.default_item_count' => 5]);
$resp = $this->get($this->endpoint);
$resp->assertJsonCount(5, 'data');
config()->set(['api.default_item_count' => 1]);
$resp = $this->get($this->endpoint);
$resp->assertJsonCount(1, 'data');
}
public function test_default_item_count_does_not_limit_count_param()
{
$this->actingAsApiEditor();
config()->set(['api.default_item_count' => 1]);
$resp = $this->get($this->endpoint . '?count=5');
$resp->assertJsonCount(5, 'data');
}
public function test_max_item_count_limits_listing_requests()
{
$this->actingAsApiEditor();
config()->set(['api.max_item_count' => 2]);
$resp = $this->get($this->endpoint);
$resp->assertJsonCount(2, 'data');
$resp = $this->get($this->endpoint . '?count=5');
$resp->assertJsonCount(2, 'data');
}
public function test_requests_per_min_alters_rate_limit()
{
$resp = $this->actingAsApiEditor()->get($this->endpoint);
$resp->assertHeader('x-ratelimit-limit', 180);
config()->set(['api.requests_per_minute' => 10]);
$resp = $this->actingAsApiEditor()->get($this->endpoint);
$resp->assertHeader('x-ratelimit-limit', 10);
}
}