Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/UsersTest.php
Show First 20 Lines • Show All 566 Lines • ▼ Show 20 Lines | public function testSetConfig(): void | ||||
$this->assertSame('success', $json['status']); | $this->assertSame('success', $json['status']); | ||||
$this->assertSame('User settings updated successfully.', $json['message']); | $this->assertSame('User settings updated successfully.', $json['message']); | ||||
$this->assertSame('true', $john->fresh()->getSetting('greylist_enabled')); | $this->assertSame('true', $john->fresh()->getSetting('greylist_enabled')); | ||||
$this->assertSame('min:10,max:255,upper,lower,digit,special', $john->fresh()->getSetting('password_policy')); | $this->assertSame('min:10,max:255,upper,lower,digit,special', $john->fresh()->getSetting('password_policy')); | ||||
// Test some valid data, acting as another account controller | // Test some valid data, acting as another account controller | ||||
$ned = $this->getTestUser('ned@kolab.org'); | $ned = $this->getTestUser('ned@kolab.org'); | ||||
$post = ['greylist_enabled' => 0, 'password_policy' => 'min:10,max:255,upper']; | $post = ['greylist_enabled' => 0, 'password_policy' => 'min:10,max:255,upper,last:1']; | ||||
$response = $this->actingAs($ned)->post("/api/v4/users/{$john->id}/config", $post); | $response = $this->actingAs($ned)->post("/api/v4/users/{$john->id}/config", $post); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$this->assertCount(2, $json); | $this->assertCount(2, $json); | ||||
$this->assertSame('success', $json['status']); | $this->assertSame('success', $json['status']); | ||||
$this->assertSame('User settings updated successfully.', $json['message']); | $this->assertSame('User settings updated successfully.', $json['message']); | ||||
$this->assertSame('false', $john->fresh()->getSetting('greylist_enabled')); | $this->assertSame('false', $john->fresh()->getSetting('greylist_enabled')); | ||||
$this->assertSame('min:10,max:255,upper', $john->fresh()->getSetting('password_policy')); | $this->assertSame('min:10,max:255,upper,last:1', $john->fresh()->getSetting('password_policy')); | ||||
} | } | ||||
/** | /** | ||||
* Test user creation (POST /api/v4/users) | * Test user creation (POST /api/v4/users) | ||||
*/ | */ | ||||
public function testStore(): void | public function testStore(): void | ||||
{ | { | ||||
Queue::fake(); | Queue::fake(); | ||||
▲ Show 20 Lines • Show All 893 Lines • Show Last 20 Lines |