public virtual async Task NotMatch_SingleParameter(string path)
        {
            // Arrange
            var(matcher, endpoint) = CreateMatcher("/{p}");
            var httpContext = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext);

            // Assert
            MatcherAssert.AssertNotMatch(httpContext);
        }
        public virtual async Task NotMatch_MultipleParameters(string template, string path)
        {
            // Arrange
            var(matcher, endpoint) = CreateMatcher(template);
            var httpContext = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext);

            // Assert
            MatcherAssert.AssertNotMatch(httpContext);
        }
Exemplo n.º 3
0
        public virtual async Task NotMatch_MultipleLiteralSegments(string template, string path)
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher(template);
            var(httpContext, feature) = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            MatcherAssert.AssertNotMatch(feature);
        }
        public virtual async Task NotMatch_SingleLiteralSegment(string path)
        {
            // Arrange
            var(matcher, endpoint) = CreateMatcher("/simple");
            var httpContext = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext);

            // Assert
            MatcherAssert.AssertNotMatch(httpContext);
        }
Exemplo n.º 5
0
        public virtual async Task NotMatch_OptionalSeparator(string template, string path)
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher(template);
            var(httpContext, feature) = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext, feature);

            // Assert
            MatcherAssert.AssertNotMatch(feature);
        }
        public virtual async Task NotMatch_DefaultValues(string template, string path)
        {
            // Arrange
            var(matcher, endpoint)    = CreateMatcher(template);
            var(httpContext, context) = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext, context);

            // Assert
            MatcherAssert.AssertNotMatch(context, httpContext);
        }
        public async Task Match_HostWithPort_IncorrectHost()
        {
            // Arrange
            var endpoint = CreateEndpoint("/hello", hosts: new string[] { "contoso.com:8080", });

            var matcher     = CreateMatcher(endpoint);
            var httpContext = CreateContext("/hello", "www.contoso.com:8080");

            // Act
            await matcher.MatchAsync(httpContext);

            // Assert
            MatcherAssert.AssertNotMatch(httpContext);
        }
        public async Task Match_HostWithPort_NoHostHeader()
        {
            // Arrange
            var endpoint = CreateEndpoint("/hello", hosts: new string[] { "contoso.com:443", });

            var matcher     = CreateMatcher(endpoint);
            var httpContext = CreateContext("/hello", null, "https");

            // Act
            await matcher.MatchAsync(httpContext);

            // Assert
            MatcherAssert.AssertNotMatch(httpContext);
        }
        public async Task Match_HostWithWildcard_PrefixNotInSubdomain()
        {
            // Arrange
            var endpoint = CreateEndpoint("/hello", hosts: new string[] { "*.contoso.com:8080", });

            var matcher     = CreateMatcher(endpoint);
            var httpContext = CreateContext("/hello", "mycontoso.com:8080");

            // Act
            await matcher.MatchAsync(httpContext);

            // Assert
            MatcherAssert.AssertNotMatch(httpContext);
        }
Exemplo n.º 10
0
        public async Task Match_CatchAllRouteFailureHost_NoMatch()
        {
            // Arrange
            var endpoint = CreateEndpoint("/{**path}", hosts: new string[] { "contoso.com", });

            var matcher     = CreateMatcher(endpoint);
            var httpContext = CreateContext("/hello", "nomatch.com");

            // Act
            await matcher.MatchAsync(httpContext);

            // Assert
            MatcherAssert.AssertNotMatch(httpContext);
        }
        [Fact] // When one of the candidates handles all verbs, dont use a 405 endpoint
        public async Task NotMatch_HttpMethod_WithAllMethodEndpoint_DoesNotReturn405()
        {
            // Arrange
            var endpoint1 = CreateEndpoint("/{x:int}", httpMethods: new string[] { });
            var endpoint2 = CreateEndpoint("/hello", httpMethods: new string[] { "DELETE" });

            var matcher     = CreateMatcher(endpoint1, endpoint2);
            var httpContext = CreateContext("/hello", "POST");

            // Act
            await matcher.MatchAsync(httpContext);

            // Assert
            MatcherAssert.AssertNotMatch(httpContext);
        }
        public async Task NotMatch_HttpMethod_CORS_DoesNotReturn405()
        {
            // Arrange
            var endpoint1 = CreateEndpoint("/hello", httpMethods: new string[] { "GET", "PUT" }, acceptCorsPreflight: true);
            var endpoint2 = CreateEndpoint("/hello", httpMethods: new string[] { "DELETE" });

            var matcher     = CreateMatcher(endpoint1, endpoint2);
            var httpContext = CreateContext("/hello", "POST", corsPreflight: true);

            // Act
            await matcher.MatchAsync(httpContext);

            // Assert
            MatcherAssert.AssertNotMatch(httpContext);
        }
        public virtual async Task Quirks_CatchAllParameter(string template, string path, string[] keys, string[] values)
        {
            // Arrange
            var(matcher, endpoint) = CreateMatcher(template);
            var httpContext = CreateContext(path);

            // Act
            await matcher.MatchAsync(httpContext);

            // Assert
            MatcherAssert.AssertNotMatch(httpContext);

            // Need to access these to prevent a warning from the xUnit analyzer.
            // Some of these tests will match (and process the values) and some will not.
            GC.KeepAlive(keys);
            GC.KeepAlive(values);
        }