From 45892b5ce308c57863fe159198e7fa24086425b0 Mon Sep 17 00:00:00 2001 From: Smitha Saligrama Date: Fri, 9 Jul 2021 21:17:46 -0700 Subject: [PATCH] React to new Microsoft.Health.Blob changes to heathcheck APIs (#875) * React to new Microsoft.Health.Blob changes to heathcheck APIs * SQL changes pulled * Disable Admin consent because it is not working again --- Directory.Build.props | 2 +- .../Public/Add-AadTestAuthEnvironment.ps1 | 2 +- .../Features/Health/DicomBlobHealthCheck.cs | 3 --- .../Features/Health/MetadataHealthCheck.cs | 3 --- ...icomServerBuilderSqlServerRegistrationExtensions.cs | 10 +++++++++- .../Persistence/DataStoreTestsFixture.cs | 7 +++---- .../Persistence/SqlDataStoreTestsFixture.cs | 7 +++++-- .../Rest/AuthorizationTests.cs | 2 +- 8 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 92615d3aad..99756b83fa 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,7 +9,7 @@ true true true - 2.1.40 + 3.0.13 true Latest MIT diff --git a/release/scripts/PowerShell/DicomServerRelease/Public/Add-AadTestAuthEnvironment.ps1 b/release/scripts/PowerShell/DicomServerRelease/Public/Add-AadTestAuthEnvironment.ps1 index 6aea3a6cf9..290efc6699 100644 --- a/release/scripts/PowerShell/DicomServerRelease/Public/Add-AadTestAuthEnvironment.ps1 +++ b/release/scripts/PowerShell/DicomServerRelease/Public/Add-AadTestAuthEnvironment.ps1 @@ -137,7 +137,7 @@ function Add-AadTestAuthEnvironment { $secretSecureString = ConvertTo-SecureString $newPassword.Value -AsPlainText -Force } - Grant-ClientAppAdminConsent -AppId $aadClientApplication.AppId -TenantAdminCredential $TenantAdminCredential + # Grant-ClientAppAdminConsent -AppId $aadClientApplication.AppId -TenantAdminCredential $TenantAdminCredential $environmentClientApplications += @{ id = $clientApp.Id diff --git a/src/Microsoft.Health.Dicom.Blob/Features/Health/DicomBlobHealthCheck.cs b/src/Microsoft.Health.Dicom.Blob/Features/Health/DicomBlobHealthCheck.cs index 8d9b284885..753e52e4c0 100644 --- a/src/Microsoft.Health.Dicom.Blob/Features/Health/DicomBlobHealthCheck.cs +++ b/src/Microsoft.Health.Dicom.Blob/Features/Health/DicomBlobHealthCheck.cs @@ -21,19 +21,16 @@ public class DicomBlobHealthCheck : BlobHealthCheck /// Initializes a new instance of the class. /// /// The blob client factory. - /// The blob data store configuration. /// The IOptions accessor to get a named blob container version. /// The test provider. /// The logger. public DicomBlobHealthCheck( BlobServiceClient client, - BlobDataStoreConfiguration configuration, IOptionsSnapshot namedBlobContainerConfigurationAccessor, IBlobClientTestProvider testProvider, ILogger logger) : base( client, - configuration, namedBlobContainerConfigurationAccessor, Constants.ContainerConfigurationName, testProvider, diff --git a/src/Microsoft.Health.Dicom.Metadata/Features/Health/MetadataHealthCheck.cs b/src/Microsoft.Health.Dicom.Metadata/Features/Health/MetadataHealthCheck.cs index b255feeba8..099828ee67 100644 --- a/src/Microsoft.Health.Dicom.Metadata/Features/Health/MetadataHealthCheck.cs +++ b/src/Microsoft.Health.Dicom.Metadata/Features/Health/MetadataHealthCheck.cs @@ -21,19 +21,16 @@ public class MetadataHealthCheck : BlobHealthCheck /// Initializes a new instance of the class. /// /// The blob client factory. - /// The blob data store configuration. /// The IOptions accessor to get a named blob container version. /// The test provider. /// The logger. public MetadataHealthCheck( BlobServiceClient client, - BlobDataStoreConfiguration configuration, IOptionsSnapshot namedBlobContainerConfigurationAccessor, IBlobClientTestProvider testProvider, ILogger logger) : base( client, - configuration, namedBlobContainerConfigurationAccessor, Constants.ContainerConfigurationName, testProvider, diff --git a/src/Microsoft.Health.Dicom.SqlServer/Registration/DicomServerBuilderSqlServerRegistrationExtensions.cs b/src/Microsoft.Health.Dicom.SqlServer/Registration/DicomServerBuilderSqlServerRegistrationExtensions.cs index 90fb613433..d3c79fb9a5 100644 --- a/src/Microsoft.Health.Dicom.SqlServer/Registration/DicomServerBuilderSqlServerRegistrationExtensions.cs +++ b/src/Microsoft.Health.Dicom.SqlServer/Registration/DicomServerBuilderSqlServerRegistrationExtensions.cs @@ -32,7 +32,15 @@ public static IDicomServerBuilder AddSqlServer( EnsureArg.IsNotNull(dicomServerBuilder, nameof(dicomServerBuilder)); IServiceCollection services = dicomServerBuilder.Services; - services.AddSqlServerBase(configurationRoot); + services + .AddSqlServerConnection( + config => + { + configurationRoot?.GetSection(SqlServerDataStoreConfiguration.SectionName).Bind(config); + configureAction?.Invoke(config); + }) + .AddSqlServerManagement(); + services.AddSqlServerApi(); var config = new SqlServerDataStoreConfiguration(); diff --git a/test/Microsoft.Health.Dicom.Tests.Integration/Persistence/DataStoreTestsFixture.cs b/test/Microsoft.Health.Dicom.Tests.Integration/Persistence/DataStoreTestsFixture.cs index 25db7d5d36..2c591603c7 100644 --- a/test/Microsoft.Health.Dicom.Tests.Integration/Persistence/DataStoreTestsFixture.cs +++ b/test/Microsoft.Health.Dicom.Tests.Integration/Persistence/DataStoreTestsFixture.cs @@ -56,15 +56,14 @@ public async Task InitializeAsync() IBlobClientTestProvider testProvider = new BlobClientReadWriteTestProvider(RecyclableMemoryStreamManager); - var blobClientInitializer = new BlobClientInitializer(testProvider, NullLogger.Instance); - _blobClient = blobClientInitializer.CreateBlobClient(_blobDataStoreConfiguration); + _blobClient = BlobClientFactory.Create(_blobDataStoreConfiguration); + + var blobClientInitializer = new BlobInitializer(_blobClient, testProvider, NullLogger.Instance); var blobContainerInitializer = new BlobContainerInitializer(_blobContainerConfiguration.ContainerName, NullLogger.Instance); var metadataContainerInitializer = new BlobContainerInitializer(_metadataContainerConfiguration.ContainerName, NullLogger.Instance); await blobClientInitializer.InitializeDataStoreAsync( - _blobClient, - _blobDataStoreConfiguration, new List { blobContainerInitializer, metadataContainerInitializer }); var jsonSerializer = new JsonSerializer(); diff --git a/test/Microsoft.Health.Dicom.Tests.Integration/Persistence/SqlDataStoreTestsFixture.cs b/test/Microsoft.Health.Dicom.Tests.Integration/Persistence/SqlDataStoreTestsFixture.cs index ff4deece0b..981520867b 100644 --- a/test/Microsoft.Health.Dicom.Tests.Integration/Persistence/SqlDataStoreTestsFixture.cs +++ b/test/Microsoft.Health.Dicom.Tests.Integration/Persistence/SqlDataStoreTestsFixture.cs @@ -10,6 +10,7 @@ using MediatR; using Microsoft.Data.SqlClient; using Microsoft.Extensions.Logging.Abstractions; +using Microsoft.Extensions.Options; using Microsoft.Health.Dicom.Core.Features.ExtendedQueryTag; using Microsoft.Health.Dicom.Core.Features.Retrieve; using Microsoft.Health.Dicom.Core.Features.Store; @@ -56,13 +57,15 @@ internal SqlDataStoreTestsFixture(string databaseName) }, }; + IOptions configOptions = Options.Create(config); + var scriptProvider = new ScriptProvider(); var baseScriptProvider = new BaseScriptProvider(); var mediator = Substitute.For(); - var sqlConnectionStringProvider = new DefaultSqlConnectionStringProvider(config); + var sqlConnectionStringProvider = new DefaultSqlConnectionStringProvider(configOptions); var sqlConnectionFactory = new DefaultSqlConnectionFactory(sqlConnectionStringProvider); @@ -72,7 +75,7 @@ internal SqlDataStoreTestsFixture(string databaseName) SchemaInformation = new SchemaInformation(SchemaVersionConstants.Min, SchemaVersionConstants.Max); - _schemaInitializer = new SchemaInitializer(config, SchemaUpgradeRunner, SchemaInformation, sqlConnectionFactory, sqlConnectionStringProvider, mediator, NullLogger.Instance); + _schemaInitializer = new SchemaInitializer(configOptions, schemaManagerDataStore, SchemaUpgradeRunner, SchemaInformation, sqlConnectionFactory, sqlConnectionStringProvider, mediator, NullLogger.Instance); SqlTransactionHandler = new SqlTransactionHandler(); diff --git a/test/Microsoft.Health.Dicom.Web.Tests.E2E/Rest/AuthorizationTests.cs b/test/Microsoft.Health.Dicom.Web.Tests.E2E/Rest/AuthorizationTests.cs index 410fb2a1a4..d34abf05f6 100644 --- a/test/Microsoft.Health.Dicom.Web.Tests.E2E/Rest/AuthorizationTests.cs +++ b/test/Microsoft.Health.Dicom.Web.Tests.E2E/Rest/AuthorizationTests.cs @@ -23,7 +23,7 @@ public AuthorizationTests(HttpIntegrationTestFixture fixture) _fixture = fixture; } - [Fact] + [Fact(Skip = "Setup AAD admin consent issue, Bug 83049: DICOM OSS CI is broken")] public async Task GivenPostDicomRequest_WithAReadOnlyToken_ReturnUnauthorized() { if (AuthenticationSettings.SecurityEnabled)