Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Reseller/DomainsTest.php
Show All 21 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 domain confirm request | * Test domain confirm request | ||||
*/ | */ | ||||
public function testConfirm(): void | public function testConfirm(): void | ||||
{ | { | ||||
$reseller1 = $this->getTestUser('reseller@' . \config('app.domain')); | $reseller1 = $this->getTestUser('reseller@' . \config('app.domain')); | ||||
$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, | ||||
]); | ]); | ||||
// THe end-point exists on the users controller, but not reseller's | // THe end-point exists on the users controller, but not reseller's | ||||
$response = $this->actingAs($reseller1)->get("api/v4/domains/{$domain->id}/confirm"); | $response = $this->actingAs($reseller1)->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 | |||||
{ | |||||
$reseller1 = $this->getTestUser('reseller@' . \config('app.domain')); | |||||
$domain = $this->getTestDomain('kolab.org'); | |||||
// This end-point does not exist for resellers | |||||
$response = $this->actingAs($reseller1)->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 | ||||
{ | { | ||||
$user = $this->getTestUser('john@kolab.org'); | $user = $this->getTestUser('john@kolab.org'); | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
$reseller1 = $this->getTestUser('reseller@' . \config('app.domain')); | $reseller1 = $this->getTestUser('reseller@' . \config('app.domain')); | ||||
$reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local'); | $reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local'); | ||||
▲ Show 20 Lines • Show All 148 Lines • ▼ Show 20 Lines | public function testSuspend(): void | ||||
$reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local'); | $reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local'); | ||||
\config(['app.tenant_id' => $reseller2->tenant_id]); | \config(['app.tenant_id' => $reseller2->tenant_id]); | ||||
$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'); | ||||
// Test unauthorized access to the reseller API (user) | // Test unauthorized access to the reseller API (user) | ||||
$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()); | ||||
// Test unauthorized access to the reseller API (admin) | // Test unauthorized access to the reseller API (admin) | ||||
Show All 33 Lines | public function testUnsuspend(): void | ||||
$reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local'); | $reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local'); | ||||
\config(['app.tenant_id' => $reseller2->tenant_id]); | \config(['app.tenant_id' => $reseller2->tenant_id]); | ||||
$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'); | ||||
// Test unauthorized access to reseller API (user) | // Test unauthorized access to reseller API (user) | ||||
$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()); | ||||
// Test unauthorized access to reseller API (admin) | // Test unauthorized access to reseller API (admin) | ||||
Show All 24 Lines |