Skip to content

Commit

Permalink
Disable
Browse files Browse the repository at this point in the history
  • Loading branch information
edersoares committed Aug 2, 2024
1 parent b8ddd17 commit 07db692
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Frontier.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class Frontier
{
public static function add(array $config): void
{
if (empty($config['enabled'])) {
return;
}

match ($config['type']) {
'http' => self::http($config),
'proxy' => self::proxy($config),
Expand Down
24 changes: 24 additions & 0 deletions tests/Unit/DisableTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

use Dex\Laravel\Frontier\Frontier;
use Illuminate\Support\Facades\Http;

test('assert not found when Frontier is disabled', function () {
Frontier::add([
'enabled' => false,
'type' => 'proxy',
'host' => 'frontier.test',
'rules' => [
'/disabled::exact',
],
]);

Http::fake([
'frontier.test/disabled' => Http::response('Frontier is disabled'),
]);

$this->get('disabled')
->assertNotFound();
});

0 comments on commit 07db692

Please sign in to comment.