Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Reseller/DomainsTest.php
Show All 33 Lines | public function tearDown(): void | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test domain confirm request | * Test domain confirm request | ||||
*/ | */ | ||||
public function testConfirm(): void | public function testConfirm(): void | ||||
{ | { | ||||
$reseller1 = $this->getTestUser('reseller@kolabnow.com'); | $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 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@kolabnow.com'); | $reseller1 = $this->getTestUser('reseller@' . \config('app.domain')); | ||||
$reseller2 = $this->getTestUser('reseller@reseller.com'); | $reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local'); | ||||
// Non-admin user | // Non-admin user | ||||
$response = $this->actingAs($user)->get("api/v4/domains"); | $response = $this->actingAs($user)->get("api/v4/domains"); | ||||
$response->assertStatus(403); | $response->assertStatus(403); | ||||
// Admin user | // Admin user | ||||
$response = $this->actingAs($admin)->get("api/v4/domains"); | $response = $this->actingAs($admin)->get("api/v4/domains"); | ||||
$response->assertStatus(403); | $response->assertStatus(403); | ||||
// Reseller from a different tenant | // Reseller from a different tenant | ||||
$response = $this->actingAs($reseller2)->get("api/v4/domains"); | $response = $this->actingAs($reseller2)->get("api/v4/domains"); | ||||
$response->assertStatus(403); | $response->assertStatus(404); | ||||
// Search with no matches expected | // Search with no matches expected | ||||
$response = $this->actingAs($reseller1)->get("api/v4/domains?search=abcd12.org"); | $response = $this->actingAs($reseller1)->get("api/v4/domains?search=abcd12.org"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertSame(0, $json['count']); | $this->assertSame(0, $json['count']); | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | class DomainsTest extends TestCase | ||||
/** | /** | ||||
* Test fetching domain info | * Test fetching domain info | ||||
*/ | */ | ||||
public function testShow(): void | public function testShow(): void | ||||
{ | { | ||||
$sku_domain = Sku::where('title', 'domain-hosting')->first(); | $sku_domain = Sku::where('title', 'domain-hosting')->first(); | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
$user = $this->getTestUser('test1@domainscontroller.com'); | $user = $this->getTestUser('test1@domainscontroller.com'); | ||||
$reseller1 = $this->getTestUser('reseller@kolabnow.com'); | $reseller1 = $this->getTestUser('reseller@' . \config('app.domain')); | ||||
$reseller2 = $this->getTestUser('reseller@reseller.com'); | $reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local'); | ||||
$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, | ||||
]); | ]); | ||||
Entitlement::create([ | Entitlement::create([ | ||||
'wallet_id' => $user->wallets()->first()->id, | 'wallet_id' => $user->wallets()->first()->id, | ||||
'sku_id' => $sku_domain->id, | 'sku_id' => $sku_domain->id, | ||||
Show All 30 Lines | public function testShow(): void | ||||
$response->assertStatus(404); | $response->assertStatus(404); | ||||
} | } | ||||
/** | /** | ||||
* Test fetching domain status (GET /api/v4/domains/<domain-id>/status) | * Test fetching domain status (GET /api/v4/domains/<domain-id>/status) | ||||
*/ | */ | ||||
public function testStatus(): void | public function testStatus(): void | ||||
{ | { | ||||
$reseller1 = $this->getTestUser('reseller@kolabnow.com'); | $reseller1 = $this->getTestUser('reseller@' . \config('app.domain')); | ||||
$domain = $this->getTestDomain('kolab.org'); | $domain = $this->getTestDomain('kolab.org'); | ||||
// This end-point does not exist for resellers | // This end-point does not exist for resellers | ||||
$response = $this->actingAs($reseller1)->get("/api/v4/domains/{$domain->id}/status"); | $response = $this->actingAs($reseller1)->get("/api/v4/domains/{$domain->id}/status"); | ||||
$response->assertStatus(404); | $response->assertStatus(404); | ||||
} | } | ||||
/** | /** | ||||
* Test domain suspending (POST /api/v4/domains/<domain-id>/suspend) | * Test domain suspending (POST /api/v4/domains/<domain-id>/suspend) | ||||
*/ | */ | ||||
public function testSuspend(): void | public function testSuspend(): void | ||||
{ | { | ||||
Queue::fake(); // disable jobs | Queue::fake(); // disable jobs | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
$reseller1 = $this->getTestUser('reseller@kolabnow.com'); | $reseller1 = $this->getTestUser('reseller@' . \config('app.domain')); | ||||
$reseller2 = $this->getTestUser('reseller@reseller.com'); | $reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local'); | ||||
\config(['app.tenant_id' => 2]); | \config(['app.tenant_id' => 2]); | ||||
$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('test@domainscontroller.com'); | ||||
Show All 37 Lines | class DomainsTest extends TestCase | ||||
/** | /** | ||||
* Test user un-suspending (POST /api/v4/users/<user-id>/unsuspend) | * Test user un-suspending (POST /api/v4/users/<user-id>/unsuspend) | ||||
*/ | */ | ||||
public function testUnsuspend(): void | public function testUnsuspend(): void | ||||
{ | { | ||||
Queue::fake(); // disable jobs | Queue::fake(); // disable jobs | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
$reseller1 = $this->getTestUser('reseller@kolabnow.com'); | $reseller1 = $this->getTestUser('reseller@' . \config('app.domain')); | ||||
$reseller2 = $this->getTestUser('reseller@reseller.com'); | $reseller2 = $this->getTestUser('reseller@sample-tenant.dev-local'); | ||||
\config(['app.tenant_id' => 2]); | \config(['app.tenant_id' => 2]); | ||||
$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('test@domainscontroller.com'); | ||||
Show All 37 Lines |