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 229 Lines • Show Last 20 Lines |