Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Admin/DomainsTest.php
Show All 20 Lines | public function setUp(): void | ||||
$this->deleteTestDomain('domainscontroller.com'); | $this->deleteTestDomain('domainscontroller.com'); | ||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function tearDown(): void | public function tearDown(): void | ||||
{ | { | ||||
$this->deleteTestUser('test1@domainscontroller.com'); | |||||
$this->deleteTestDomain('domainscontroller.com'); | $this->deleteTestDomain('domainscontroller.com'); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test domains confirming (not implemented) | * Test domains confirming (not implemented) | ||||
*/ | */ | ||||
public function testConfirm(): void | public function testConfirm(): void | ||||
{ | { | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
$domain = $this->getTestDomain('kolab.org'); | $domain = $this->getTestDomain('kolab.org'); | ||||
// This end-point does not exist for admins | // This end-point does not exist for admins | ||||
$response = $this->actingAs($admin)->get("api/v4/domains/{$domain->id}/confirm"); | $response = $this->actingAs($admin)->get("api/v4/domains/{$domain->id}/confirm"); | ||||
$response->assertStatus(404); | $response->assertStatus(404); | ||||
} | } | ||||
/** | /** | ||||
* Test deleting a domain (DELETE /api/v4/domains/<id>) | |||||
*/ | |||||
public function testDestroy(): void | |||||
{ | |||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | |||||
$domain = $this->getTestDomain('kolab.org'); | |||||
// This end-point does not exist for admins | |||||
$response = $this->actingAs($admin)->delete("api/v4/domains/{$domain->id}"); | |||||
$response->assertStatus(404); | |||||
} | |||||
/** | |||||
* Test domains searching (/api/v4/domains) | * Test domains searching (/api/v4/domains) | ||||
*/ | */ | ||||
public function testIndex(): void | public function testIndex(): void | ||||
{ | { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
// Non-admin user | // Non-admin user | ||||
▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | class DomainsTest extends TestCase | ||||
public function testSuspend(): void | public function testSuspend(): void | ||||
{ | { | ||||
Queue::fake(); // disable jobs | Queue::fake(); // disable jobs | ||||
$domain = $this->getTestDomain('domainscontroller.com', [ | $domain = $this->getTestDomain('domainscontroller.com', [ | ||||
'status' => Domain::STATUS_NEW, | 'status' => Domain::STATUS_NEW, | ||||
'type' => Domain::TYPE_EXTERNAL, | 'type' => Domain::TYPE_EXTERNAL, | ||||
]); | ]); | ||||
$user = $this->getTestUser('test@domainscontroller.com'); | $user = $this->getTestUser('test1@domainscontroller.com'); | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
// Test unauthorized access to admin API | // Test unauthorized access to admin API | ||||
$response = $this->actingAs($user)->post("/api/v4/domains/{$domain->id}/suspend", []); | $response = $this->actingAs($user)->post("/api/v4/domains/{$domain->id}/suspend", []); | ||||
$response->assertStatus(403); | $response->assertStatus(403); | ||||
$this->assertFalse($domain->fresh()->isSuspended()); | $this->assertFalse($domain->fresh()->isSuspended()); | ||||
Show All 16 Lines | class DomainsTest extends TestCase | ||||
public function testUnsuspend(): void | public function testUnsuspend(): void | ||||
{ | { | ||||
Queue::fake(); // disable jobs | Queue::fake(); // disable jobs | ||||
$domain = $this->getTestDomain('domainscontroller.com', [ | $domain = $this->getTestDomain('domainscontroller.com', [ | ||||
'status' => Domain::STATUS_NEW | Domain::STATUS_SUSPENDED, | 'status' => Domain::STATUS_NEW | Domain::STATUS_SUSPENDED, | ||||
'type' => Domain::TYPE_EXTERNAL, | 'type' => Domain::TYPE_EXTERNAL, | ||||
]); | ]); | ||||
$user = $this->getTestUser('test@domainscontroller.com'); | $user = $this->getTestUser('test1@domainscontroller.com'); | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
// Test unauthorized access to admin API | // Test unauthorized access to admin API | ||||
$response = $this->actingAs($user)->post("/api/v4/domains/{$domain->id}/unsuspend", []); | $response = $this->actingAs($user)->post("/api/v4/domains/{$domain->id}/unsuspend", []); | ||||
$response->assertStatus(403); | $response->assertStatus(403); | ||||
$this->assertTrue($domain->fresh()->isSuspended()); | $this->assertTrue($domain->fresh()->isSuspended()); | ||||
Show All 13 Lines |