Beispiel #1
0
        public void SimpleRequestWithNoMatchingOrigin()
        {
            var           origin   = new AsciiString("http://localhost:8888");
            IHttpResponse response = SimpleRequest(CorsConfigBuilder.ForOrigins(
                                                       new AsciiString("https://localhost:8888")).Build(), origin.ToString());

            Assert.Null(response.Headers.Get(HttpHeaderNames.AccessControlAllowOrigin, null));
            Assert.Null(response.Headers.Get(HttpHeaderNames.AccessControlAllowHeaders, null));
        }
Beispiel #2
0
        public void Origins()
        {
            ICharSequence[] origins = { (StringCharSequence)"http://localhost:7888", (StringCharSequence)"https://localhost:7888" };
            CorsConfig      cors    = CorsConfigBuilder.ForOrigins(origins).Build();

            Assert.Equal(2, cors.Origins.Count);
            Assert.True(cors.Origins.Contains(origins[0]));
            Assert.True(cors.Origins.Contains(origins[1]));
            Assert.False(cors.IsAnyOriginSupported);
        }
Beispiel #3
0
        public void SimpleRequestWithOrigins()
        {
            var origin1 = new AsciiString("http://localhost:8888");
            var origin2 = new AsciiString("https://localhost:8888");

            ICharSequence[] origins   = { origin1, origin2 };
            IHttpResponse   response1 = SimpleRequest(CorsConfigBuilder.ForOrigins(origins).Build(), origin1.ToString());

            Assert.Equal(origin1, response1.Headers.Get(HttpHeaderNames.AccessControlAllowOrigin, null));
            Assert.Null(response1.Headers.Get(HttpHeaderNames.AccessControlAllowHeaders, null));
            IHttpResponse response2 = SimpleRequest(CorsConfigBuilder.ForOrigins(origins).Build(), origin2.ToString());

            Assert.Equal(origin2, response2.Headers.Get(HttpHeaderNames.AccessControlAllowOrigin, null));
            Assert.Null(response2.Headers.Get(HttpHeaderNames.AccessControlAllowHeaders, null));
        }