You are here

public function JWKFetcherTest::testConvertCertToPem in Auth0 Single Sign On 8.2

Test that the protected getProp method returns correctly.

Return value

void

File

vendor/auth0/auth0-php/tests/Helpers/JWKFetcherTest.php, line 158

Class

JWKFetcherTest
Class JWKFetcherTest.

Namespace

Auth0\Tests\Helpers

Code

public function testConvertCertToPem() {
  $class = new \ReflectionClass(JWKFetcher::class);
  $method = $class
    ->getMethod('convertCertToPem');
  $method
    ->setAccessible(true);
  $test_string_1 = '';
  for ($i = 1; $i <= 64; $i++) {
    $test_string_1 .= 'a';
  }
  $test_string_2 = '';
  for ($i = 1; $i <= 64; $i++) {
    $test_string_2 .= 'b';
  }
  $returned_pem = $method
    ->invoke(new JWKFetcher(), $test_string_1 . $test_string_2);
  $pem_parts = explode(PHP_EOL, $returned_pem);
  $this
    ->assertEquals(5, count($pem_parts));
  $this
    ->assertEquals('-----BEGIN CERTIFICATE-----', $pem_parts[0]);
  $this
    ->assertEquals($test_string_1, $pem_parts[1]);
  $this
    ->assertEquals($test_string_2, $pem_parts[2]);
  $this
    ->assertEquals('-----END CERTIFICATE-----', $pem_parts[3]);
}