Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Endpoints/Accounts/Rulesets.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function get(string $accountId): ResponseInterface
public function create(string $accountId, array|Ruleset $values): ResponseInterface
{
if (is_array($values)) {
$this->requiredParams(['name', 'kind', 'phase', 'rules'], $values);
$this->requiredParams(['name', 'kind', 'phase'], $values);
} else {
$values = $values->toArray();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Endpoints/Zones/Rulesets.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function get(string $zoneId): ResponseInterface
public function create(string $zoneId, array|Ruleset $values): ResponseInterface
{
if (is_array($values)) {
$this->requiredParams(['name', 'kind', 'phase', 'rules'], $values);
$this->requiredParams(['name', 'kind', 'phase'], $values);
} else {
$values = $values->toArray();
}
Expand Down
35 changes: 35 additions & 0 deletions test/Tests/Endpoints/Accounts/RulesetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,41 @@ public function shouldCreateWithArray()
$this->assertSame('/client/v4/accounts/account_id/rulesets', $this->lastRequest()->getUri()->getPath());
}

#[Test]
public function shouldCreateWithEmptyRulesArray()
{
$client = $this->mockClient([
new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])),
]);

$response = $client->accounts()->rulesets()->create('account_id', [
'name' => 'my ruleset',
'kind' => 'root',
'phase' => 'http_request_firewall_custom',
'rules' => [],
]);

$this->assertTrue($response->successful());
$this->assertSame('POST', $this->lastRequest()->getMethod());
}

#[Test]
public function shouldCreateWithoutRulesKey()
{
$client = $this->mockClient([
new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])),
]);

$response = $client->accounts()->rulesets()->create('account_id', [
'name' => 'my ruleset',
'kind' => 'root',
'phase' => 'http_request_firewall_custom',
]);

$this->assertTrue($response->successful());
$this->assertSame('POST', $this->lastRequest()->getMethod());
}

#[Test]
public function shouldCreateWithRulesetObject()
{
Expand Down
35 changes: 35 additions & 0 deletions test/Tests/Endpoints/Zones/RulesetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,41 @@ public function shouldCreateWithArray()
$this->assertSame('/client/v4/zones/zone_id/rulesets', $this->lastRequest()->getUri()->getPath());
}

#[Test]
public function shouldCreateWithEmptyRulesArray()
{
$client = $this->mockClient([
new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])),
]);

$response = $client->zones()->rulesets()->create('zone_id', [
'name' => 'my ruleset',
'kind' => 'zone',
'phase' => 'http_request_firewall_custom',
'rules' => [],
]);

$this->assertTrue($response->successful());
$this->assertSame('POST', $this->lastRequest()->getMethod());
}

#[Test]
public function shouldCreateWithoutRulesKey()
{
$client = $this->mockClient([
new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])),
]);

$response = $client->zones()->rulesets()->create('zone_id', [
'name' => 'my ruleset',
'kind' => 'zone',
'phase' => 'http_request_firewall_custom',
]);

$this->assertTrue($response->successful());
$this->assertSame('POST', $this->lastRequest()->getMethod());
}

#[Test]
public function shouldCreateWithRulesetObject()
{
Expand Down
Loading