Esempio n. 1
0
        public void DenyAnonymous_WithoutCredentials_401()
        {
            var denyAnon = new DenyAnonymousMiddleware(SimpleApp);
            IDictionary<string, object> emptyEnv = CreateEmptyRequest();
            denyAnon.Invoke(emptyEnv).Wait();

            Assert.Equal(401, emptyEnv.Get<int>("owin.ResponseStatusCode"));
            var responseHeaders = emptyEnv.Get<IDictionary<string, string[]>>("owin.ResponseHeaders");
            Assert.Equal(0, responseHeaders.Count);
        }
Esempio n. 2
0
        public void DenyAnonymous_WithoutCredentials_401()
        {
            var denyAnon = new DenyAnonymousMiddleware(SimpleApp);
            IDictionary<string, object> emptyEnv = CreateEmptyRequest();
            denyAnon.Invoke(emptyEnv).Wait();

            Assert.Equal(401, emptyEnv.Get<int>("owin.ResponseStatusCode"));
            var responseHeaders = emptyEnv.Get<IDictionary<string, string[]>>("owin.ResponseHeaders");
            Assert.Equal(0, responseHeaders.Count);
        }
Esempio n. 3
0
        public void DenyAnonymous_WithCredentials_PassedThrough()
        {
            var denyAnon = new DenyAnonymousMiddleware(SimpleApp);
            IDictionary<string, object> emptyEnv = CreateEmptyRequest();
            emptyEnv["server.User"] = new GenericPrincipal(new GenericIdentity("bob"), null);
            denyAnon.Invoke(emptyEnv).Wait();

            Assert.Equal(DefaultStatusCode, emptyEnv.Get<int>("owin.ResponseStatusCode"));
            var responseHeaders = emptyEnv.Get<IDictionary<string, string[]>>("owin.ResponseHeaders");
            Assert.Equal(0, responseHeaders.Count);
        }
Esempio n. 4
0
        public void DenyAnonymous_WithCredentials_PassedThrough()
        {
            var denyAnon = new DenyAnonymousMiddleware(SimpleApp);
            IDictionary<string, object> emptyEnv = CreateEmptyRequest();
            emptyEnv["server.User"] = new GenericPrincipal(new GenericIdentity("bob"), null);
            denyAnon.Invoke(emptyEnv).Wait();

            Assert.Equal(DefaultStatusCode, emptyEnv.Get<int>("owin.ResponseStatusCode"));
            var responseHeaders = emptyEnv.Get<IDictionary<string, string[]>>("owin.ResponseHeaders");
            Assert.Equal(0, responseHeaders.Count);
        }