diff --git a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/CorsTests.cs b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/CorsTests.cs index c409985cee..06dd8a9099 100644 --- a/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/CorsTests.cs +++ b/test/Microsoft.Health.Fhir.Shared.Tests.E2E/Rest/CorsTests.cs @@ -32,23 +32,24 @@ public CorsTests(HttpIntegrationTestFixture fixture) [Trait(Traits.Priority, Priority.One)] public async Task WhenGettingOptions_GivenAppropriateHeaders_TheServerShouldReturnTheAppropriateCorsHeaders() { - var message = new HttpRequestMessage - { - Method = HttpMethod.Options, - }; + var message = new HttpRequestMessage(HttpMethod.Options, "patient"); message.Headers.Add(HeaderNames.Origin, "https://localhost:6001"); message.Headers.Add(HeaderNames.AccessControlRequestMethod, "PUT"); message.Headers.Add(HeaderNames.AccessControlRequestHeaders, "authorization"); message.Headers.Add(HeaderNames.AccessControlRequestHeaders, "content-type"); - message.RequestUri = new Uri(_client.HttpClient.BaseAddress, "/patient"); HttpResponseMessage response = await _client.HttpClient.SendAsync(message); Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); Assert.Contains("https://localhost:6001", response.Headers.GetValues(HeaderNames.AccessControlAllowOrigin)); - Assert.Contains("PUT", response.Headers.GetValues(HeaderNames.AccessControlAllowMethods)); + var allowMethods = response.Headers.GetValues(HeaderNames.AccessControlAllowMethods); +#pragma warning disable xUnit2012 // Do not use Enumerable.Any() to check if a value exists in a collection + + // The response can be in a single comma separated string, we want to check that it exists in any of them. + Assert.True(allowMethods.Any(x => x.Contains("PUT"))); +#pragma warning restore xUnit2012 // Do not use Enumerable.Any() to check if a value exists in a collection Assert.Contains("authorization,content-type", response.Headers.GetValues(HeaderNames.AccessControlAllowHeaders));