'shared-db.test', 'port' => 8444, 'database' => 'shared_system', 'username' => 'shared_writer', ], 'correct-password'); $settings = (new TeamSystemDatabaseProfile($encoded))->settings('correct-password'); $this->assertSame('shared-db.test', $settings['host']); $this->assertSame(8444, $settings['port']); $this->assertSame('shared_system', $settings['database']); $this->assertSame('shared_writer', $settings['username']); $this->assertSame('correct-password', $settings['password']); $this->assertTrue($settings['tls_required']); $this->assertFalse($settings['tls_verify_server_cert']); $this->assertSame('', $settings['tls_ca']); } public function test_wrong_password_does_not_reveal_connection_details(): void { $encoded = TeamSystemDatabaseProfile::seal([ 'host' => 'shared-db.test', 'port' => 3306, 'database' => 'shared_system', 'username' => 'shared_writer', ], 'correct-password'); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('系统数据库密码不正确,请重新输入。'); (new TeamSystemDatabaseProfile($encoded))->settings('wrong-password'); } public function test_missing_cached_config_uses_embedded_profile(): void { config(['system_database.team_profile' => null]); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('系统数据库密码不正确,请重新输入。'); (new TeamSystemDatabaseProfile())->settings('wrong-password'); } public function test_empty_cached_config_uses_embedded_profile(): void { config(['system_database.team_profile' => '']); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('系统数据库密码不正确,请重新输入。'); (new TeamSystemDatabaseProfile())->settings('wrong-password'); } }