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)); }
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); }
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)); }