Exemple #1
0
        public void TryValidateOrigin_NullResult_Throws()
        {
            CorsEngine corsEngine = new CorsEngine();

            Assert.ThrowsArgumentNull(() =>
                                      corsEngine.TryValidateOrigin(new CorsRequestContext(), new CorsPolicy(), null),
                                      "result");
        }
Exemple #2
0
        public void TryValidateOrigin_DoesCaseSensitiveComparison()
        {
            CorsEngine corsEngine = new CorsEngine();

            CorsPolicy policy = new CorsPolicy();

            policy.Origins.Add("http://Example.com");
            CorsResult result = new CorsResult();

            bool isValid = corsEngine.TryValidateOrigin(new CorsRequestContext {
                Origin = "http://example.com"
            }, policy, result);

            Assert.False(isValid);
            Assert.Equal(1, result.ErrorMessages.Count);
            Assert.Equal("The origin 'http://example.com' is not allowed.", result.ErrorMessages[0]);
        }
        public void TryValidateOrigin_NullResult_Throws()
        {
            CorsEngine corsEngine = new CorsEngine();

            Assert.ThrowsArgumentNull(() =>
                corsEngine.TryValidateOrigin(new CorsRequestContext(), new CorsPolicy(), null),
                "result");
        }
        public void TryValidateOrigin_DoesCaseSensitiveComparison()
        {
            CorsEngine corsEngine = new CorsEngine();

            CorsPolicy policy = new CorsPolicy();
            policy.Origins.Add("http://Example.com");
            CorsResult result = new CorsResult();

            bool isValid = corsEngine.TryValidateOrigin(new CorsRequestContext { Origin = "http://example.com" }, policy, result);
            Assert.False(isValid);
            Assert.Equal(1, result.ErrorMessages.Count);
            Assert.Equal("The origin 'http://example.com' is not allowed.", result.ErrorMessages[0]);
        }