User management (#185)

This commit is contained in:
Saeed Vaziry
2024-04-29 20:58:04 +02:00
committed by GitHub
parent 35f896eab1
commit d846acaa8d
106 changed files with 1490 additions and 434 deletions

View File

@ -17,7 +17,7 @@ public function test_add_email_channel(): void
{
$this->actingAs($this->user);
$this->post(route('notification-channels.add'), [
$this->post(route('settings.notification-channels.add'), [
'provider' => NotificationChannel::EMAIL,
'email' => 'email@example.com',
'label' => 'Email',
@ -40,7 +40,7 @@ public function test_cannot_add_email_channel(): void
$this->actingAs($this->user);
$this->post(route('notification-channels.add'), [
$this->post(route('settings.notification-channels.add'), [
'provider' => NotificationChannel::EMAIL,
'email' => 'email@example.com',
'label' => 'Email',
@ -61,7 +61,7 @@ public function test_add_slack_channel(): void
Http::fake();
$this->post(route('notification-channels.add'), [
$this->post(route('settings.notification-channels.add'), [
'provider' => NotificationChannel::SLACK,
'webhook_url' => 'https://hooks.slack.com/services/123/token',
'label' => 'Slack',
@ -84,7 +84,7 @@ public function test_cannot_add_slack_channel(): void
'slack.com/*' => Http::response(['ok' => false], 401),
]);
$this->post(route('notification-channels.add'), [
$this->post(route('settings.notification-channels.add'), [
'provider' => NotificationChannel::SLACK,
'webhook_url' => 'https://hooks.slack.com/services/123/token',
'label' => 'Slack',
@ -104,7 +104,7 @@ public function test_add_discord_channel(): void
Http::fake();
$this->post(route('notification-channels.add'), [
$this->post(route('settings.notification-channels.add'), [
'provider' => NotificationChannel::DISCORD,
'webhook_url' => 'https://discord.com/api/webhooks/123/token',
'label' => 'Discord',
@ -127,7 +127,7 @@ public function test_cannot_add_discord_channel(): void
'discord.com/*' => Http::response(['ok' => false], 401),
]);
$this->post(route('notification-channels.add'), [
$this->post(route('settings.notification-channels.add'), [
'provider' => NotificationChannel::DISCORD,
'webhook_url' => 'https://discord.com/api/webhooks/123/token',
'label' => 'Discord',
@ -147,7 +147,7 @@ public function test_add_telegram_channel(): void
Http::fake();
$this->post(route('notification-channels.add'), [
$this->post(route('settings.notification-channels.add'), [
'provider' => NotificationChannel::TELEGRAM,
'bot_token' => 'token',
'chat_id' => '123',
@ -172,7 +172,7 @@ public function test_cannot_add_telegram_channel(): void
'api.telegram.org/*' => Http::response(['ok' => false], 401),
]);
$this->post(route('notification-channels.add'), [
$this->post(route('settings.notification-channels.add'), [
'provider' => NotificationChannel::TELEGRAM,
'bot_token' => 'token',
'chat_id' => '123',
@ -193,7 +193,7 @@ public function test_see_channels_list(): void
$channel = \App\Models\NotificationChannel::factory()->create();
$this->get(route('notification-channels'))
$this->get(route('settings.notification-channels'))
->assertSuccessful()
->assertSee($channel->provider);
}
@ -204,7 +204,7 @@ public function test_delete_channel(): void
$channel = \App\Models\NotificationChannel::factory()->create();
$this->delete(route('notification-channels.delete', $channel->id))
$this->delete(route('settings.notification-channels.delete', $channel->id))
->assertSessionDoesntHaveErrors();
$this->assertDatabaseMissing('notification_channels', [

View File

@ -14,7 +14,7 @@ public function test_create_project(): void
{
$this->actingAs($this->user);
$this->post(route('projects.create'), [
$this->post(route('settings.projects.create'), [
'name' => 'test',
])->assertSessionDoesntHaveErrors();
@ -27,11 +27,11 @@ public function test_see_projects_list(): void
{
$this->actingAs($this->user);
$project = Project::factory()->create([
'user_id' => $this->user->id,
]);
$project = Project::factory()->create();
$this->get(route('projects'))
$this->user->projects()->attach($project);
$this->get(route('settings.projects'))
->assertSuccessful()
->assertSee($project->name);
}
@ -40,11 +40,11 @@ public function test_delete_project(): void
{
$this->actingAs($this->user);
$project = Project::factory()->create([
'user_id' => $this->user->id,
]);
$project = Project::factory()->create();
$this->delete(route('projects.delete', $project))
$this->user->projects()->attach($project);
$this->delete(route('settings.projects.delete', $project))
->assertSessionDoesntHaveErrors();
$this->assertDatabaseMissing('projects', [
@ -56,11 +56,11 @@ public function test_edit_project(): void
{
$this->actingAs($this->user);
$project = Project::factory()->create([
'user_id' => $this->user->id,
]);
$project = Project::factory()->create();
$this->post(route('projects.update', $project), [
$this->user->projects()->attach($project);
$this->post(route('settings.projects.update', $project), [
'name' => 'new-name',
])->assertSessionDoesntHaveErrors();
@ -74,7 +74,7 @@ public function test_cannot_delete_last_project(): void
{
$this->actingAs($this->user);
$this->delete(route('projects.delete', [
$this->delete(route('settings.projects.delete', [
'project' => $this->user->currentProject,
]))
->assertSessionDoesntHaveErrors()

View File

@ -27,7 +27,7 @@ public function test_connect_provider(string $provider, array $input): void
],
$input
);
$this->post(route('server-providers.connect'), $data)->assertSessionDoesntHaveErrors();
$this->post(route('settings.server-providers.connect'), $data)->assertSessionDoesntHaveErrors();
$this->assertDatabaseHas('server_providers', [
'provider' => $provider,
@ -53,7 +53,7 @@ public function test_cannot_connect_to_provider(string $provider, array $input):
],
$input
);
$this->post(route('server-providers.connect'), $data)->assertSessionHasErrors();
$this->post(route('settings.server-providers.connect'), $data)->assertSessionHasErrors();
$this->assertDatabaseMissing('server_providers', [
'provider' => $provider,
@ -69,7 +69,7 @@ public function test_see_providers_list(): void
'user_id' => $this->user->id,
]);
$this->get(route('server-providers'))
$this->get(route('settings.server-providers'))
->assertSuccessful()
->assertSee($provider->profile);
}
@ -86,7 +86,7 @@ public function test_delete_provider(string $provider): void
'provider' => $provider,
]);
$this->delete(route('server-providers.delete', $provider))
$this->delete(route('settings.server-providers.delete', $provider))
->assertSessionDoesntHaveErrors();
$this->assertDatabaseMissing('server_providers', [
@ -110,7 +110,7 @@ public function test_cannot_delete_provider(string $provider): void
'provider_id' => $provider->id,
]);
$this->delete(route('server-providers.delete', $provider))
$this->delete(route('settings.server-providers.delete', $provider))
->assertSessionDoesntHaveErrors()
->assertSessionHas('toast.type', 'error')
->assertSessionHas('toast.message', 'This server provider is being used by a server.');

View File

@ -28,7 +28,7 @@ public function test_connect_provider(string $provider, ?string $customUrl, arra
if ($customUrl !== null) {
$input['url'] = $customUrl;
}
$this->post(route('source-controls.connect'), $input)
$this->post(route('settings.source-controls.connect'), $input)
->assertSessionDoesntHaveErrors();
$this->assertDatabaseHas('source_controls', [
@ -50,7 +50,7 @@ public function test_delete_provider(string $provider): void
'profile' => 'test',
]);
$this->delete(route('source-controls.delete', $sourceControl->id))
$this->delete(route('settings.source-controls.delete', $sourceControl->id))
->assertSessionDoesntHaveErrors();
$this->assertDatabaseMissing('source_controls', [
@ -75,7 +75,7 @@ public function test_cannot_delete_provider(string $provider): void
'source_control_id' => $sourceControl->id,
]);
$this->delete(route('source-controls.delete', $sourceControl->id))
$this->delete(route('settings.source-controls.delete', $sourceControl->id))
->assertSessionDoesntHaveErrors()
->assertSessionHas('toast.type', 'error')
->assertSessionHas('toast.message', 'This source control is being used by a site.');

View File

@ -14,7 +14,7 @@ public function test_create_ssh_key(): void
{
$this->actingAs($this->user);
$this->post(route('ssh-keys.add'), [
$this->post(route('settings.ssh-keys.add'), [
'name' => 'test',
'public_key' => 'ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSUGPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XAt3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/EnmZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbxNrRFi9wrf+M7Q== test@test.local',
])->assertSessionDoesntHaveErrors();
@ -28,7 +28,7 @@ public function test_get_public_keys_list(): void
'user_id' => $this->user->id,
]);
$this->get(route('ssh-keys'))
$this->get(route('settings.ssh-keys'))
->assertSuccessful()
->assertSee($key->name);
}
@ -41,7 +41,7 @@ public function test_delete_key(): void
'user_id' => $this->user->id,
]);
$this->delete(route('ssh-keys.delete', $key->id))
$this->delete(route('settings.ssh-keys.delete', $key->id))
->assertSessionDoesntHaveErrors();
$this->assertDatabaseMissing('ssh_keys', [

View File

@ -19,7 +19,7 @@ public function test_connect_dropbox(): void
Http::fake();
$this->post(route('storage-providers.connect'), [
$this->post(route('settings.storage-providers.connect'), [
'provider' => StorageProvider::DROPBOX,
'name' => 'profile',
'token' => 'token',
@ -40,7 +40,7 @@ public function test_see_providers_list(): void
'provider' => StorageProvider::DROPBOX,
]);
$this->get(route('storage-providers'))
$this->get(route('settings.storage-providers'))
->assertSuccessful()
->assertSee($provider->profile);
}
@ -53,7 +53,7 @@ public function test_delete_provider(): void
'user_id' => $this->user->id,
]);
$this->delete(route('storage-providers.delete', $provider->id))
$this->delete(route('settings.storage-providers.delete', $provider->id))
->assertSessionDoesntHaveErrors();
$this->assertDatabaseMissing('storage_providers', [
@ -79,7 +79,7 @@ public function test_cannot_delete_provider(): void
'storage_id' => $provider->id,
]);
$this->delete(route('storage-providers.delete', $provider->id))
$this->delete(route('settings.storage-providers.delete', $provider->id))
->assertSessionDoesntHaveErrors()
->assertSessionHas('toast.type', 'error')
->assertSessionHas('toast.message', 'This storage provider is being used by a backup.');