Skip to content

Commit

Permalink
Changed the approach for one integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooja Adhikari committed Dec 11, 2018
1 parent 686b655 commit 3fa99f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
13 changes: 9 additions & 4 deletions test/Microsoft.Health.Fhir.Tests.E2E/Common/FhirClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
14 changes: 7 additions & 7 deletions test/Microsoft.Health.Fhir.Tests.E2E/Rest/BasicAuthTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,30 +144,30 @@ 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<FhirException>(async () => await Client.CreateAsync(Samples.GetDefaultObservation()));
Assert.Equal(UnauthorizedMessage, fhirException.Message);
Assert.Equal(HttpStatusCode.Unauthorized, fhirException.StatusCode);
}

[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<FhirException>(async () => await Client.CreateAsync(Samples.GetDefaultObservation()));
Assert.Equal(UnauthorizedMessage, fhirException.Message);
Assert.Equal(HttpStatusCode.Unauthorized, fhirException.StatusCode);
}

[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<FhirException>(async () => await Client.CreateAsync(Samples.GetDefaultObservation()));
Assert.Equal(UnauthorizedMessage, fhirException.Message);
Assert.Equal(HttpStatusCode.Unauthorized, fhirException.StatusCode);
Expand Down

0 comments on commit 3fa99f8

Please sign in to comment.