AspireCloud/tests/Feature/Sanctum/ApiTokenPermissionsTest.php
Chuck Adams ef6ba4e584
gardening: dependency updates, more tests (#108)
* fix: rm last vestiges of SyncPlugin

* refactor: move Sanctum tests into their own dir

* tests: zap example tests

* test: break helpers out into the tests/Helpers dir

* build: composer bump

* refactor: rm unused TranslationData class

* build: run composer update since bump does not (WTF)

* refactor: move docker app from /var/www/html to /app

this is the de facto standard for docker apps, and it makes config much simpler if we follow it

* build: upgrade dockerfiles to composer 2.8

* build: tweak composer invocation for prod

* tests: rm placeholder that never got filled out

* tests: write tests for sync themes/plugins

* tests: put back dummy unit test because pest freaks out w/ an empty dir

* tests: rm copypasta from SyncThemeTest

* build: bump after update, silly, not before
2024-11-23 09:52:02 -07:00

35 lines
1,002 B
PHP

<?php
use App\Models\User;
use Illuminate\Support\Str;
use Laravel\Jetstream\Features;
test('api token permissions can be updated', function () {
if (Features::hasTeamFeatures()) {
$this->actingAs($user = User::factory()->withPersonalTeam()->create());
} else {
$this->actingAs($user = User::factory()->create());
}
$token = $user->tokens()->create([
'name' => 'Test Token',
'token' => Str::random(40),
'abilities' => ['create', 'read'],
]);
$this->put('/user/api-tokens/' . $token->id, [
'name' => $token->name,
'permissions' => [
'delete',
'missing-permission',
],
]);
expect($user->fresh()->tokens->first())
->can('delete')->toBeTrue()
->can('read')->toBeFalse()
->can('missing-permission')->toBeFalse();
})->skip(function () {
// return !Features::hasApiFeatures();
return true;
}, 'There is only a read option on the AspirePress API.');