From 68eb9646ea18808504e06e1c5ef9c16a53a33aea Mon Sep 17 00:00:00 2001 From: Kristian Hellang Date: Thu, 20 Aug 2015 00:08:14 +0200 Subject: [PATCH] Added asserts to tests --- test/Microsoft.AspNet.Owin.Tests/OwinEnvironmentTests.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.AspNet.Owin.Tests/OwinEnvironmentTests.cs b/test/Microsoft.AspNet.Owin.Tests/OwinEnvironmentTests.cs index 3676fb2941..6cd3e7a844 100644 --- a/test/Microsoft.AspNet.Owin.Tests/OwinEnvironmentTests.cs +++ b/test/Microsoft.AspNet.Owin.Tests/OwinEnvironmentTests.cs @@ -39,7 +39,9 @@ namespace Microsoft.AspNet.Owin IDictionary env = new OwinEnvironment(context); Assert.Equal("SomeMethod", Get(env, "owin.RequestMethod")); + // User property should set both server.User (non-standard) and owin.RequestUser. Assert.Equal("Foo", Get(env, "server.User").Identity.AuthenticationType); + Assert.Equal("Foo", Get(env, "owin.RequestUser").Identity.AuthenticationType); Assert.Same(Stream.Null, Get(env, "owin.RequestBody")); var requestHeaders = Get>(env, "owin.RequestHeaders"); Assert.NotNull(requestHeaders); @@ -65,6 +67,10 @@ namespace Microsoft.AspNet.Owin env["owin.RequestMethod"] = "SomeMethod"; env["server.User"] = new ClaimsPrincipal(new ClaimsIdentity("Foo")); + Assert.Equal("Foo", context.User.Identity.AuthenticationType); + // User property should fall back from owin.RequestUser to server.User. + env["owin.RequestUser"] = new ClaimsPrincipal(new ClaimsIdentity("Bar")); + Assert.Equal("Bar", context.User.Identity.AuthenticationType); env["owin.RequestBody"] = Stream.Null; var requestHeaders = Get>(env, "owin.RequestHeaders"); Assert.NotNull(requestHeaders); @@ -81,7 +87,6 @@ namespace Microsoft.AspNet.Owin env["owin.ResponseStatusCode"] = 201; Assert.Equal("SomeMethod", context.Request.Method); - Assert.Equal("Foo", context.User.Identity.AuthenticationType); Assert.Same(Stream.Null, context.Request.Body); Assert.Equal("CustomRequestValue", context.Request.Headers["CustomRequestHeader"]); Assert.Equal("/path", context.Request.Path.Value);