im profil kann ein nutzer nun seine daten exportieren. man kann seinen account löschen. nach 2 jahren werden inaktive accounts gelöscht, 1 monat vorher wird eine email geschickt. Hilfetexte und Legal Pages in der Guest PWA korrigiert und vom layout her optimiert (dark mode).
This commit is contained in:
51
tests/Feature/ProfileAccountDeletionTest.php
Normal file
51
tests/Feature/ProfileAccountDeletionTest.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Jobs\AnonymizeAccount;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProfileAccountDeletionTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_confirmation_is_required(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
||||
$tenant = Tenant::factory()->create();
|
||||
$user = User::factory()->create(['tenant_id' => $tenant->id]);
|
||||
|
||||
$response = $this->actingAs($user)->delete('/profile/account', [
|
||||
'confirmation' => 'WRONG',
|
||||
]);
|
||||
|
||||
$response->assertSessionHasErrors('confirmation');
|
||||
Queue::assertNothingPushed();
|
||||
}
|
||||
|
||||
public function test_account_deletion_dispatches_job(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
||||
$tenant = Tenant::factory()->create();
|
||||
$user = User::factory()->create(['tenant_id' => $tenant->id]);
|
||||
|
||||
$keyword = Str::upper(__('profile.delete.confirmation_keyword'));
|
||||
|
||||
$response = $this->actingAs($user)->delete('/profile/account', [
|
||||
'confirmation' => $keyword,
|
||||
]);
|
||||
|
||||
$response->assertRedirect('/profile');
|
||||
|
||||
Queue::assertPushed(AnonymizeAccount::class, function (AnonymizeAccount $job) use ($user) {
|
||||
return $job->userId() === $user->id;
|
||||
});
|
||||
}
|
||||
}
|
||||
55
tests/Feature/ProfileDataExportTest.php
Normal file
55
tests/Feature/ProfileDataExportTest.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Jobs\GenerateDataExport;
|
||||
use App\Models\DataExport;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ProfileDataExportTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_user_can_request_data_export(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
||||
$tenant = Tenant::factory()->create();
|
||||
$user = User::factory()->create(['tenant_id' => $tenant->id]);
|
||||
|
||||
$response = $this->actingAs($user)->post('/profile/data-exports');
|
||||
|
||||
$response->assertRedirect();
|
||||
$this->assertDatabaseCount('data_exports', 1);
|
||||
Queue::assertPushed(GenerateDataExport::class);
|
||||
}
|
||||
|
||||
public function test_ready_export_can_be_downloaded(): void
|
||||
{
|
||||
Storage::fake('local');
|
||||
|
||||
$tenant = Tenant::factory()->create();
|
||||
$user = User::factory()->create(['tenant_id' => $tenant->id]);
|
||||
|
||||
Storage::disk('local')->put('exports/demo.zip', 'demo-content');
|
||||
|
||||
$export = DataExport::create([
|
||||
'user_id' => $user->id,
|
||||
'tenant_id' => $tenant->id,
|
||||
'status' => DataExport::STATUS_READY,
|
||||
'path' => 'exports/demo.zip',
|
||||
'size_bytes' => 123,
|
||||
'expires_at' => now()->addDay(),
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($user)->get(route('profile.data-exports.download', $export));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertHeader('content-disposition');
|
||||
}
|
||||
}
|
||||
85
tests/Feature/TenantRetentionCommandTest.php
Normal file
85
tests/Feature/TenantRetentionCommandTest.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Jobs\AnonymizeAccount;
|
||||
use App\Models\Package;
|
||||
use App\Models\Tenant;
|
||||
use App\Models\TenantPackage;
|
||||
use App\Models\User;
|
||||
use App\Notifications\InactiveTenantDeletionWarning;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Tests\TestCase;
|
||||
|
||||
class TenantRetentionCommandTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_inactive_tenant_gets_anonymized(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
||||
$tenant = Tenant::factory()->create([
|
||||
'last_activity_at' => now()->subMonths(25),
|
||||
]);
|
||||
$user = User::factory()->create(['tenant_id' => $tenant->id]);
|
||||
$tenant->user()->associate($user)->save();
|
||||
|
||||
$this->artisan('tenants:retention-scan')->assertExitCode(0);
|
||||
Queue::assertPushed(AnonymizeAccount::class, function (AnonymizeAccount $job) use ($tenant) {
|
||||
return $job->tenantId() === $tenant->id;
|
||||
});
|
||||
}
|
||||
|
||||
public function test_warning_is_sent_one_month_before(): void
|
||||
{
|
||||
Queue::fake();
|
||||
Notification::fake();
|
||||
|
||||
$tenant = Tenant::factory()->create([
|
||||
'last_activity_at' => now()->subMonths(23)->subWeek(),
|
||||
'contact_email' => 'owner@example.com',
|
||||
]);
|
||||
$user = User::factory()->create(['tenant_id' => $tenant->id]);
|
||||
$tenant->user()->associate($user)->save();
|
||||
|
||||
$this->artisan('tenants:retention-scan')->assertExitCode(0);
|
||||
|
||||
Notification::assertSentOnDemand(
|
||||
InactiveTenantDeletionWarning::class,
|
||||
function (InactiveTenantDeletionWarning $notification, array $channels, $notifiable) {
|
||||
return in_array('mail', $channels, true);
|
||||
}
|
||||
);
|
||||
|
||||
$this->assertNotNull($tenant->fresh()->deletion_warning_sent_at);
|
||||
}
|
||||
|
||||
public function test_active_subscription_is_whitelisted(): void
|
||||
{
|
||||
Queue::fake();
|
||||
|
||||
$tenant = Tenant::factory()->create([
|
||||
'last_activity_at' => now()->subMonths(25),
|
||||
]);
|
||||
$user = User::factory()->create(['tenant_id' => $tenant->id]);
|
||||
$tenant->user()->associate($user)->save();
|
||||
|
||||
$package = Package::factory()->create(['type' => 'reseller']);
|
||||
TenantPackage::create([
|
||||
'tenant_id' => $tenant->id,
|
||||
'package_id' => $package->id,
|
||||
'price' => 99,
|
||||
'purchased_at' => now()->subMonth(),
|
||||
'expires_at' => now()->addYear(),
|
||||
'used_events' => 0,
|
||||
'active' => true,
|
||||
]);
|
||||
|
||||
$this->artisan('tenants:retention-scan')->assertExitCode(0);
|
||||
|
||||
Queue::assertNothingPushed();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user