Ejemplo n.º 1
0
        public async Task Returns_Delegated_StatusCode_When_Request_Is_Over_HTTPS()
        {
            // Arrange
            var request = new HttpRequestMessage(HttpMethod.Get, "https://localhost:8080");
            var requireHttpsMessageHandler = new RequireHttpsMessageHandler();

            // Act
            var response = await requireHttpsMessageHandler.InvokeAsync(request);

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
Ejemplo n.º 2
0
        public async Task Returns_Forbidden_If_Request_Is_Not_Over_HTTPS()
        {
            // Arange
            var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:8080");
            var requireHtttpsMessageHandler = new RequireHttpsMessageHandler();

            // Act
            var response = await requireHtttpsMessageHandler.InvokeAsync(request);

            // Assert
            Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode);
        }
Ejemplo n.º 3
0
        public async Task Returns_Forbidden_If_Request_Is_Not_Over_HTTPS()
        {
            // 准备
            var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost:8080");
            var requireHtttpsMessageHandler = new RequireHttpsMessageHandler();

            // 动作
            var response = await requireHtttpsMessageHandler.InvokeAsync(request);

            // 断言
            Assert.AreEqual(HttpStatusCode.Forbidden, response.StatusCode);
            Console.WriteLine(response.ReasonPhrase);
        }