diff --git a/src/Console/Commands/LockoutDisable.php b/src/Console/Commands/LockoutDisable.php index afeb2a7..9c1eb8f 100644 --- a/src/Console/Commands/LockoutDisable.php +++ b/src/Console/Commands/LockoutDisable.php @@ -62,4 +62,3 @@ public function handle(): int return Command::SUCCESS; } } - diff --git a/src/Console/Commands/LockoutEnable.php b/src/Console/Commands/LockoutEnable.php index f2d3372..e677c7e 100644 --- a/src/Console/Commands/LockoutEnable.php +++ b/src/Console/Commands/LockoutEnable.php @@ -62,4 +62,3 @@ public function handle(): int return Command::SUCCESS; } } - diff --git a/src/Console/Commands/LockoutStatus.php b/src/Console/Commands/LockoutStatus.php index 617ffcc..5db3881 100644 --- a/src/Console/Commands/LockoutStatus.php +++ b/src/Console/Commands/LockoutStatus.php @@ -47,4 +47,3 @@ public function handle(): int return Command::SUCCESS; } } - diff --git a/src/Events/LockoutDisabled.php b/src/Events/LockoutDisabled.php index 3fd9d2c..32cb68a 100644 --- a/src/Events/LockoutDisabled.php +++ b/src/Events/LockoutDisabled.php @@ -17,4 +17,3 @@ public function __construct() // } } - diff --git a/src/Events/LockoutEnabled.php b/src/Events/LockoutEnabled.php index a8c420b..b690202 100644 --- a/src/Events/LockoutEnabled.php +++ b/src/Events/LockoutEnabled.php @@ -17,4 +17,3 @@ public function __construct() // } } - diff --git a/src/Events/RequestBlocked.php b/src/Events/RequestBlocked.php index 64dc398..050cccb 100644 --- a/src/Events/RequestBlocked.php +++ b/src/Events/RequestBlocked.php @@ -3,8 +3,8 @@ namespace Rappasoft\Lockout\Events; use Illuminate\Foundation\Events\Dispatchable; -use Illuminate\Queue\SerializesModels; use Illuminate\Http\Request; +use Illuminate\Queue\SerializesModels; class RequestBlocked { @@ -20,4 +20,3 @@ public function __construct( // } } - diff --git a/src/Helpers/IpHelper.php b/src/Helpers/IpHelper.php index b189d57..9676bfc 100644 --- a/src/Helpers/IpHelper.php +++ b/src/Helpers/IpHelper.php @@ -89,4 +89,3 @@ public static function parseIpList(?string $ipList): array return array_map('trim', explode(',', $ipList)); } } - diff --git a/tests/AdvancedFeaturesTest.php b/tests/AdvancedFeaturesTest.php index 90b15ea..aeb1a69 100644 --- a/tests/AdvancedFeaturesTest.php +++ b/tests/AdvancedFeaturesTest.php @@ -3,11 +3,9 @@ namespace Rappasoft\Lockout\Tests; use Illuminate\Http\Response; -use Rappasoft\Lockout\Events\LockoutDisabled; -use Rappasoft\Lockout\Events\LockoutEnabled; -use Rappasoft\Lockout\Events\RequestBlocked; -use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Event; +use Rappasoft\Lockout\Events\RequestBlocked; class AdvancedFeaturesTest extends TestCase { @@ -118,7 +116,7 @@ public function api_requests_return_json_response() $response = $this->withHeaders(['Accept' => 'application/json']) ->call('POST', 'api/test'); - + $response->assertStatus(Response::HTTP_UNAUTHORIZED); // Check if response is JSON (might be HTML if API detection fails) if ($response->headers->get('Content-Type') === 'application/json') { @@ -136,7 +134,7 @@ public function view_response_type_returns_view() // View might not exist in test environment, so test with json instead config(['lockout.response_type' => 'json']); - + $response = $this->call('POST', 'post'); $response->assertStatus(Response::HTTP_UNAUTHORIZED); $response->assertJson(['message' => 'Application is currently in read-only mode.']); @@ -212,4 +210,3 @@ public function events_are_not_fired_when_disabled() Event::assertNotDispatched(RequestBlocked::class); } } - diff --git a/tests/EdgeCasesTest.php b/tests/EdgeCasesTest.php index ea6c5e3..5913cce 100644 --- a/tests/EdgeCasesTest.php +++ b/tests/EdgeCasesTest.php @@ -151,7 +151,7 @@ public function custom_health_check_path_configuration_works() // Verify custom path config is set and health check is enabled $this->assertEquals('custom-health', config('lockout.health_check_path')); $this->assertTrue(config('lockout.health_check_enabled')); - + // The actual route registration happens at service provider boot // In real applications, changing the path would require clearing route cache // This test verifies the configuration is properly stored and retrieved @@ -275,4 +275,3 @@ public function cache_ttl_customization_works() ->assertStatus(Response::HTTP_UNAUTHORIZED); } } - diff --git a/tests/IpHelperTest.php b/tests/IpHelperTest.php index 195c802..d769027 100644 --- a/tests/IpHelperTest.php +++ b/tests/IpHelperTest.php @@ -33,7 +33,7 @@ public function cidr_with_different_masks_works() public function multiple_ips_in_whitelist_work() { $whitelist = ['127.0.0.1', '192.168.1.0/24', '10.0.0.1']; - + $this->assertTrue(IpHelper::isIpAllowed('127.0.0.1', $whitelist)); $this->assertTrue(IpHelper::isIpAllowed('192.168.1.50', $whitelist)); $this->assertTrue(IpHelper::isIpAllowed('10.0.0.1', $whitelist)); @@ -70,7 +70,7 @@ public function empty_blacklist_returns_false() public function parse_ip_list_from_string() { $result = IpHelper::parseIpList('127.0.0.1,192.168.1.1,10.0.0.0/8'); - + $this->assertEquals(['127.0.0.1', '192.168.1.1', '10.0.0.0/8'], $result); } @@ -78,7 +78,7 @@ public function parse_ip_list_from_string() public function parse_ip_list_handles_spaces() { $result = IpHelper::parseIpList('127.0.0.1, 192.168.1.1 , 10.0.0.0/8'); - + $this->assertEquals(['127.0.0.1', '192.168.1.1', '10.0.0.0/8'], $result); } @@ -107,10 +107,9 @@ public function cidr_edge_cases() // /32 should match only exact IP $this->assertTrue(IpHelper::isIpAllowed('192.168.1.1', ['192.168.1.1/32'])); $this->assertFalse(IpHelper::isIpAllowed('192.168.1.2', ['192.168.1.1/32'])); - + // /0 should match everything (entire IPv4 range) $this->assertTrue(IpHelper::isIpAllowed('0.0.0.0', ['0.0.0.0/0'])); $this->assertTrue(IpHelper::isIpAllowed('255.255.255.255', ['0.0.0.0/0'])); } } - diff --git a/tests/RoleBasedTest.php b/tests/RoleBasedTest.php index c49ca87..b417dab 100644 --- a/tests/RoleBasedTest.php +++ b/tests/RoleBasedTest.php @@ -2,8 +2,8 @@ namespace Rappasoft\Lockout\Tests; -use Illuminate\Http\Response; use Illuminate\Foundation\Auth\User as Authenticatable; +use Illuminate\Http\Response; class RoleBasedTest extends TestCase { @@ -14,7 +14,8 @@ public function user_with_role_attribute_bypasses_lockout() config(['lockout.locked_types' => ['post']]); config(['lockout.allowed_roles' => ['admin']]); - $user = new class extends Authenticatable { + $user = new class extends Authenticatable + { public $role = 'admin'; }; @@ -30,7 +31,8 @@ public function user_without_allowed_role_is_blocked() config(['lockout.locked_types' => ['post']]); config(['lockout.allowed_roles' => ['admin']]); - $user = new class extends Authenticatable { + $user = new class extends Authenticatable + { public $role = 'user'; }; @@ -46,7 +48,8 @@ public function user_with_hasRole_method_bypasses_lockout() config(['lockout.locked_types' => ['post']]); config(['lockout.allowed_roles' => ['admin']]); - $user = new class extends Authenticatable { + $user = new class extends Authenticatable + { public function hasRole($role) { return $role === 'admin'; @@ -76,15 +79,18 @@ public function multiple_allowed_roles_work() config(['lockout.locked_types' => ['post']]); config(['lockout.allowed_roles' => ['admin', 'super-admin', 'maintenance']]); - $admin = new class extends Authenticatable { + $admin = new class extends Authenticatable + { public $role = 'admin'; }; - $superAdmin = new class extends Authenticatable { + $superAdmin = new class extends Authenticatable + { public $role = 'super-admin'; }; - $maintenance = new class extends Authenticatable { + $maintenance = new class extends Authenticatable + { public $role = 'maintenance'; }; @@ -108,7 +114,8 @@ public function empty_allowed_roles_blocks_everyone() config(['lockout.locked_types' => ['post']]); config(['lockout.allowed_roles' => []]); - $user = new class extends Authenticatable { + $user = new class extends Authenticatable + { public $role = 'admin'; }; @@ -116,6 +123,4 @@ public function empty_allowed_roles_blocks_everyone() ->call('POST', 'post') ->assertStatus(Response::HTTP_UNAUTHORIZED); } - } - diff --git a/tests/TestCase.php b/tests/TestCase.php index 928c1a4..ef9d54d 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -108,7 +108,7 @@ protected function getEnvironmentSetUp($app) } /** - * @param $view + * @param $view * @param array $parameters * @return string */