Windows Auth with Microsoft.Owin.Testing.TestServer

I have a Web API application that I am securing with Windows Authentication (it will translate to AD locally in a production environment). I just started adding features that rely on authenticating and / or getting properties of the current user, and I immediately fell on the roadblock: the testing server doesn't seem to be able to authenticate.

How can I make the following test code to send an authenticated request using Windows Authentication?

using (var server = Microsoft.Owin.Testing.TestServer.Create(MyApp.Startup.Configure)) {
    var response = server.HttpClient.GetAsync(url).Result;
    // Assert things about the response



source to share

All Articles