withoutVite(); InstanceSettings::unguarded(fn () => InstanceSettings::updateOrCreate(['id' => 0], ['id' => 0])); $this->team = Team::factory()->create(); $this->member = User::factory()->create(); $this->member->teams()->attach($this->team, ['role' => 'member']); $this->actingAs($this->member); session(['currentTeam' => $this->team]); }); test('member cannot create a cloud provider token through the public action', function () { Http::fake(['*' => Http::response([], 200)]); Livewire::test(CloudProviderTokenForm::class) ->set('provider', 'hetzner') ->set('token', 'secret-token') ->set('name', 'Unauthorized token') ->call('addToken') ->assertForbidden(); expect(CloudProviderToken::query()->count())->toBe(0); }); test('member cannot load cloud-init scripts through the public action', function () { $script = CloudInitScript::query()->create([ 'team_id' => $this->team->id, 'name' => 'Protected script', 'script' => '#cloud-config', ]); CloudInitScript::query()->whereKey($script)->update(['uuid' => null]); $component = app(CloudInitScripts::class); expect(fn () => $component->loadScripts()) ->toThrow(AuthorizationException::class); expect($script->refresh()->uuid)->toBeNull(); });