Skip to content

Commit

Permalink
Fix failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate Malubay committed Feb 10, 2024
1 parent 55d6fe2 commit e1b5d68
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<CancellationToken>()).Returns(GetOpenIdConfiguration(auth, token));
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<CancellationToken>()).Returns(GetOpenIdConfiguration(openIdAuthorization, openIdToken));

Expand All @@ -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);
}

Expand All @@ -127,9 +127,9 @@ private GetSmartConfigurationResponse GetSmartConfiguration(List<string> 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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IHttpClientFactory>();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e1b5d68

Please sign in to comment.