mirror of
https://github.com/flarum/framework.git
synced 2025-02-06 06:56:14 +08:00
Tests: Use new authenticatedAs option where useful
There are two more API integration tests that explicitly add the "Authorization" header right now: - `Flarum\Tests\integration\api\authentication\WithApiKeyTest` - `Flarum\Tests\integration\api\csrf_protection\RequireCsrfTokenTest` These two specifically test authentication, so in those cases the explicitness seems desirable.
This commit is contained in:
parent
8e21fee06c
commit
2b0bc2865d
|
@ -24,9 +24,6 @@ class ListTest extends TestCase
|
|||
'users' => [
|
||||
$this->normalUser(),
|
||||
],
|
||||
'access_tokens' => [
|
||||
['token' => 'normaltoken', 'user_id' => 2],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -48,8 +45,9 @@ class ListTest extends TestCase
|
|||
public function shows_index_for_user()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/notifications')
|
||||
->withHeader('Authorization', 'Token normaltoken')
|
||||
$this->request('GET', '/api/notifications', [
|
||||
'authenticatedAs' => 2,
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
|
|
|
@ -35,9 +35,6 @@ class CreationTest extends TestCase
|
|||
'settings' => [
|
||||
['key' => 'mail_driver', 'value' => 'log'],
|
||||
],
|
||||
'access_tokens' => [
|
||||
['token' => 'admintoken', 'user_id' => 1],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -128,6 +125,7 @@ class CreationTest extends TestCase
|
|||
'POST',
|
||||
'/api/users',
|
||||
[
|
||||
'authenticatedAs' => 1,
|
||||
'json' => [
|
||||
'data' => [
|
||||
'attributes' => [
|
||||
|
@ -139,7 +137,7 @@ class CreationTest extends TestCase
|
|||
]
|
||||
],
|
||||
]
|
||||
)->withHeader('Authorization', 'Token admintoken')
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(201, $response->getStatusCode());
|
||||
|
|
|
@ -33,9 +33,6 @@ class ListTest extends TestCase
|
|||
'group_user' => [
|
||||
['user_id' => 1, 'group_id' => 1],
|
||||
],
|
||||
'access_tokens' => [
|
||||
['token' => 'admintoken', 'user_id' => 1],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -76,8 +73,9 @@ class ListTest extends TestCase
|
|||
public function shows_index_for_admin()
|
||||
{
|
||||
$response = $this->send(
|
||||
$this->request('GET', '/api/users')
|
||||
->withHeader('Authorization', 'Token admintoken')
|
||||
$this->request('GET', '/api/users', [
|
||||
'authenticatedAs' => 1,
|
||||
])
|
||||
);
|
||||
|
||||
$this->assertEquals(200, $response->getStatusCode());
|
||||
|
|
Loading…
Reference in New Issue
Block a user