Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/Admin/UsersTest.php
- This file was copied to src/tests/Feature/Controller/Reseller/UsersTest.php.
Show All 36 Lines | public function tearDown(): void | ||||
$jack = $this->getTestUser('jack@kolab.org'); | $jack = $this->getTestUser('jack@kolab.org'); | ||||
$jack->setSetting('external_email', null); | $jack->setSetting('external_email', null); | ||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test user deleting (DELETE /api/v4/users/<id>) | |||||
*/ | |||||
public function testDestroy(): void | |||||
{ | |||||
$john = $this->getTestUser('john@kolab.org'); | |||||
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com'); | |||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | |||||
// Test unauth access | |||||
$response = $this->delete("api/v4/users/{$user->id}"); | |||||
$response->assertStatus(401); | |||||
// The end-point does not exist | |||||
$response = $this->actingAs($admin)->delete("api/v4/users/{$user->id}"); | |||||
$response->assertStatus(404); | |||||
} | |||||
/** | |||||
* Test users searching (/api/v4/users) | * Test users searching (/api/v4/users) | ||||
*/ | */ | ||||
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'); | ||||
$group = $this->getTestGroup('group-test@kolab.org'); | $group = $this->getTestGroup('group-test@kolab.org'); | ||||
$group->assignToWallet($user->wallets->first()); | $group->assignToWallet($user->wallets->first()); | ||||
▲ Show 20 Lines • Show All 190 Lines • ▼ Show 20 Lines | public function testReset2FA(): void | ||||
$entitlements = $user->fresh()->entitlements()->where('sku_id', $sku2fa->id)->get(); | $entitlements = $user->fresh()->entitlements()->where('sku_id', $sku2fa->id)->get(); | ||||
$this->assertCount(0, $entitlements); | $this->assertCount(0, $entitlements); | ||||
$sf = new SecondFactor($user); | $sf = new SecondFactor($user); | ||||
$this->assertCount(0, $sf->factors()); | $this->assertCount(0, $sf->factors()); | ||||
} | } | ||||
/** | /** | ||||
* Test user creation (POST /api/v4/users) | |||||
*/ | |||||
public function testStore(): void | |||||
{ | |||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | |||||
// The end-point does not exist | |||||
$response = $this->actingAs($admin)->post("/api/v4/users", []); | |||||
$response->assertStatus(404); | |||||
} | |||||
/** | |||||
* Test user suspending (POST /api/v4/users/<user-id>/suspend) | * Test user suspending (POST /api/v4/users/<user-id>/suspend) | ||||
*/ | */ | ||||
public function testSuspend(): void | public function testSuspend(): void | ||||
{ | { | ||||
Queue::fake(); // disable jobs | Queue::fake(); // disable jobs | ||||
$user = $this->getTestUser('UsersControllerTest1@userscontroller.com'); | $user = $this->getTestUser('UsersControllerTest1@userscontroller.com'); | ||||
$admin = $this->getTestUser('jeroen@jeroen.jeroen'); | $admin = $this->getTestUser('jeroen@jeroen.jeroen'); | ||||
▲ Show 20 Lines • Show All 97 Lines • Show Last 20 Lines |