Reputation: 4786
I recently started using Aspire and am now migrating my Integration Tests that use WebApplicationFactory to an Aspire.Host.Testing approach based on this article
With WebApplicationFactory I'm creating a HttpClient from the CreateClient of WebApplicationFactory and I'm adding the Auth Headers like this:
var client = webApplicationFactory.CreateClient();
client.DefaultRequestHeaders.Add("Authorization", BasicAuthValue);
var response = await client.GetAsync(requestUri)
I've tried to do a similar thing using DistributedApplicationTestingBuilder
var client = distributedApplication.CreateHttpClient("myWebApp");
client.DefaultRequestHeaders.Add("Authorization", BasicAuthValue);
var response = await client.GetAsync(requestUri)
However, unlike with WebApplicationFactory, the Authentication Header seems to have been removed from the request, and when it hits my WebApp, it's just not there.
Upvotes: 0
Views: 45