mirror of
https://github.com/flarum/framework.git
synced 2025-02-06 12:27:30 +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' => [
|
'users' => [
|
||||||
$this->normalUser(),
|
$this->normalUser(),
|
||||||
],
|
],
|
||||||
'access_tokens' => [
|
|
||||||
['token' => 'normaltoken', 'user_id' => 2],
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +45,9 @@ class ListTest extends TestCase
|
||||||
public function shows_index_for_user()
|
public function shows_index_for_user()
|
||||||
{
|
{
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/notifications')
|
$this->request('GET', '/api/notifications', [
|
||||||
->withHeader('Authorization', 'Token normaltoken')
|
'authenticatedAs' => 2,
|
||||||
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
|
|
@ -35,9 +35,6 @@ class CreationTest extends TestCase
|
||||||
'settings' => [
|
'settings' => [
|
||||||
['key' => 'mail_driver', 'value' => 'log'],
|
['key' => 'mail_driver', 'value' => 'log'],
|
||||||
],
|
],
|
||||||
'access_tokens' => [
|
|
||||||
['token' => 'admintoken', 'user_id' => 1],
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +125,7 @@ class CreationTest extends TestCase
|
||||||
'POST',
|
'POST',
|
||||||
'/api/users',
|
'/api/users',
|
||||||
[
|
[
|
||||||
|
'authenticatedAs' => 1,
|
||||||
'json' => [
|
'json' => [
|
||||||
'data' => [
|
'data' => [
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
|
@ -139,7 +137,7 @@ class CreationTest extends TestCase
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
)->withHeader('Authorization', 'Token admintoken')
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(201, $response->getStatusCode());
|
$this->assertEquals(201, $response->getStatusCode());
|
||||||
|
|
|
@ -33,9 +33,6 @@ class ListTest extends TestCase
|
||||||
'group_user' => [
|
'group_user' => [
|
||||||
['user_id' => 1, 'group_id' => 1],
|
['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()
|
public function shows_index_for_admin()
|
||||||
{
|
{
|
||||||
$response = $this->send(
|
$response = $this->send(
|
||||||
$this->request('GET', '/api/users')
|
$this->request('GET', '/api/users', [
|
||||||
->withHeader('Authorization', 'Token admintoken')
|
'authenticatedAs' => 1,
|
||||||
|
])
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(200, $response->getStatusCode());
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user