public void TestGetEncryptionState() { IAsset asset = JobTests.CreateSmoothAsset(_mediaContext, _filePaths, AssetCreationOptions.None); AssetDeliveryProtocol protocolsToSet = AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.Dash; Dictionary <AssetDeliveryPolicyConfigurationKey, string> configuration = new Dictionary <AssetDeliveryPolicyConfigurationKey, string>() { { AssetDeliveryPolicyConfigurationKey.EnvelopeBaseKeyAcquisitionUrl, "https://www.test.com/" }, { AssetDeliveryPolicyConfigurationKey.EnvelopeEncryptionIVAsBase64, Convert.ToBase64String(ContentKeyTests.GetRandomBuffer(16)) } }; IAssetDeliveryPolicy policy = _mediaContext.AssetDeliveryPolicies.Create("Test Policy", AssetDeliveryPolicyType.DynamicEnvelopeEncryption, protocolsToSet, configuration); IContentKey key = _mediaContext.ContentKeys.Create(Guid.NewGuid(), ContentKeyTests.GetRandomBuffer(16), "Test key", ContentKeyType.EnvelopeEncryption); asset.ContentKeys.Add(key); asset.DeliveryPolicies.Add(policy); AssetEncryptionState state = asset.GetEncryptionState(protocolsToSet); Assert.AreEqual(AssetEncryptionState.DynamicEnvelopeEncryption, state); state = asset.GetEncryptionState(AssetDeliveryProtocol.Dash | AssetDeliveryProtocol.Hds); Assert.AreEqual(AssetEncryptionState.NoSinglePolicyApplies, state); state = asset.GetEncryptionState(AssetDeliveryProtocol.Hds); Assert.AreEqual(AssetEncryptionState.BlockedByPolicy, state); CleanupAsset(asset); }
public void ValidateEffectiveEncryptionStatusOfStorageEncryptedHls() { IAsset smoothAsset = JobTests.CreateSmoothAsset(_mediaContext, _filePaths, AssetCreationOptions.None); IAsset playReadyProtectedSmoothAsset = CreatePlayReadyProtectedSmoothAsset(smoothAsset); IAsset storageEncryptedHls = CreateHlsFromSmoothAsset(smoothAsset, AssetCreationOptions.StorageEncrypted); CleanupAsset(smoothAsset); Assert.AreEqual(true, storageEncryptedHls.IsStreamable); Assert.AreEqual(AssetType.MediaServicesHLS, storageEncryptedHls.AssetType); Assert.AreEqual(AssetCreationOptions.StorageEncrypted, storageEncryptedHls.Options); AssetDeliveryProtocol protocolsToTest = AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.Dash | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Hds; List <TestCase> testCases = GetTestsCasesForProtocolCombination(protocolsToTest, AssetEncryptionState.StorageEncryptedWithNoDeliveryPolicy); ValidateAssetEncryptionState(storageEncryptedHls, testCases); SetupClearPolicy(storageEncryptedHls, AssetDeliveryProtocol.HLS); UpdateTestCasesForAddedPolicy(testCases, storageEncryptedHls.DeliveryPolicies); ValidateAssetEncryptionState(storageEncryptedHls, testCases); CleanupAsset(storageEncryptedHls); }
public void ValidateEffectiveEncryptionStatusOfSmooth() { IAsset asset = JobTests.CreateSmoothAsset(_mediaContext, _filePaths, AssetCreationOptions.None); Assert.AreEqual(true, asset.IsStreamable); Assert.AreEqual(AssetType.SmoothStreaming, asset.AssetType); Assert.AreEqual(AssetCreationOptions.None, asset.Options); AssetDeliveryProtocol protocolsToTest = AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.Dash | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Hds; List <TestCase> testCases = GetTestsCasesForProtocolCombination(protocolsToTest, AssetEncryptionState.ClearOutput); ValidateAssetEncryptionState(asset, testCases); SetupCommonPolicy(asset, AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Dash | AssetDeliveryProtocol.SmoothStreaming); UpdateTestCasesForAddedPolicy(testCases, asset.DeliveryPolicies); ValidateAssetEncryptionState(asset, testCases); CleanupAsset(asset); }
public void ValidateEffectiveEncryptionStatusOfStorageEncryptedSmooth() { IAsset asset = JobTests.CreateSmoothAsset(_mediaContext, _filePaths, AssetCreationOptions.StorageEncrypted); Assert.IsTrue(asset.IsStreamable); Assert.AreEqual(AssetType.SmoothStreaming, asset.AssetType); Assert.AreEqual(AssetCreationOptions.StorageEncrypted, asset.Options); // There is no asset delivery policy so streaming should be blocked AssetDeliveryProtocol protocolsToTest = AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.Dash | AssetDeliveryProtocol.HLS | AssetDeliveryProtocol.Hds; List <TestCase> testCases = GetTestsCasesForProtocolCombination(protocolsToTest, AssetEncryptionState.StorageEncryptedWithNoDeliveryPolicy); ValidateAssetEncryptionState(asset, testCases); SetupEnvelopePolicy(asset, AssetDeliveryProtocol.HLS); UpdateTestCasesForAddedPolicy(testCases, asset.DeliveryPolicies); ValidateAssetEncryptionState(asset, testCases); SetupCommonPolicy(asset, AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.Dash); UpdateTestCasesForAddedPolicy(testCases, asset.DeliveryPolicies); ValidateAssetEncryptionState(asset, testCases); CleanupAsset(asset); }
public void ValidateEffectiveEncryptionStatusOfEnvelopeProtectedHls() { IAsset smoothAsset = JobTests.CreateSmoothAsset(_mediaContext, _filePaths, AssetCreationOptions.None); IAsset envelopeHls = CreateHlsFromSmoothAsset(smoothAsset, AssetCreationOptions.EnvelopeEncryptionProtected); CleanupAsset(smoothAsset); Assert.AreEqual(true, envelopeHls.IsStreamable); Assert.AreEqual(AssetType.MediaServicesHLS, envelopeHls.AssetType); Assert.AreEqual(AssetCreationOptions.EnvelopeEncryptionProtected, envelopeHls.Options); ValidateAssetEncryptionState(envelopeHls, AssetDeliveryProtocol.HLS, AssetEncryptionState.StaticEnvelopeEncryption); CleanupAsset(envelopeHls); }
public void ValidateEffectiveEncryptionStatusOfHls() { IAsset smoothAsset = JobTests.CreateSmoothAsset(_mediaContext, _filePaths, AssetCreationOptions.None); IAsset clearHls = CreateHlsFromSmoothAsset(smoothAsset, AssetCreationOptions.None); CleanupAsset(smoothAsset); Assert.AreEqual(true, clearHls.IsStreamable); Assert.AreEqual(AssetType.MediaServicesHLS, clearHls.AssetType); Assert.AreEqual(AssetCreationOptions.None, clearHls.Options); ValidateAssetEncryptionState(clearHls, AssetDeliveryProtocol.HLS, AssetEncryptionState.ClearOutput); CleanupAsset(clearHls); }
public void ValidateEffectiveEncryptionStatusOfPlayReadyProtectedHls() { IAsset smoothAsset = JobTests.CreateSmoothAsset(_mediaContext, _filePaths, AssetCreationOptions.None); IAsset playReadyProtectedSmoothAsset = CreatePlayReadyProtectedSmoothAsset(smoothAsset); IAsset playReadyProtectedHls = CreateHlsFromSmoothAsset(playReadyProtectedSmoothAsset, AssetCreationOptions.CommonEncryptionProtected); CleanupAsset(smoothAsset); CleanupAsset(playReadyProtectedSmoothAsset); Assert.AreEqual(true, playReadyProtectedHls.IsStreamable); Assert.AreEqual(AssetType.MediaServicesHLS, playReadyProtectedHls.AssetType); Assert.AreEqual(AssetCreationOptions.CommonEncryptionProtected, playReadyProtectedHls.Options); // Enable these once bug //Assert.AreEqual(1, playReadyProtectedHls.ContentKeys.Count); //Assert.AreEqual(ContentKeyType.CommonEncryption, playReadyProtectedHls.ContentKeys[0].ContentKeyType); ValidateAssetEncryptionState(playReadyProtectedHls, AssetDeliveryProtocol.HLS, AssetEncryptionState.StaticCommonEncryption); CleanupAsset(playReadyProtectedHls); }
public void ValidateEffectiveEncryptionStatusOfPlayReadyProtectedSmooth() { IAsset asset = JobTests.CreateSmoothAsset(_mediaContext, _filePaths, AssetCreationOptions.None); IAsset playReadyProtectedSmoothAsset = CreatePlayReadyProtectedSmoothAsset(asset); Assert.AreEqual(true, playReadyProtectedSmoothAsset.IsStreamable); Assert.AreEqual(AssetType.SmoothStreaming, playReadyProtectedSmoothAsset.AssetType); Assert.AreEqual(AssetCreationOptions.CommonEncryptionProtected, playReadyProtectedSmoothAsset.Options); Assert.AreEqual(1, playReadyProtectedSmoothAsset.ContentKeys.Count); AssetDeliveryProtocol protocolsToTest = AssetDeliveryProtocol.SmoothStreaming | AssetDeliveryProtocol.Dash | AssetDeliveryProtocol.HLS; Assert.AreEqual(ContentKeyType.CommonEncryption, playReadyProtectedSmoothAsset.ContentKeys[0].ContentKeyType); ValidateAssetEncryptionState(playReadyProtectedSmoothAsset, protocolsToTest, AssetEncryptionState.StaticCommonEncryption); CleanupAsset(playReadyProtectedSmoothAsset); CleanupAsset(asset); }