From 2b8e616fc47a9c608eb8e86cc4ab381fc05ccad8 Mon Sep 17 00:00:00 2001 From: Nate Malubay Date: Fri, 9 Feb 2024 17:06:45 -0800 Subject: [PATCH] Fix failing unit tests --- .../Security/SecurityProviderTests.cs | 22 +++++++++---------- .../GetSmartConfigurationHandlerTests.cs | 16 +++++++------- .../WellKnownConfigurationProviderTests.cs | 8 +++---- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Security/SecurityProviderTests.cs b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Security/SecurityProviderTests.cs index 384a74ad20..fc8f03ac29 100644 --- a/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Security/SecurityProviderTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Api.UnitTests/Features/Security/SecurityProviderTests.cs @@ -75,8 +75,8 @@ public void GivenSecurityNotEnabled_WhenBuildCalled_SecurityNotAddedToBuilder() [Theory] [InlineData(null, null)] - [InlineData(null, "https://localhost:44312/token")] - [InlineData("https://localhost:44312/auth", null)] + [InlineData(null, "https://testhost:44312/token")] + [InlineData("https://testhost:44312/auth", null)] public void GivenOAuthAuthorizationEndpointOrTokenEndpointIsInvalid_WhenBuildCalled_ExceptionThrown(string auth, string token) { _wellKnownConfigurationProvider.GetOpenIdConfigurationAsync(Arg.Any()).Returns(GetOpenIdConfiguration(auth, token)); @@ -87,8 +87,8 @@ public void GivenOAuthAuthorizationEndpointOrTokenEndpointIsInvalid_WhenBuildCal [Fact] public void GivenOpenIdConfigurationProvided_WhenBuildCalled_ExpectedCapabilitiesAreAdded() { - string auth = "https://localhost:44312/auth"; - string token = "https://localhost:44312/token"; + string auth = "https://testhost:44312/auth"; + string token = "https://testhost:44312/token"; _modelInfoProvider.Version.Returns(FhirSpecification.R4); _wellKnownConfigurationProvider.IsSmartConfigured().Returns(false); @@ -113,11 +113,11 @@ public void GivenOpenIdConfigurationProvided_WhenBuildCalled_ExpectedCapabilitie } [Theory] - [InlineData("https://localhost:44312/auth", "https://localhost:44312/token", null, null, null, null)] - [InlineData("https://localhost:44312/auth", "https://localhost:44312/token", "https://localhost:44312/reg", null, null, null)] - [InlineData("https://localhost:44312/auth", "https://localhost:44312/token", "https://localhost:44312/reg", "https://localhost:44312/man", null, null)] - [InlineData("https://localhost:44312/auth", "https://localhost:44312/token", "https://localhost:44312/reg", "https://localhost:44312/man", "https://localhost:44312/intr", null)] - [InlineData("https://localhost:44312/auth", "https://localhost:44312/token", "https://localhost:44312/reg", "https://localhost:44312/man", "https://localhost:44312/intr", "https://localhost:44312/rev")] + [InlineData("https://testhost:44312/auth", "https://testhost:44312/token", null, null, null, null)] + [InlineData("https://testhost:44312/auth", "https://testhost:44312/token", "https://testhost:44312/reg", null, null, null)] + [InlineData("https://testhost:44312/auth", "https://testhost:44312/token", "https://testhost:44312/reg", "https://testhost:44312/man", null, null)] + [InlineData("https://testhost:44312/auth", "https://testhost:44312/token", "https://testhost:44312/reg", "https://testhost:44312/man", "https://testhost:44312/intr", null)] + [InlineData("https://testhost:44312/auth", "https://testhost:44312/token", "https://testhost:44312/reg", "https://testhost:44312/man", "https://testhost:44312/intr", "https://testhost:44312/rev")] public void GivenSmartConfigurationProvided_WhenBuildCalled_ExpectedCapabilitiesAreAdded(string auth, string token, string reg, string man, string intr, string rev) { _modelInfoProvider.Version.Returns(FhirSpecification.R4); @@ -149,8 +149,8 @@ public void GivenSmartConfigurationProvided_WhenBuildCalled_ExpectedCapabilities [Fact] public void GivenSmartConfigurationIsNotValid_WhenBuildCalled_FallbackCapabilitiesAreAdded() { - string auth = "https://localhost:44312/auth"; - string token = "https://localhost:44312/token"; + string auth = "https://testhost:44312/auth"; + string token = "https://testhost:44312/token"; _modelInfoProvider.Version.Returns(FhirSpecification.R4); _wellKnownConfigurationProvider.IsSmartConfigured().Returns(true); diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/GetSmartConfigurationHandlerTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/GetSmartConfigurationHandlerTests.cs index 838e7f9520..0b32086415 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/GetSmartConfigurationHandlerTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/GetSmartConfigurationHandlerTests.cs @@ -83,16 +83,16 @@ public async Task GivenSmartConfigurationProvided_WhenHandleCalled_ThenSmartConf GetSmartConfigurationResponse response = await _handler.Handle(new GetSmartConfigurationRequest(), CancellationToken.None); - Assert.Equal("https://localhost:44312/smart/auth", response.AuthorizationEndpoint.AbsoluteUri); - Assert.Equal("https://localhost:44312/smart/token", response.TokenEndpoint.AbsoluteUri); + Assert.Equal("https://testhost:44312/smart/auth", response.AuthorizationEndpoint.AbsoluteUri); + Assert.Equal("https://testhost:44312/smart/token", response.TokenEndpoint.AbsoluteUri); Assert.Equal(capabilities, response.Capabilities); } [Fact] public async Task GivenSmartConfigurationNotProvided_WhenHandleCalled_ThenSmartConfigurationUsingOpenIdReturned() { - string openIdAuthorization = "https://localhost:44312/openid/auth"; - string openIdToken = "https://localhost:44312/openid/token"; + string openIdAuthorization = "https://testhost:44312/openid/auth"; + string openIdToken = "https://testhost:44312/openid/token"; _configurationProvider.GetOpenIdConfigurationAsync(Arg.Any()).Returns(GetOpenIdConfiguration(openIdAuthorization, openIdToken)); @@ -112,8 +112,8 @@ public async Task GivenSmartConfigurationHasNoCapabilities_WhenHandleCalled_Then GetSmartConfigurationResponse response = await _handler.Handle(new GetSmartConfigurationRequest(), CancellationToken.None); - Assert.Equal("https://localhost:44312/smart/auth", response.AuthorizationEndpoint.AbsoluteUri); - Assert.Equal("https://localhost:44312/smart/token", response.TokenEndpoint.AbsoluteUri); + Assert.Equal("https://testhost:44312/smart/auth", response.AuthorizationEndpoint.AbsoluteUri); + Assert.Equal("https://testhost:44312/smart/token", response.TokenEndpoint.AbsoluteUri); Assert.Equal(GetFallbackCapabilities(), response.Capabilities); } @@ -127,9 +127,9 @@ private GetSmartConfigurationResponse GetSmartConfiguration(List capabil return new GetSmartConfigurationResponse( null, null, - new Uri("https://localhost:44312/smart/auth"), + new Uri("https://testhost:44312/smart/auth"), null, - new Uri("https://localhost:44312/smart/token"), + new Uri("https://testhost:44312/smart/token"), null, null, null, diff --git a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/Providers/WellKnownConfigurationProviderTests.cs b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/Providers/WellKnownConfigurationProviderTests.cs index 98d35fcf01..f866dd10f9 100644 --- a/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/Providers/WellKnownConfigurationProviderTests.cs +++ b/src/Microsoft.Health.Fhir.Shared.Core.UnitTests/Features/Conformance/Providers/WellKnownConfigurationProviderTests.cs @@ -35,8 +35,8 @@ public WellKnownConfigurationProviderTests() { _securityConfiguration = new SecurityConfiguration(); _securityConfiguration.Authorization.Enabled = true; - _securityConfiguration.Authentication.Authority = "https://localhost:44312/OAuth2/v2.0"; - _securityConfiguration.SmartAuthentication.Authority = "https://localhost:44312/Smart/OAuth2/v2.0"; + _securityConfiguration.Authentication.Authority = "https://testhost:44312/OAuth2/v2.0"; + _securityConfiguration.SmartAuthentication.Authority = "https://testhost:44312/Smart/OAuth2/v2.0"; _messageHandler = new TestHttpMessageHandler(); _httpClientFactory = Substitute.For(); @@ -198,12 +198,12 @@ private void SetResponseBody(object body, HttpStatusCode code = HttpStatusCode.O private OpenIdConfigurationResponse GetOpenIdConfiguration() { - return new OpenIdConfigurationResponse(new Uri("https://localhost:44312/openid/auth"), new Uri("https://localhost:44312/openid/token")); + return new OpenIdConfigurationResponse(new Uri("https://testhost:44312/openid/auth"), new Uri("https://testhost:44312/openid/token")); } private GetSmartConfigurationResponse GetSmartConfiguration() { - return new GetSmartConfigurationResponse(new Uri("https://localhost:44312/smart/auth"), new Uri("https://localhost:44312/smart/token")); + return new GetSmartConfigurationResponse(new Uri("https://testhost:44312/smart/auth"), new Uri("https://testhost:44312/smart/token")); } internal class TestHttpMessageHandler : DelegatingHandler