AzureDataProtectionBuilderExtensionsTest.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright (c) .NET Foundation. All rights reserved.
  2. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
  3. using System;
  4. using Microsoft.AspNetCore.DataProtection.KeyManagement;
  5. using Microsoft.Extensions.DependencyInjection;
  6. using Microsoft.Extensions.Options;
  7. using Microsoft.WindowsAzure.Storage.Blob;
  8. using Xunit;
  9. namespace Microsoft.AspNetCore.DataProtection.AzureStorage
  10. {
  11. public class AzureDataProtectionBuilderExtensionsTest
  12. {
  13. [Fact]
  14. public void PersistKeysToAzureBlobStorage_UsesAzureBlobXmlRepository()
  15. {
  16. // Arrange
  17. var container = new CloudBlobContainer(new Uri("http://www.example.com"));
  18. var serviceCollection = new ServiceCollection();
  19. var builder = serviceCollection.AddDataProtection();
  20. // Act
  21. builder.PersistKeysToAzureBlobStorage(container, "keys.xml");
  22. var services = serviceCollection.BuildServiceProvider();
  23. // Assert
  24. var options = services.GetRequiredService<IOptions<KeyManagementOptions>>();
  25. Assert.IsType<AzureBlobXmlRepository>(options.Value.XmlRepository);
  26. }
  27. }
  28. }