Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/GroupsTest.php
Show First 20 Lines • Show All 244 Lines • ▼ Show 20 Lines | public function testShow(): void | ||||
$this->assertSame($group->name, $json['name']); | $this->assertSame($group->name, $json['name']); | ||||
$this->assertSame($group->members, $json['members']); | $this->assertSame($group->members, $json['members']); | ||||
$this->assertTrue(!empty($json['statusInfo'])); | $this->assertTrue(!empty($json['statusInfo'])); | ||||
$this->assertArrayHasKey('isDeleted', $json); | $this->assertArrayHasKey('isDeleted', $json); | ||||
$this->assertArrayHasKey('isSuspended', $json); | $this->assertArrayHasKey('isSuspended', $json); | ||||
$this->assertArrayHasKey('isActive', $json); | $this->assertArrayHasKey('isActive', $json); | ||||
$this->assertArrayHasKey('isLdapReady', $json); | $this->assertArrayHasKey('isLdapReady', $json); | ||||
$this->assertSame(['sender_policy' => ['test']], $json['config']); | $this->assertSame(['sender_policy' => ['test']], $json['config']); | ||||
$this->assertCount(1, $json['skus']); | |||||
} | |||||
/** | |||||
* Test fetching SKUs list for a group (GET /groups/<id>/skus) | |||||
*/ | |||||
public function testSkus(): void | |||||
{ | |||||
Queue::fake(); | |||||
$john = $this->getTestUser('john@kolab.org'); | |||||
$jack = $this->getTestUser('jack@kolab.org'); | |||||
$group = $this->getTestGroup('group-test@kolab.org'); | |||||
$group->assignToWallet($john->wallets->first()); | |||||
// Unauth access not allowed | |||||
$response = $this->get("api/v4/groups/{$group->id}/skus"); | |||||
$response->assertStatus(401); | |||||
// Unauthorized access not allowed | |||||
$response = $this->actingAs($jack)->get("api/v4/groups/{$group->id}/skus"); | |||||
$response->assertStatus(403); | |||||
$response = $this->actingAs($john)->get("api/v4/groups/{$group->id}/skus"); | |||||
$response->assertStatus(200); | |||||
$json = $response->json(); | |||||
$this->assertCount(1, $json); | |||||
$this->assertSkuElement('group', $json[0], [ | |||||
'prio' => 0, | |||||
'type' => 'group', | |||||
'handler' => 'Group', | |||||
'enabled' => true, | |||||
'readonly' => true, | |||||
]); | |||||
} | } | ||||
/** | /** | ||||
* Test fetching group status (GET /api/v4/groups/<group-id>/status) | * Test fetching group status (GET /api/v4/groups/<group-id>/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 353 Lines • Show Last 20 Lines |