Zapier integration (#491)
* create zapier app * install sanctum * move OAuthProviderController * make `api-external` middleware * add zapier endpoints * add tests * token management * zapier event handler * add policy * use `slug` instead of `id` * wip * check policies * change api prefix to `external` * ui tweaks * validate token abilities * open zapier URL * zapier ui tweaks * update zap * Fix linting * Added sample endpoints + minor UI changes * Run PHP code linter --------- Co-authored-by: Julien Nahum <julien@nahum.net>
This commit is contained in:
39
tests/Feature/Zapier/ListWorkspacesTest.php
Normal file
39
tests/Feature/Zapier/ListWorkspacesTest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use App\Models\User;
|
||||
use Laravel\Sanctum\Sanctum;
|
||||
|
||||
use function Pest\Laravel\get;
|
||||
|
||||
test('list all workspaces of a user', function () {
|
||||
$user = User::factory()->create();
|
||||
$workspace = createUserWorkspace($user);
|
||||
|
||||
$anotherUser = User::factory()->create();
|
||||
$anotherWorkspace = createUserWorkspace($anotherUser);
|
||||
|
||||
Sanctum::actingAs(
|
||||
$user,
|
||||
['list-workspaces']
|
||||
);
|
||||
|
||||
get(route('zapier.workspaces'))
|
||||
->assertOk()
|
||||
->assertJsonCount(1)
|
||||
->assertJson([
|
||||
[
|
||||
'id' => $workspace->id,
|
||||
'name' => $workspace->name,
|
||||
]
|
||||
]);
|
||||
});
|
||||
|
||||
test('cannot list workspaces without a corresponding ability', function () {
|
||||
$user = User::factory()->create();
|
||||
$workspace = createUserWorkspace($user);
|
||||
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
get(route('zapier.workspaces'))
|
||||
->assertForbidden();
|
||||
});
|
||||
Reference in New Issue
Block a user