Skip to content

Commit

Permalink
fixed #57 #58
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Mar 20, 2023
1 parent 6a44c0b commit 16f7db9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Config/firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'enabled' => env('FIREWALL_ENABLED', true),

'whitelist' => [env('FIREWALL_WHITELIST', '')],
'whitelist' => explode(',', env('FIREWALL_WHITELIST', '')),

'models' => [
'user' => '\App\Models\User',
Expand Down
8 changes: 7 additions & 1 deletion tests/Feature/WhitelistTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Akaunting\Firewall\Tests\Feature;

use Akaunting\Firewall\Middleware\Whitelist;
use Akaunting\Firewall\Models\Ip as Model;
use Akaunting\Firewall\Tests\TestCase;

class WhitelistTest extends TestCase
Expand All @@ -15,6 +14,13 @@ public function testShouldAllow()
$this->assertEquals('next', (new Whitelist())->handle($this->app->request, $this->getNextClosure()));
}

public function testShouldAllowMultiple()
{
config(['firewall.whitelist' => ['127.0.0.0/24', '127.0.0.1']]);

$this->assertEquals('next', (new Whitelist())->handle($this->app->request, $this->getNextClosure()));
}

public function testShouldBlock()
{
$this->assertEquals('403', (new Whitelist())->handle($this->app->request, $this->getNextClosure())->getStatusCode());
Expand Down

0 comments on commit 16f7db9

Please sign in to comment.