mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-01 05:56:16 +00:00
Isolate Users (#431)
* WIP to isolate users * Resolved issue with SSH AsUser Updated Isolated User Script to use Server User for Team Access Updated Path creation script to simplify for running as the isolated user * Included the server user * PHPMyAdmin script updated Wordpress Script Updated Updated Execute Script to support executing as isolated users * Issue Resolution & Resolved Failing Unit Tests * Fix for isolated_username vs user * Run the deploy as the isolated user * queue updates for isolated user * Support isolated users in cronjobs * script tests for isolated users * Queue tests for isolated users * Cronjob tests for isolated user * Removed default queue command for laravel apps * add default user to factory * laravel pint fixes * ensure echos are consistent * removed unneeded parameter * update * fix queues for isolated users * revert addslashes --------- Co-authored-by: Saeed Vaziry <mr.saeedvaziry@gmail.com>
This commit is contained in:
@ -6,6 +6,8 @@
|
||||
use App\Facades\SSH;
|
||||
use App\Models\Script;
|
||||
use App\Models\ScriptExecution;
|
||||
use App\Models\Server;
|
||||
use App\Models\Site;
|
||||
use App\Web\Pages\Scripts\Executions;
|
||||
use App\Web\Pages\Scripts\Index;
|
||||
use App\Web\Pages\Scripts\Widgets\ScriptExecutionsList;
|
||||
@ -118,6 +120,7 @@ public function test_execute_script_and_view_log(): void
|
||||
$this->assertDatabaseHas('script_executions', [
|
||||
'script_id' => $script->id,
|
||||
'status' => ScriptExecutionStatus::COMPLETED,
|
||||
'user' => 'root',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('server_logs', [
|
||||
@ -133,6 +136,88 @@ public function test_execute_script_and_view_log(): void
|
||||
->assertSuccessful();
|
||||
}
|
||||
|
||||
public function test_execute_script_as_isolated_user(): void
|
||||
{
|
||||
SSH::fake('script output');
|
||||
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$script = Script::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
|
||||
Site::factory()->create([
|
||||
'server_id' => $this->server->id,
|
||||
'user' => 'example',
|
||||
]);
|
||||
|
||||
Livewire::test(Executions::class, [
|
||||
'script' => $script,
|
||||
])
|
||||
->callAction('execute', [
|
||||
'server' => $this->server->id,
|
||||
'user' => 'example',
|
||||
])
|
||||
->assertSuccessful();
|
||||
|
||||
$this->assertDatabaseHas('script_executions', [
|
||||
'script_id' => $script->id,
|
||||
'status' => ScriptExecutionStatus::COMPLETED,
|
||||
'user' => 'example',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_cannot_execute_script_as_non_existing_user(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$script = Script::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
|
||||
Livewire::test(Executions::class, [
|
||||
'script' => $script,
|
||||
])
|
||||
->callAction('execute', [
|
||||
'server' => $this->server->id,
|
||||
'user' => 'example',
|
||||
])
|
||||
->assertHasActionErrors();
|
||||
|
||||
$this->assertDatabaseMissing('script_executions', [
|
||||
'script_id' => $script->id,
|
||||
'user' => 'example',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_cannot_execute_script_as_user_not_on_server(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
||||
$script = Script::factory()->create([
|
||||
'user_id' => $this->user->id,
|
||||
]);
|
||||
|
||||
Site::factory()->create([
|
||||
'server_id' => Server::factory()->create(['user_id' => 1])->id,
|
||||
'user' => 'example',
|
||||
]);
|
||||
|
||||
Livewire::test(Executions::class, [
|
||||
'script' => $script,
|
||||
])
|
||||
->callAction('execute', [
|
||||
'server' => $this->server->id,
|
||||
'user' => 'example',
|
||||
])
|
||||
->assertHasActionErrors();
|
||||
|
||||
$this->assertDatabaseMissing('script_executions', [
|
||||
'script_id' => $script->id,
|
||||
'user' => 'example',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_see_executions(): void
|
||||
{
|
||||
$this->actingAs($this->user);
|
||||
|
Reference in New Issue
Block a user