get('/') ->assertRedirect('/recipients'); } public function test_guests_are_redirected_to_login(): void { $this->get('/recipients') ->assertRedirect('/login'); } public function test_login_page_is_available(): void { $this->get('/login') ->assertOk() ->assertSee('Connexion'); } public function test_authenticated_user_can_access_recipient_selection(): void { $user = User::factory()->create(); $this->actingAs($user) ->get('/recipients') ->assertOk() ->assertSee('Composer') ->assertSee('Pour'); } public function test_user_can_log_in_and_log_out(): void { User::factory()->create([ 'email' => 'admin@relais-sms.test', 'password' => 'relais-sms', ]); $this->post('/login', [ 'email' => 'admin@relais-sms.test', 'password' => 'relais-sms', ])->assertRedirect('/recipients'); $this->assertAuthenticated(); $this->post('/logout') ->assertRedirect('/login'); $this->assertGuest(); } public function test_default_app_settings_are_seeded(): void { config(['relais_sms.default_settings.max_sms_per_campaign' => 100]); $this->seed(); $this->assertDatabaseHas('app_settings', [ 'key' => 'max_sms_per_campaign', 'value' => '100', 'type' => 'integer', ]); } public function test_production_seeding_rejects_default_admin_password(): void { $this->app['env'] = 'production'; $repository = Env::getRepository(); $originalPassword = $repository->get('RELAIS_SMS_ADMIN_PASSWORD'); $repository->set('RELAIS_SMS_ADMIN_PASSWORD', 'relais-sms'); try { $this->expectException(RuntimeException::class); (new DatabaseSeeder)->run(); } finally { $originalPassword === null ? $repository->clear('RELAIS_SMS_ADMIN_PASSWORD') : $repository->set('RELAIS_SMS_ADMIN_PASSWORD', $originalPassword); } } public function test_production_seeding_accepts_a_personal_admin_password(): void { $this->app['env'] = 'production'; $repository = Env::getRepository(); $originalPassword = $repository->get('RELAIS_SMS_ADMIN_PASSWORD'); $repository->set('RELAIS_SMS_ADMIN_PASSWORD', 'test-only-personal-password'); try { (new DatabaseSeeder)->run(); $user = User::query()->sole(); $this->assertTrue(Hash::check('test-only-personal-password', $user->password)); } finally { $originalPassword === null ? $repository->clear('RELAIS_SMS_ADMIN_PASSWORD') : $repository->set('RELAIS_SMS_ADMIN_PASSWORD', $originalPassword); } } }