public void ShouldSkipAuthOnWrongAuthScheme() { var builder = new AppBuilderFactory().Create(); var context = new OwinContext(); OwinRequest request = (OwinRequest)context.Request; request.Set <Action <Action <object>, object> >("server.OnSendingHeaders", RegisterForOnSendingHeaders); request.Method = "get"; request.SetUri(new Uri("http://example.com:8080/resource/4?filter=a")); request.SetHeader("Authorization", new string[] { "Basic " }); var response = context.Response; var middleware = new HawkAuthenticationMiddleware( new AppFuncTransition((env) => { response.StatusCode = 200; return(Task.FromResult <object>(null)); }), builder, new HawkAuthenticationOptions { Credentials = GetCredential } ); middleware.Invoke(context); Assert.IsNotNull(response); Assert.AreEqual(200, response.StatusCode); }