/**
  * @covers WindowsAzure\MediaServices\Templates\SymmetricVerificationKey::getKeyValue
  * @covers WindowsAzure\MediaServices\Templates\SymmetricVerificationKey::setKeyValue
  */
 public function testGetSetKeyValue()
 {
     // Setup
     $entity = new SymmetricVerificationKey();
     $payload = "payload string";
     // Test
     $entity->setKeyValue($payload);
     $result = $entity->getKeyValue();
     // Assert
     $this->assertEquals($payload, $result);
 }
 /**
  * @param mixed $xmlElement
  * @return TokenVerificationKey
  */
 private static function deserializeTokenVerificationKey($xmlElement)
 {
     if (!isset($xmlElement->attributes(Resources::XSI_XML_NAMESPACE)->type)) {
         throw new \RuntimeException("A TokenVerificationKey must contains a 'type' attribute");
     }
     $type = $xmlElement->attributes(Resources::XSI_XML_NAMESPACE)->type;
     if ($type == "SymmetricVerificationKey") {
         if (!isset($xmlElement->KeyValue)) {
             throw new \RuntimeException("The SymmetricVerificationKey must contains an 'KeyValue' element");
         }
         $key = new SymmetricVerificationKey();
         $key->setKeyValue(base64_decode($xmlElement->KeyValue));
         return $key;
     }
     if ($type == "X509CertTokenVerificationKey") {
         if (!isset($xmlElement->RawBody)) {
             throw new \RuntimeException("The X509CertTokenVerificationKey must contains a 'RawBody' element");
         }
         $key = new X509CertTokenVerificationKey();
         $key->setRawBody(base64_decode($xmlElement->RawBody));
         return $key;
     }
     throw new \RuntimeException("Unknown TokenVerificationKey type: type='{$type}'");
 }
 public function testKnownGoodGenerateTestTokenJWT()
 {
     // Arrange
     $expectedToken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1cm46bWljcm9zb2Z0OmF6dXJlOm1lZGlhc2VydmljZXM6Y29udGVudGtleWlkZW50aWZpZXIiOiIwOTE0NDM1ZC0xNTAwLTgwYzQtNmMyYi1mMWU1MmZkYTQ3YWUiLCJpc3MiOiJodHRwczpcL1wvdHN0LmNvbnRvc28uY29tIiwiYXVkIjoidXJuOmNvbnRvc28iLCJleHAiOjE0NTE2MDY0MDAsIm5iZiI6MTQ1MTYwNjQwMH0.voBCckYtSgVq6Z1Y8gwOBJO8DfH4-dX9ACmvSSHADso';
     $knownSymetricKey = '64bytes6RNhi8EsxcYsdYQ9zpFuNR1Ks9milykbxYWGILaK0LKzd5dCtYonsr456';
     $knownGuid = '0914435d-1500-80c4-6c2b-f1e52fda47ae';
     $knownExpireOn = 1451606400;
     // 2016-01-01 as Unix Epoch;
     $knownNotBefore = 1451606400;
     // 2016-01-01 as Unix Epoch;
     $knownAudience = 'urn:contoso';
     $knownIssuer = 'https://tst.contoso.com';
     $template = new TokenRestrictionTemplate(TokenType::JWT);
     $key = new SymmetricVerificationKey();
     $key->setKeyValue($knownSymetricKey);
     $template->setPrimaryVerificationKey($key);
     $template->setAudience($knownAudience);
     $template->setIssuer($knownIssuer);
     $template->setRequiredClaims(array(new TokenClaim(TokenClaim::CONTENT_KEY_ID_CLAIM_TYPE)));
     // Act
     $resultsToken = TokenRestrictionTemplateSerializer::generateTestToken($template, $key, $knownGuid, $knownExpireOn, $knownNotBefore);
     // Assert
     $this->assertEquals($expectedToken, $resultsToken);
 }