mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-07-31 15:24:31 +03:00
@ -1,10 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
<?php namespace Tests\Api;
|
||||
|
||||
use BookStack\Auth\Permissions\RolePermission;
|
||||
use BookStack\Auth\User;
|
||||
use Carbon\Carbon;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ApiAuthTest extends TestCase
|
||||
{
|
||||
|
@ -1,9 +1,6 @@
|
||||
<?php
|
||||
<?php namespace Tests\Api;
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use BookStack\Auth\Permissions\RolePermission;
|
||||
use Carbon\Carbon;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ApiConfigTest extends TestCase
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
<?php namespace Tests\Api;
|
||||
|
||||
namespace Tests;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ApiDocsTest extends TestCase
|
||||
{
|
||||
|
@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace Tests;
|
||||
<?php namespace Tests\Api;
|
||||
|
||||
use BookStack\Entities\Book;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ApiListingTest extends TestCase
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php namespace Tests;
|
||||
<?php namespace Tests\Api;
|
||||
|
||||
use BookStack\Entities\Book;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BooksApiTest extends TestCase
|
||||
{
|
||||
|
36
tests/Api/TestsApi.php
Normal file
36
tests/Api/TestsApi.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php namespace Tests\Api;
|
||||
|
||||
trait TestsApi
|
||||
{
|
||||
|
||||
protected $apiTokenId = 'apitoken';
|
||||
protected $apiTokenSecret = 'password';
|
||||
|
||||
/**
|
||||
* Set the API editor role as the current user via the API driver.
|
||||
*/
|
||||
protected function actingAsApiEditor()
|
||||
{
|
||||
$this->actingAs($this->getEditor(), 'api');
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format the given items into a standardised error format.
|
||||
*/
|
||||
protected function errorResponse(string $message, int $code): array
|
||||
{
|
||||
return ["error" => ["code" => $code, "message" => $message]];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an approved API auth header.
|
||||
*/
|
||||
protected function apiAuthHeader(): array
|
||||
{
|
||||
return [
|
||||
"Authorization" => "Token {$this->apiTokenId}:{$this->apiTokenSecret}"
|
||||
];
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user