Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/UsersTest.php
Show First 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | class UsersTest extends TestCase | ||||
* Test fetching user status (GET /api/v4/users/<user-id>/status) | * Test fetching user status (GET /api/v4/users/<user-id>/status) | ||||
* and forcing setup process update (?refresh=1) | * and forcing setup process update (?refresh=1) | ||||
* | * | ||||
* @group imap | * @group imap | ||||
* @group dns | * @group dns | ||||
*/ | */ | ||||
public function testStatus(): void | public function testStatus(): void | ||||
{ | { | ||||
Queue::fake(); | |||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$jack = $this->getTestUser('jack@kolab.org'); | $jack = $this->getTestUser('jack@kolab.org'); | ||||
// Test unauthorized access | // Test unauthorized access | ||||
$response = $this->actingAs($jack)->get("/api/v4/users/{$john->id}/status"); | $response = $this->actingAs($jack)->get("/api/v4/users/{$john->id}/status"); | ||||
$response->assertStatus(403); | $response->assertStatus(403); | ||||
if ($john->isImapReady()) { | if ($john->isImapReady()) { | ||||
Show All 28 Lines | public function testStatus(): void | ||||
$this->assertTrue($json['isImapReady']); | $this->assertTrue($json['isImapReady']); | ||||
$this->assertTrue($json['isReady']); | $this->assertTrue($json['isReady']); | ||||
$this->assertCount(7, $json['process']); | $this->assertCount(7, $json['process']); | ||||
$this->assertSame('user-imap-ready', $json['process'][2]['label']); | $this->assertSame('user-imap-ready', $json['process'][2]['label']); | ||||
$this->assertSame(true, $json['process'][2]['state']); | $this->assertSame(true, $json['process'][2]['state']); | ||||
$this->assertSame('success', $json['status']); | $this->assertSame('success', $json['status']); | ||||
$this->assertSame('Setup process finished successfully.', $json['message']); | $this->assertSame('Setup process finished successfully.', $json['message']); | ||||
Queue::size(1); | |||||
// Test case for when the verify job is dispatched to the worker | |||||
$john->refresh(); | |||||
$john->status ^= User::STATUS_IMAP_READY; | |||||
$john->save(); | |||||
\config(['imap.admin_password' => null]); | |||||
$response = $this->actingAs($john)->get("/api/v4/users/{$john->id}/status?refresh=1"); | |||||
$response->assertStatus(200); | |||||
$json = $response->json(); | |||||
$this->assertFalse($json['isImapReady']); | |||||
$this->assertFalse($json['isReady']); | |||||
$this->assertSame('success', $json['status']); | |||||
$this->assertSame('waiting', $json['processState']); | |||||
$this->assertSame('Setup process has been pushed. Please wait.', $json['message']); | |||||
Queue::assertPushed(\App\Jobs\User\VerifyJob::class, 1); | |||||
} | } | ||||
/** | /** | ||||
* Test UsersController::statusInfo() | * Test UsersController::statusInfo() | ||||
*/ | */ | ||||
public function testStatusInfo(): void | public function testStatusInfo(): void | ||||
{ | { | ||||
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com'); | $user = $this->getTestUser('UsersControllerTest1@userscontroller.com'); | ||||
▲ Show 20 Lines • Show All 756 Lines • Show Last 20 Lines |