Ejemplo n.º 1
0
        public void TryValidateMethod_NullResult_Throws()
        {
            CorsEngine corsEngine = new CorsEngine();

            Assert.ThrowsArgumentNull(() =>
                                      corsEngine.TryValidateMethod(new CorsRequestContext(), new CorsPolicy(), null),
                                      "result");
        }
Ejemplo n.º 2
0
        public void TryValidateMethod_DoesCaseSensitiveComparison()
        {
            CorsEngine corsEngine = new CorsEngine();

            CorsPolicy policy = new CorsPolicy();

            policy.Methods.Add("POST");
            CorsResult result = new CorsResult();

            bool isValid = corsEngine.TryValidateMethod(new CorsRequestContext {
                AccessControlRequestMethod = "post"
            }, policy, result);

            Assert.False(isValid);
            Assert.Equal(1, result.ErrorMessages.Count);
            Assert.Equal("The method 'post' is not allowed.", result.ErrorMessages[0]);
        }
        public void TryValidateMethod_NullResult_Throws()
        {
            CorsEngine corsEngine = new CorsEngine();

            Assert.ThrowsArgumentNull(() =>
                corsEngine.TryValidateMethod(new CorsRequestContext(), new CorsPolicy(), null),
                "result");
        }
Ejemplo n.º 4
0
        public void TryValidateMethod_DoesCaseSensitiveComparison()
        {
            CorsEngine corsEngine = new CorsEngine();

            CorsPolicy policy = new CorsPolicy();
            policy.Methods.Add("POST");
            CorsResult result = new CorsResult();

            bool isValid = corsEngine.TryValidateMethod(new CorsRequestContext { AccessControlRequestMethod = "post" }, policy, result);
            Assert.False(isValid);
            Assert.Equal(1, result.ErrorMessages.Count);
            Assert.Equal("The method 'post' is not allowed.", result.ErrorMessages[0]);
        }