vendredi 24 juillet 2015

Windows Auth with Microsoft.Owin.Testing.TestServer

I have a Web API application which I'm protecting with Windows Authentication (locally, it'll translate to AD in the production environment). I just started adding features that rely on authentication and/or getting properties of the current user, and I immediately fell on a road block: the testing server doesn't seem able to authenticate.

How can I make the following test code 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
}

Aucun commentaire:

Enregistrer un commentaire