Package com.github.kevinsawicki.http

Examples of com.github.kevinsawicki.http.HttpRequest$RequestOutputStream


        assertHttpResponse(client().GET("/api/cors/1"), 200, "CORS1");
    }

    @Test
    public void should_handle_good_origin_on_get() throws Exception {
        HttpRequest httpRequest = client().GET("/api/cors/1").header("Origin", "http://localhost:9000");
        assertHttpResponse(httpRequest, 200, "CORS1");
        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo("http://localhost:9000");
    }
View Full Code Here


        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo("http://localhost:9000");
    }

    @Test
    public void should_handle_good_origin_on_post() throws Exception {
        HttpRequest httpRequest = client().POST("/api/cors/1").header("Origin", "http://localhost:9000").send("{}");
        assertHttpResponse(httpRequest, 200, "CORS1");
        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo("http://localhost:9000");
    }
View Full Code Here

        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo("http://localhost:9000");
    }

    @Test
    public void should_reject_invalid_origin_on_get() throws Exception {
        HttpRequest httpRequest = client().GET("/api/cors/1").header("Origin", "http://localhost:80");
        assertHttpResponse(httpRequest, 403, "");
    }
View Full Code Here

        assertHttpResponse(httpRequest, 403, "");
    }

    @Test
    public void should_accept_same_origin_on_get() throws Exception {
        HttpRequest httpRequest = client().GET("/api/cors/1")
                .header("Origin", server.getServer().baseUrl());
        assertHttpResponse(httpRequest, 200, "CORS1");
    }
View Full Code Here

        assertHttpResponse(httpRequest, 200, "CORS1");
    }

    @Test
    public void should_reject_invalid_origin_on_post() throws Exception {
        HttpRequest httpRequest = client().POST("/api/cors/1").header("Origin", "http://localhost:80").send("{}");
        assertHttpResponse(httpRequest, 403, "");
    }
View Full Code Here

        assertHttpResponse(httpRequest, 403, "");
    }

    @Test
    public void should_reject_head_on_cors1() throws Exception {
        HttpRequest httpRequest = client().HEAD("/api/cors/1").header("Origin", "http://localhost:9000");
        assertHttpResponse(httpRequest, 403, "");
    }
View Full Code Here

    @ClassRule
    public static RestxServerRule server = new RestxServerRule();

    @Test
    public void should_return_path_params() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/params/path/v1/v2/35v4");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("a=v1 b=v2 c=35 d=v4");
    }
View Full Code Here

        assertHttpResponse(httpRequest, 403, "");
    }

    @Test
    public void should_handle_any_origin_on_get() throws Exception {
        HttpRequest httpRequest = client().GET("/api/cors/2").header("Origin", randomOrigin);
        assertHttpResponse(httpRequest, 200, "CORS2");
        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo(randomOrigin);
    }
View Full Code Here

        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo(randomOrigin);
    }

    @Test
    public void should_handle_any_origin_on_post() throws Exception {
        HttpRequest httpRequest = client().POST("/api/cors/2").header("Origin", randomOrigin).send("{}");
        assertHttpResponse(httpRequest, 200, "CORS2");
        assertThat(httpRequest.header("Access-Control-Allow-Origin")).isEqualTo(randomOrigin);
    }
View Full Code Here

        assertThat(httpRequest.body().trim()).isEqualTo("a=v1 b=v2 c=35 d=v4");
    }

    @Test
    public void should_return_query_params() throws Exception {
        HttpRequest httpRequest = server.client().authenticatedAs("admin").GET(
                "/api/params/query/1?a=v1&b=v2");
        assertThat(httpRequest.code()).isEqualTo(200);
        assertThat(httpRequest.body().trim()).isEqualTo("a=v1 b=v2");
    }
View Full Code Here

TOP

Related Classes of com.github.kevinsawicki.http.HttpRequest$RequestOutputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.