Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Feature/Controller/PasswordPolicyTest.php
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | public function testIndex(): void | ||||
// Get available policy rules | // Get available policy rules | ||||
$response = $this->actingAs($john)->get('/api/v4/password-policy'); | $response = $this->actingAs($john)->get('/api/v4/password-policy'); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$this->assertCount(2, $json); | $this->assertCount(2, $json); | ||||
$this->assertSame(6, $json['count']); | $this->assertSame(7, $json['count']); | ||||
$this->assertCount(6, $json['list']); | $this->assertCount(7, $json['list']); | ||||
$this->assertSame('Minimum password length: 8 characters', $json['list'][0]['name']); | $this->assertSame('Minimum password length: 8 characters', $json['list'][0]['name']); | ||||
$this->assertSame('min', $json['list'][0]['label']); | $this->assertSame('min', $json['list'][0]['label']); | ||||
$this->assertSame('8', $json['list'][0]['param']); | $this->assertSame('8', $json['list'][0]['param']); | ||||
$this->assertSame(true, $json['list'][0]['enabled']); | $this->assertSame(true, $json['list'][0]['enabled']); | ||||
$this->assertSame('Maximum password length: 255 characters', $json['list'][1]['name']); | $this->assertSame('Maximum password length: 255 characters', $json['list'][1]['name']); | ||||
$this->assertSame('max', $json['list'][1]['label']); | $this->assertSame('max', $json['list'][1]['label']); | ||||
$this->assertSame('255', $json['list'][1]['param']); | $this->assertSame('255', $json['list'][1]['param']); | ||||
$this->assertSame(true, $json['list'][1]['enabled']); | $this->assertSame(true, $json['list'][1]['enabled']); | ||||
$this->assertSame('lower', $json['list'][2]['label']); | $this->assertSame('lower', $json['list'][2]['label']); | ||||
$this->assertSame(false, $json['list'][2]['enabled']); | $this->assertSame(false, $json['list'][2]['enabled']); | ||||
$this->assertSame('upper', $json['list'][3]['label']); | $this->assertSame('upper', $json['list'][3]['label']); | ||||
$this->assertSame(false, $json['list'][3]['enabled']); | $this->assertSame(false, $json['list'][3]['enabled']); | ||||
$this->assertSame('digit', $json['list'][4]['label']); | $this->assertSame('digit', $json['list'][4]['label']); | ||||
$this->assertSame(false, $json['list'][4]['enabled']); | $this->assertSame(false, $json['list'][4]['enabled']); | ||||
$this->assertSame('special', $json['list'][5]['label']); | $this->assertSame('special', $json['list'][5]['label']); | ||||
$this->assertSame(true, $json['list'][5]['enabled']); | $this->assertSame(true, $json['list'][5]['enabled']); | ||||
$this->assertSame('last', $json['list'][6]['label']); | |||||
$this->assertSame(false, $json['list'][6]['enabled']); | |||||
// Test acting as Jack | // Test acting as Jack | ||||
$response = $this->actingAs($jack)->get('/api/v4/password-policy'); | $response = $this->actingAs($jack)->get('/api/v4/password-policy'); | ||||
$json = $response->json(); | $json = $response->json(); | ||||
$response->assertStatus(200); | $response->assertStatus(200); | ||||
$this->assertCount(2, $json); | $this->assertCount(2, $json); | ||||
$this->assertSame(6, $json['count']); | $this->assertSame(7, $json['count']); | ||||
$this->assertCount(6, $json['list']); | $this->assertCount(7, $json['list']); | ||||
$this->assertSame('Minimum password length: 8 characters', $json['list'][0]['name']); | $this->assertSame('Minimum password length: 8 characters', $json['list'][0]['name']); | ||||
$this->assertSame('min', $json['list'][0]['label']); | $this->assertSame('min', $json['list'][0]['label']); | ||||
$this->assertSame('8', $json['list'][0]['param']); | $this->assertSame('8', $json['list'][0]['param']); | ||||
$this->assertSame(true, $json['list'][0]['enabled']); | $this->assertSame(true, $json['list'][0]['enabled']); | ||||
$this->assertSame('Maximum password length: 255 characters', $json['list'][1]['name']); | $this->assertSame('Maximum password length: 255 characters', $json['list'][1]['name']); | ||||
$this->assertSame('max', $json['list'][1]['label']); | $this->assertSame('max', $json['list'][1]['label']); | ||||
$this->assertSame('255', $json['list'][1]['param']); | $this->assertSame('255', $json['list'][1]['param']); | ||||
$this->assertSame(true, $json['list'][1]['enabled']); | $this->assertSame(true, $json['list'][1]['enabled']); | ||||
$this->assertSame('lower', $json['list'][2]['label']); | $this->assertSame('lower', $json['list'][2]['label']); | ||||
$this->assertSame(false, $json['list'][2]['enabled']); | $this->assertSame(false, $json['list'][2]['enabled']); | ||||
$this->assertSame('upper', $json['list'][3]['label']); | $this->assertSame('upper', $json['list'][3]['label']); | ||||
$this->assertSame(false, $json['list'][3]['enabled']); | $this->assertSame(false, $json['list'][3]['enabled']); | ||||
$this->assertSame('digit', $json['list'][4]['label']); | $this->assertSame('digit', $json['list'][4]['label']); | ||||
$this->assertSame(false, $json['list'][4]['enabled']); | $this->assertSame(false, $json['list'][4]['enabled']); | ||||
$this->assertSame('special', $json['list'][5]['label']); | $this->assertSame('special', $json['list'][5]['label']); | ||||
$this->assertSame(true, $json['list'][5]['enabled']); | $this->assertSame(true, $json['list'][5]['enabled']); | ||||
$this->assertSame('last', $json['list'][6]['label']); | |||||
$this->assertSame(false, $json['list'][6]['enabled']); | |||||
} | } | ||||
} | } |