mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 13:14:37 -04:00
base api testS
This commit is contained in:
parent
883c8f2289
commit
ca225846c2
@ -52,7 +52,6 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
// );
|
// );
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
|
||||||
Relation::morphMap([
|
Relation::morphMap([
|
||||||
'invoices' => Invoice::class,
|
'invoices' => Invoice::class,
|
||||||
'proposals' => Proposal::class,
|
'proposals' => Proposal::class,
|
||||||
|
@ -14,6 +14,7 @@ namespace Tests\Feature;
|
|||||||
use App\Factory\CompanyUserFactory;
|
use App\Factory\CompanyUserFactory;
|
||||||
use App\Models\CompanyToken;
|
use App\Models\CompanyToken;
|
||||||
use App\Models\CompanyUser;
|
use App\Models\CompanyUser;
|
||||||
|
use App\Models\Product;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Routing\Middleware\ThrottleRequests;
|
use Illuminate\Routing\Middleware\ThrottleRequests;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
@ -106,8 +107,40 @@ class BaseApiTest extends TestCase
|
|||||||
|
|
||||||
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
public function testOwnerRoutes()
|
||||||
|
{
|
||||||
|
|
||||||
public function testRestrictedRoute()
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->get('/api/v1/users/');
|
||||||
|
|
||||||
|
$response->assertStatus(200)
|
||||||
|
->assertJson(fn (AssertableJson $json) => $json->has('data',2)->etc());
|
||||||
|
|
||||||
|
/*does not test the number of records however*/
|
||||||
|
collect($this->list_routes)->each(function($route){
|
||||||
|
nlog($route);
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->low_token,
|
||||||
|
])->get("/api/v1/{$route}/")
|
||||||
|
->assertJson(fn (AssertableJson $json) =>
|
||||||
|
$json->has('meta')
|
||||||
|
->has('data')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->low_token,
|
||||||
|
])->get('/api/v1/companies/'.$this->company->hashed_id)
|
||||||
|
->assertStatus(401);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRestrictedUserRoute()
|
||||||
{
|
{
|
||||||
// $permissions = ["view_invoice","view_client","edit_client","edit_invoice","create_invoice","create_client"];
|
// $permissions = ["view_invoice","view_client","edit_client","edit_invoice","create_invoice","create_client"];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user