add firewall settings endpoints, tests
This commit is contained in:
121
tests/Endpoints/FirewallSettingsTest.php
Normal file
121
tests/Endpoints/FirewallSettingsTest.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php
|
||||
|
||||
class FirewallSettingsTest extends TestCase
|
||||
{
|
||||
public function testGetSecurityLevelSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getSecurityLevelSetting.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('get')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/security_level')
|
||||
);
|
||||
|
||||
$firewallSettingsMock = new \Cloudflare\API\Endpoints\FirewallSettings($mock);
|
||||
$result = $firewallSettingsMock->getSecurityLevelSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertEquals('medium', $result);
|
||||
}
|
||||
|
||||
public function testGetChallengeTTLSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getChallengeTTLSetting.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('get')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/challenge_ttl')
|
||||
);
|
||||
|
||||
$firewallSettingsMock = new \Cloudflare\API\Endpoints\FirewallSettings($mock);
|
||||
$result = $firewallSettingsMock->getChallengeTTLSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertEquals(1800, $result);
|
||||
}
|
||||
|
||||
public function testGetBrowserIntegrityCheckSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getBrowserIntegrityCheckSetting.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('get')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/browser_check')
|
||||
);
|
||||
|
||||
$firewallSettingsMock = new \Cloudflare\API\Endpoints\FirewallSettings($mock);
|
||||
$result = $firewallSettingsMock->getBrowserIntegrityCheckSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
|
||||
|
||||
$this->assertEquals('on', $result);
|
||||
}
|
||||
|
||||
public function testUpdateSecurityLevelSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateSecurityLevelSetting.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('patch')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('patch')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/opportunistic_encryption'),
|
||||
$this->equalTo(['value' => 'medium'])
|
||||
);
|
||||
|
||||
$firewallSettingsMock = new \Cloudflare\API\Endpoints\FirewallSettings($mock);
|
||||
$result = $firewallSettingsMock->updateSecurityLevelSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'medium');
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testUpdateChallengeTTLSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateChallengeTTLSetting.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('patch')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('patch')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/challenge_ttl'),
|
||||
$this->equalTo(['value' => 1800])
|
||||
);
|
||||
|
||||
$firewallSettingsMock = new \Cloudflare\API\Endpoints\FirewallSettings($mock);
|
||||
$result = $firewallSettingsMock->updateChallengeTTLSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 1800);
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testUpdateBrowserIntegrityCheckSetting()
|
||||
{
|
||||
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateBrowserIntegrityCheckSetting.json');
|
||||
|
||||
$mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
|
||||
$mock->method('patch')->willReturn($response);
|
||||
|
||||
$mock->expects($this->once())
|
||||
->method('patch')
|
||||
->with(
|
||||
$this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/browser_check'),
|
||||
$this->equalTo(['value' => 'on'])
|
||||
);
|
||||
|
||||
$firewallSettingsMock = new \Cloudflare\API\Endpoints\FirewallSettings($mock);
|
||||
$result = $firewallSettingsMock->updateBrowserIntegrityCheckSetting('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'on');
|
||||
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,10 @@ class UARulesTest extends TestCase
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/firewall/ua_rules'),
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20
|
||||
])
|
||||
$this->equalTo([
|
||||
'page' => 1,
|
||||
'per_page' => 20
|
||||
])
|
||||
);
|
||||
|
||||
$zones = new \Cloudflare\API\Endpoints\UARules($mock);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "browser_check",
|
||||
"value": "on",
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
11
tests/Fixtures/Endpoints/getChallengeTTLSetting.json
Normal file
11
tests/Fixtures/Endpoints/getChallengeTTLSetting.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "challenge_ttl",
|
||||
"value": 1800,
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
11
tests/Fixtures/Endpoints/getSecurityLevelSetting.json
Normal file
11
tests/Fixtures/Endpoints/getSecurityLevelSetting.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "security_level",
|
||||
"value": "medium",
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "browser_check",
|
||||
"value": "on",
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
11
tests/Fixtures/Endpoints/updateChallengeTTLSetting.json
Normal file
11
tests/Fixtures/Endpoints/updateChallengeTTLSetting.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "challenge_ttl",
|
||||
"value": 1800,
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
11
tests/Fixtures/Endpoints/updateSecurityLevelSetting.json
Normal file
11
tests/Fixtures/Endpoints/updateSecurityLevelSetting.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"success": true,
|
||||
"errors": [],
|
||||
"messages": [],
|
||||
"result": {
|
||||
"id": "security_level",
|
||||
"value": "medium",
|
||||
"editable": true,
|
||||
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user