ChannelCredentialsTest.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /*
  3. *
  4. * Copyright 2015 gRPC authors.
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. *
  18. */
  19. class ChanellCredentialsTest extends \PHPUnit\Framework\TestCase
  20. {
  21. public function setUp(): void
  22. {
  23. }
  24. public function tearDown(): void
  25. {
  26. }
  27. public function testCreateSslWith3Null()
  28. {
  29. $channel_credentials = Grpc\ChannelCredentials::createSsl(null, null,
  30. null);
  31. $this->assertNotNull($channel_credentials);
  32. }
  33. public function testCreateSslWith3NullString()
  34. {
  35. $channel_credentials = Grpc\ChannelCredentials::createSsl('', '', '');
  36. $this->assertNotNull($channel_credentials);
  37. }
  38. public function testCreateInsecure()
  39. {
  40. $channel_credentials = Grpc\ChannelCredentials::createInsecure();
  41. $this->assertNotNull($channel_credentials);
  42. }
  43. public function testDefaultRootsPem()
  44. {
  45. Grpc\ChannelCredentials::setDefaultRootsPem("Pem-Content-Not-Verified");
  46. $this->assertTrue(Grpc\ChannelCredentials::isDefaultRootsPemSet());
  47. Grpc\ChannelCredentials::invalidateDefaultRootsPem();
  48. $this->assertFalse(Grpc\ChannelCredentials::isDefaultRootsPemSet());
  49. Grpc\ChannelCredentials::setDefaultRootsPem("Content-Not-Verified");
  50. $this->assertTrue(Grpc\ChannelCredentials::isDefaultRootsPemSet());
  51. }
  52. public function testInvalidCreateSsl()
  53. {
  54. $this->expectException(\InvalidArgumentException::class);
  55. $channel_credentials = Grpc\ChannelCredentials::createSsl([]);
  56. }
  57. public function testInvalidCreateComposite()
  58. {
  59. $this->expectException(\InvalidArgumentException::class);
  60. $channel_credentials = Grpc\ChannelCredentials::createComposite(
  61. 'something', 'something');
  62. }
  63. }