mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Allow to authenticate using Authorization: Token header, which the KiCAD API uses
This commit is contained in:
parent
feca20ef77
commit
6b0f0d31b9
3 changed files with 32 additions and 1 deletions
|
@ -96,6 +96,24 @@ class APITokenAuthenticationTest extends ApiTestCase
|
|||
self::assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public function testWithAuthorizationToken(): void
|
||||
{
|
||||
//For the KICAD API it should also work with Authorization: Token header instead of Bearer
|
||||
self::ensureKernelShutdown();
|
||||
$client = static::createClient([], ['headers' => ['authorization' => 'Token '.APITokenFixtures::TOKEN_ADMIN]]);;
|
||||
|
||||
//Read should be possible
|
||||
$client->request('GET', '/api/parts');
|
||||
self::assertResponseIsSuccessful();
|
||||
|
||||
//Trying to list all users
|
||||
$client->request('GET', '/api/users');
|
||||
self::assertResponseIsSuccessful();
|
||||
|
||||
$client->request('POST', '/api/footprints', ['json' => ['name' => 'post test']]);
|
||||
self::assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
protected function createClientWithCredentials(string $token): Client
|
||||
{
|
||||
return static::createClient([], ['headers' => ['authorization' => 'Bearer '.$token]]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue