Page MenuHomePhorge

D5433.1775264704.diff
No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None

D5433.1775264704.diff

diff --git a/src/app/Console/Commands/User/ForceDeleteCommand.php b/src/app/Console/Commands/User/ForceDeleteCommand.php
--- a/src/app/Console/Commands/User/ForceDeleteCommand.php
+++ b/src/app/Console/Commands/User/ForceDeleteCommand.php
@@ -3,6 +3,8 @@
namespace App\Console\Commands\User;
use App\Console\Command;
+use App\Support\Facades\IMAP;
+use App\Support\Facades\Roundcube;
use Illuminate\Support\Facades\DB;
class ForceDeleteCommand extends Command
@@ -43,5 +45,20 @@
DB::beginTransaction();
$user->forceDelete();
DB::commit();
+
+ // Make sure the mailbox got deleted
+ if (IMAP::verifyAccount($user->email)) {
+ $this->output->write('The mailbox still exists. Deleting... ');
+ if (IMAP::deleteUser($user)) {
+ $this->info('DONE');
+ } else {
+ $this->warn('FAILED');
+ }
+ }
+
+ // Make sure Roundcube user record is deleted
+ if (\config('database.connections.roundcube')) {
+ Roundcube::deleteUser($user->email);
+ }
}
}
diff --git a/src/tests/Feature/Console/User/ForceDeleteTest.php b/src/tests/Feature/Console/User/ForceDeleteTest.php
--- a/src/tests/Feature/Console/User/ForceDeleteTest.php
+++ b/src/tests/Feature/Console/User/ForceDeleteTest.php
@@ -5,7 +5,8 @@
use App\Domain;
use App\Entitlement;
use App\Package;
-use App\Transaction;
+use App\Support\Facades\IMAP;
+use App\Support\Facades\Roundcube;
use App\User;
use App\Wallet;
use Illuminate\Support\Facades\Queue;
@@ -63,37 +64,28 @@
$this->assertTrue($domain->fresh()->trashed());
// Deleted user
- $this->artisan('user:force-delete user@force-delete.com')
+ IMAP::shouldReceive('verifyAccount')->once()->with($user->email)->andReturn(false);
+ Roundcube::shouldReceive('deleteUser')->once()->with($user->email);
+
+ $this->artisan("user:force-delete {$user->email}")
->assertExitCode(0);
- $this->assertCount(
- 0,
- User::withTrashed()->where('email', 'user@force-delete.com')->get()
- );
- $this->assertCount(
- 0,
- Domain::withTrashed()->where('namespace', 'force-delete.com')->get()
- );
- $this->assertCount(
- 0,
- Wallet::where('id', $wallet->id)->get()
- );
- $this->assertCount(
- 0,
- Entitlement::withTrashed()->where('wallet_id', $wallet->id)->get()
- );
- $this->assertCount(
- 0,
- Entitlement::withTrashed()->where('entitleable_id', $user->id)->get()
- );
-
- $this->assertCount(
- 0,
- Transaction::whereIn('object_id', $entitlements)
- ->where('object_type', Entitlement::class)
- ->get()
- );
-
- // TODO: Test that it also deletes users in a group account
+ $this->assertCount(0, User::withTrashed()->where('email', 'user@force-delete.com')->get());
+ $this->assertCount(0, Domain::withTrashed()->where('namespace', 'force-delete.com')->get());
+ $this->assertCount(0, Wallet::where('id', $wallet->id)->get());
+ $this->assertCount(0, Entitlement::withTrashed()->where('wallet_id', $wallet->id)->get());
+ $this->assertCount(0, Entitlement::withTrashed()->where('entitleable_id', $user->id)->get());
+
+ // Deleted user with an existing mailbox
+ $user = $this->getTestUser('user@force-delete.com');
+ $user->delete();
+
+ IMAP::shouldReceive('verifyAccount')->once()->with($user->email)->andReturn(true);
+ IMAP::shouldReceive('deleteUser')->once()->andReturn(true);
+ Roundcube::shouldReceive('deleteUser')->once()->with($user->email);
+
+ $this->artisan("user:force-delete {$user->email}")
+ ->assertExitCode(0)
+ ->expectsOutput('DONE');
}
}

File Metadata

Mime Type
text/plain
Expires
Sat, Apr 4, 1:05 AM (10 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18827227
Default Alt Text
D5433.1775264704.diff (3 KB)

Event Timeline