Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/ResourcesTest.php
Show First 20 Lines • Show All 242 Lines • ▼ Show 20 Lines | public function testShow(): void | ||||
$this->assertSame($resource->email, $json['email']); | $this->assertSame($resource->email, $json['email']); | ||||
$this->assertSame($resource->name, $json['name']); | $this->assertSame($resource->name, $json['name']); | ||||
$this->assertTrue(!empty($json['statusInfo'])); | $this->assertTrue(!empty($json['statusInfo'])); | ||||
$this->assertArrayHasKey('isDeleted', $json); | $this->assertArrayHasKey('isDeleted', $json); | ||||
$this->assertArrayHasKey('isActive', $json); | $this->assertArrayHasKey('isActive', $json); | ||||
$this->assertArrayHasKey('isLdapReady', $json); | $this->assertArrayHasKey('isLdapReady', $json); | ||||
$this->assertArrayHasKey('isImapReady', $json); | $this->assertArrayHasKey('isImapReady', $json); | ||||
$this->assertSame(['invitation_policy' => 'reject'], $json['config']); | $this->assertSame(['invitation_policy' => 'reject'], $json['config']); | ||||
$this->assertCount(1, $json['skus']); | |||||
} | |||||
/** | |||||
* Test fetching SKUs list for a resource (GET /resources/<id>/skus) | |||||
*/ | |||||
public function testSkus(): void | |||||
{ | |||||
Queue::fake(); | |||||
$john = $this->getTestUser('john@kolab.org'); | |||||
$jack = $this->getTestUser('jack@kolab.org'); | |||||
$resource = $this->getTestResource('resource-test@kolab.org'); | |||||
$resource->assignToWallet($john->wallets->first()); | |||||
// Unauth access not allowed | |||||
$response = $this->get("api/v4/resources/{$resource->id}/skus"); | |||||
$response->assertStatus(401); | |||||
// Unauthorized access not allowed | |||||
$response = $this->actingAs($jack)->get("api/v4/resources/{$resource->id}/skus"); | |||||
$response->assertStatus(403); | |||||
$response = $this->actingAs($john)->get("api/v4/resources/{$resource->id}/skus"); | |||||
$response->assertStatus(200); | |||||
$json = $response->json(); | |||||
$this->assertCount(1, $json); | |||||
$this->assertSkuElement('resource', $json[0], [ | |||||
'prio' => 0, | |||||
'type' => 'resource', | |||||
'handler' => 'Resource', | |||||
'enabled' => true, | |||||
'readonly' => true, | |||||
]); | |||||
} | } | ||||
/** | /** | ||||
* Test fetching a resource status (GET /api/v4/resources/<resource>/status) | * Test fetching a resource status (GET /api/v4/resources/<resource>/status) | ||||
* and forcing setup process update (?refresh=1) | * and forcing setup process update (?refresh=1) | ||||
*/ | */ | ||||
public function testStatus(): void | public function testStatus(): void | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |