Refactor firewall and add edit rule (#488)

This commit is contained in:
Richard Anderson
2025-02-16 19:31:58 +00:00
committed by GitHub
parent e2b9d18a71
commit 8c7c3d2192
23 changed files with 443 additions and 210 deletions

View File

@ -23,16 +23,47 @@ public function test_create_firewall_rule(): void
'project' => $this->server->project,
'server' => $this->server,
]), [
'name' => 'Test',
'type' => 'allow',
'protocol' => 'tcp',
'port' => '1234',
'source' => '0.0.0.0',
'mask' => '0',
'mask' => '1',
])
->assertSuccessful()
->assertJsonFragment([
'port' => 1234,
'status' => FirewallRuleStatus::READY,
'status' => FirewallRuleStatus::CREATING,
]);
}
public function test_edit_firewall_rule(): void
{
SSH::fake();
Sanctum::actingAs($this->user, ['read', 'write']);
$rule = FirewallRule::factory()->create([
'server_id' => $this->server->id,
'port' => 1234,
]);
$this->json('PUT', route('api.projects.servers.firewall-rules.edit', [
'project' => $this->server->project,
'server' => $this->server,
'firewallRule' => $rule,
]), [
'name' => 'Test',
'type' => 'allow',
'protocol' => 'tcp',
'port' => '55',
'source' => null,
'mask' => null,
])
->assertSuccessful()
->assertJsonFragment([
'port' => 55,
'status' => FirewallRuleStatus::UPDATING,
]);
}

View File

@ -25,6 +25,7 @@ public function test_create_firewall_rule(): void
'server' => $this->server,
])
->callAction('create', [
'name' => 'Test',
'type' => 'allow',
'protocol' => 'tcp',
'port' => '1234',