From 3fa99f8466176ae75cc0f340762deaad835ea801 Mon Sep 17 00:00:00 2001 From: Pooja Adhikari Date: Mon, 10 Dec 2018 16:43:52 -0800 Subject: [PATCH] Changed the approach for one integration test --- .../Common/FhirClient.cs | 13 +++++++++---- .../Rest/BasicAuthTests.cs | 14 +++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/test/Microsoft.Health.Fhir.Tests.E2E/Common/FhirClient.cs b/test/Microsoft.Health.Fhir.Tests.E2E/Common/FhirClient.cs index 0b0f010b7a..db219a169c 100644 --- a/test/Microsoft.Health.Fhir.Tests.E2E/Common/FhirClient.cs +++ b/test/Microsoft.Health.Fhir.Tests.E2E/Common/FhirClient.cs @@ -287,16 +287,21 @@ private async Task SetupAuthenticationAsync(TestApplication clientApplication, T } } - private void ConfigureSecuritySettings(AuthenticationScenarios scnerio) + private void ConfigureSecuritySettings(AuthenticationScenarios authenticationscenario) { - if (scnerio == AuthenticationScenarios.NOAUTH) + if (authenticationscenario == AuthenticationScenarios.NOAUTH) { SecuritySettings = (true, null, null); } - if (scnerio == AuthenticationScenarios.VALIDAUTHWRONGAUTHORITY) + if (authenticationscenario == AuthenticationScenarios.INVALIDAUTH) { - SecuritySettings = (true, SecuritySettings.AuthorizeUrl, null); + SecuritySettings = (true, SecuritySettings.AuthorizeUrl, "invalidtoken"); + } + + if (authenticationscenario == AuthenticationScenarios.VALIDAUTHWRONGAUTHORITY) + { + SecuritySettings = (true, "invalidauthority", SecuritySettings.TokenUrl); } } diff --git a/test/Microsoft.Health.Fhir.Tests.E2E/Rest/BasicAuthTests.cs b/test/Microsoft.Health.Fhir.Tests.E2E/Rest/BasicAuthTests.cs index 480247cf83..2dabd6594d 100644 --- a/test/Microsoft.Health.Fhir.Tests.E2E/Rest/BasicAuthTests.cs +++ b/test/Microsoft.Health.Fhir.Tests.E2E/Rest/BasicAuthTests.cs @@ -144,9 +144,10 @@ public async Task WhenUpdatingAResource_GivenAUserWithUpdatePermissions_TheServe [Fact] [Trait(Traits.Priority, Priority.One)] - public async Task WhenGettingAResource_GivenAUserWithInvalidAuthToken_TheServerShouldReturnUnAuthorized() + public async Task WhenGettingAResource_GivenAUserWithNoAuthToken_TheServerShouldReturnUnAuthorized() { - await Client.RunAsClientApplication(TestApplications.InvalidClient, AuthenticationScenarios.INVALIDAUTH); + await Client.RunAsClientApplication(TestApplications.NativeClient, AuthenticationScenarios.NOAUTH); + FhirException fhirException = await Assert.ThrowsAsync(async () => await Client.CreateAsync(Samples.GetDefaultObservation())); Assert.Equal(UnauthorizedMessage, fhirException.Message); Assert.Equal(HttpStatusCode.Unauthorized, fhirException.StatusCode); @@ -154,9 +155,9 @@ public async Task WhenGettingAResource_GivenAUserWithInvalidAuthToken_TheServerS [Fact] [Trait(Traits.Priority, Priority.One)] - public async Task WhenGettingAResource_GivenAUserWithValidAuthTokenWrongAuthority_TheServerShouldReturnUnAuthorized() + public async Task WhenGettingAResource_GivenAUserWithInvalidAuthToken_TheServerShouldReturnUnAuthorized() { - await Client.RunAsClientApplication(TestApplications.NativeClient, AuthenticationScenarios.VALIDAUTHWRONGAUTHORITY); + await Client.RunAsClientApplication(TestApplications.InvalidClient, AuthenticationScenarios.INVALIDAUTH); FhirException fhirException = await Assert.ThrowsAsync(async () => await Client.CreateAsync(Samples.GetDefaultObservation())); Assert.Equal(UnauthorizedMessage, fhirException.Message); Assert.Equal(HttpStatusCode.Unauthorized, fhirException.StatusCode); @@ -164,10 +165,9 @@ public async Task WhenGettingAResource_GivenAUserWithValidAuthTokenWrongAuthorit [Fact] [Trait(Traits.Priority, Priority.One)] - public async Task WhenGettingAResource_GivenAUserWithNoAuthToken_TheServerShouldReturnUnAuthorized() + public async Task WhenGettingAResource_GivenAUserWithValidAuthTokenWrongAuthority_TheServerShouldReturnUnAuthorized() { - await Client.RunAsClientApplication(TestApplications.NativeClient, AuthenticationScenarios.NOAUTH); - + await Client.RunAsClientApplication(TestApplications.NativeClient, AuthenticationScenarios.VALIDAUTHWRONGAUTHORITY); FhirException fhirException = await Assert.ThrowsAsync(async () => await Client.CreateAsync(Samples.GetDefaultObservation())); Assert.Equal(UnauthorizedMessage, fhirException.Message); Assert.Equal(HttpStatusCode.Unauthorized, fhirException.StatusCode);