Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/DomainsTest.php
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | public function testConfirm(): void | ||||
$response = $this->actingAs($user)->get("api/v4/domains/{$domain->id}/confirm"); | $response = $this->actingAs($user)->get("api/v4/domains/{$domain->id}/confirm"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertEquals('success', $json['status']); | $this->assertEquals('success', $json['status']); | ||||
$this->assertEquals('Domain verified successfully.', $json['message']); | $this->assertEquals('Domain verified successfully.', $json['message']); | ||||
$this->assertTrue(is_array($json['statusInfo'])); | |||||
// Not authorized access | // Not authorized access | ||||
$response = $this->actingAs($john)->get("api/v4/domains/{$domain->id}/confirm"); | $response = $this->actingAs($john)->get("api/v4/domains/{$domain->id}/confirm"); | ||||
$response->assertStatus(403); | $response->assertStatus(403); | ||||
// Authorized access by additional account controller | // Authorized access by additional account controller | ||||
$domain = $this->getTestDomain('kolab.org'); | $domain = $this->getTestDomain('kolab.org'); | ||||
$response = $this->actingAs($ned)->get("api/v4/domains/{$domain->id}/confirm"); | $response = $this->actingAs($ned)->get("api/v4/domains/{$domain->id}/confirm"); | ||||
Show All 17 Lines | public function testIndex(): void | ||||
// User with custom domain(s) | // User with custom domain(s) | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$ned = $this->getTestUser('ned@kolab.org'); | $ned = $this->getTestUser('ned@kolab.org'); | ||||
$response = $this->actingAs($john)->get("api/v4/domains"); | $response = $this->actingAs($john)->get("api/v4/domains"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(1, $json); | $this->assertCount(1, $json); | ||||
$this->assertSame('kolab.org', $json[0]['namespace']); | $this->assertSame('kolab.org', $json[0]['namespace']); | ||||
// Values below are tested by Unit tests | |||||
$this->assertArrayHasKey('isConfirmed', $json[0]); | |||||
$this->assertArrayHasKey('isDeleted', $json[0]); | |||||
$this->assertArrayHasKey('isVerified', $json[0]); | |||||
$this->assertArrayHasKey('isSuspended', $json[0]); | |||||
$this->assertArrayHasKey('isActive', $json[0]); | |||||
$this->assertArrayHasKey('isLdapReady', $json[0]); | |||||
$response = $this->actingAs($ned)->get("api/v4/domains"); | $response = $this->actingAs($ned)->get("api/v4/domains"); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(1, $json); | $this->assertCount(1, $json); | ||||
$this->assertSame('kolab.org', $json[0]['namespace']); | $this->assertSame('kolab.org', $json[0]['namespace']); | ||||
Show All 22 Lines | public function testShow(): void | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertEquals($domain->id, $json['id']); | $this->assertEquals($domain->id, $json['id']); | ||||
$this->assertEquals($domain->namespace, $json['namespace']); | $this->assertEquals($domain->namespace, $json['namespace']); | ||||
$this->assertEquals($domain->status, $json['status']); | $this->assertEquals($domain->status, $json['status']); | ||||
$this->assertEquals($domain->type, $json['type']); | $this->assertEquals($domain->type, $json['type']); | ||||
$this->assertTrue($json['confirmed'] === false); | |||||
$this->assertSame($domain->hash(Domain::HASH_TEXT), $json['hash_text']); | $this->assertSame($domain->hash(Domain::HASH_TEXT), $json['hash_text']); | ||||
$this->assertSame($domain->hash(Domain::HASH_CNAME), $json['hash_cname']); | $this->assertSame($domain->hash(Domain::HASH_CNAME), $json['hash_cname']); | ||||
$this->assertSame($domain->hash(Domain::HASH_CODE), $json['hash_code']); | $this->assertSame($domain->hash(Domain::HASH_CODE), $json['hash_code']); | ||||
$this->assertCount(4, $json['config']); | $this->assertCount(4, $json['config']); | ||||
$this->assertTrue(strpos(implode("\n", $json['config']), $domain->namespace) !== false); | $this->assertTrue(strpos(implode("\n", $json['config']), $domain->namespace) !== false); | ||||
$this->assertCount(8, $json['dns']); | $this->assertCount(8, $json['dns']); | ||||
$this->assertTrue(strpos(implode("\n", $json['dns']), $domain->namespace) !== false); | $this->assertTrue(strpos(implode("\n", $json['dns']), $domain->namespace) !== false); | ||||
$this->assertTrue(strpos(implode("\n", $json['dns']), $domain->hash()) !== false); | $this->assertTrue(strpos(implode("\n", $json['dns']), $domain->hash()) !== false); | ||||
$this->assertTrue(is_array($json['statusInfo'])); | |||||
// Values below are tested by Unit tests | |||||
$this->assertArrayHasKey('isConfirmed', $json); | |||||
$this->assertArrayHasKey('isDeleted', $json); | |||||
$this->assertArrayHasKey('isVerified', $json); | |||||
$this->assertArrayHasKey('isSuspended', $json); | |||||
$this->assertArrayHasKey('isActive', $json); | |||||
$this->assertArrayHasKey('isLdapReady', $json); | |||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$ned = $this->getTestUser('ned@kolab.org'); | $ned = $this->getTestUser('ned@kolab.org'); | ||||
$jack = $this->getTestUser('jack@kolab.org'); | $jack = $this->getTestUser('jack@kolab.org'); | ||||
// Not authorized - Other account domain | // Not authorized - Other account domain | ||||
$response = $this->actingAs($john)->get("api/v4/domains/{$domain->id}"); | $response = $this->actingAs($john)->get("api/v4/domains/{$domain->id}"); | ||||
$response->assertStatus(403); | $response->assertStatus(403); | ||||
Show All 12 Lines |