TLSTest.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Jurgen Coetsiers
  5. * Date: 21/10/2018
  6. * Time: 09:09
  7. */
  8. class TLSTest extends TestCase
  9. {
  10. public function testGetTLSClientAuth()
  11. {
  12. $response = $this->getPsr7JsonResponseForFixture('Endpoints/getTLSClientAuth.json');
  13. $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
  14. $mock->method('get')->willReturn($response);
  15. $mock->expects($this->once())
  16. ->method('get')
  17. ->with(
  18. $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/tls_client_auth')
  19. );
  20. $tlsMock = new \Cloudflare\API\Endpoints\TLS($mock);
  21. $result = $tlsMock->getTLSClientAuth('c2547eb745079dac9320b638f5e225cf483cc5cfdda41');
  22. $this->assertEquals('off', $result);
  23. }
  24. public function testEnableTLS13()
  25. {
  26. $response = $this->getPsr7JsonResponseForFixture('Endpoints/enableTLS13.json');
  27. $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
  28. $mock->method('patch')->willReturn($response);
  29. $mock->expects($this->once())
  30. ->method('patch')
  31. ->with(
  32. $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/tls_1_3'),
  33. $this->equalTo(['value' => 'on'])
  34. );
  35. $tlsMock = new \Cloudflare\API\Endpoints\TLS($mock);
  36. $result = $tlsMock->enableTLS13('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true);
  37. $this->assertTrue($result);
  38. }
  39. public function testDisableTLS13()
  40. {
  41. $response = $this->getPsr7JsonResponseForFixture('Endpoints/disableTLS13.json');
  42. $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
  43. $mock->method('patch')->willReturn($response);
  44. $mock->expects($this->once())
  45. ->method('patch')
  46. ->with(
  47. $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/tls_1_3'),
  48. $this->equalTo(['value' => 'off'])
  49. );
  50. $tlsMock = new \Cloudflare\API\Endpoints\TLS($mock);
  51. $result = $tlsMock->disableTLS13('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', true);
  52. $this->assertTrue($result);
  53. }
  54. public function testChangeMinimimTLSVersion()
  55. {
  56. $response = $this->getPsr7JsonResponseForFixture('Endpoints/changeMinimumTLSVersion.json');
  57. $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
  58. $mock->method('patch')->willReturn($response);
  59. $mock->expects($this->once())
  60. ->method('patch')
  61. ->with(
  62. $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/min_tls_version'),
  63. $this->equalTo(['value' => '1.1'])
  64. );
  65. $tlsMock = new \Cloudflare\API\Endpoints\TLS($mock);
  66. $result = $tlsMock->changeMinimumTLSVersion('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', '1.1');
  67. $this->assertTrue($result);
  68. }
  69. public function testUpdateTLSClientAuth()
  70. {
  71. $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateTLSClientAuth.json');
  72. $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock();
  73. $mock->method('patch')->willReturn($response);
  74. $mock->expects($this->once())
  75. ->method('patch')
  76. ->with(
  77. $this->equalTo('zones/c2547eb745079dac9320b638f5e225cf483cc5cfdda41/settings/tls_client_auth'),
  78. $this->equalTo(['value' => 'off'])
  79. );
  80. $tlsMock = new \Cloudflare\API\Endpoints\TLS($mock);
  81. $result = $tlsMock->updateTLSClientAuth('c2547eb745079dac9320b638f5e225cf483cc5cfdda41', 'off');
  82. $this->assertTrue($result);
  83. }
  84. }