Package com.sonian.elasticsearch.http.jetty

Examples of com.sonian.elasticsearch.http.jetty.HttpClientResponse.errorCode()


    @SuppressWarnings({"unchecked"})
    @Test
    public void testErrorHandler() throws Exception {
        HttpClientResponse resp = httpClient("server1").request("PUT", "foo/bar/bizzle");
        assertThat(resp.errorCode(), equalTo(HttpURLConnection.HTTP_UNAUTHORIZED));
        assertThat("response body should be error message",
                   resp.get("body").equals("401 Unauthorized /foo/bar/bizzle"));
    }

}
View Full Code Here


        publishAuth("server1", "foo", "MD5:37b51d194a7513e45b56f6524f2d51f2", "pray:readwrite:love"); // password bar
        HttpClient http = httpClient("server1", "foo", "bar");
        String data;
        data = jsonBuilder().startObject().field("blip", 1).endObject().string();
        HttpClientResponse resp = http.request("PUT", "/foo/bar/1", data.getBytes());
        assertThat(resp.errorCode(), equalTo(201));
    }

    @Test
    public void testFail()  throws Exception {
        publishAuth("server1", "foo", "MD5:37b51d194a7513e45b56f6524f2d51f2", "readwrite"); // password bar
View Full Code Here

        publishAuth("server1", "foo", "MD5:37b51d194a7513e45b56f6524f2d51f2", "readwrite"); // password bar
        HttpClient http = httpClient("server1", "foo", "WRONG");
        String data;
        data = jsonBuilder().startObject().field("blip", 1).endObject().string();
        HttpClientResponse resp = http.request("PUT", "/foo/bar/1", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));
    }

    @Test
    public void testTwoUsers()  throws Exception {
        publishAuth("server1", "john", "password1", "readwrite");
View Full Code Here

        String data;
        data = jsonBuilder().startObject().field("blip", 1).endObject().string();

        HttpClient http = httpClient("server1", "john", "password1");
        HttpClientResponse resp = http.request("PUT", "/foo/bar/1", data.getBytes());
        assertThat(resp.errorCode(), equalTo(201));

        http = httpClient("server1", "jane", "password2");
        resp = http.request("PUT", "/foo/bar/2", data.getBytes());
        assertThat(resp.errorCode(), equalTo(201));
View Full Code Here

        HttpClientResponse resp = http.request("PUT", "/foo/bar/1", data.getBytes());
        assertThat(resp.errorCode(), equalTo(201));

        http = httpClient("server1", "jane", "password2");
        resp = http.request("PUT", "/foo/bar/2", data.getBytes());
        assertThat(resp.errorCode(), equalTo(201));

        http = httpClient("server1", "john", "password2");
        resp = http.request("PUT", "/foo/bar/3", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));
View Full Code Here

        resp = http.request("PUT", "/foo/bar/2", data.getBytes());
        assertThat(resp.errorCode(), equalTo(201));

        http = httpClient("server1", "john", "password2");
        resp = http.request("PUT", "/foo/bar/3", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));

        http = httpClient("server1", "jane", "password1");
        resp = http.request("PUT", "/foo/bar/4", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));
View Full Code Here

        resp = http.request("PUT", "/foo/bar/3", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));

        http = httpClient("server1", "jane", "password1");
        resp = http.request("PUT", "/foo/bar/4", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));

        http = httpClient("server1", "JaNe", "password2");
        resp = http.request("PUT", "/foo/bar/4", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));
    }
View Full Code Here

        resp = http.request("PUT", "/foo/bar/4", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));

        http = httpClient("server1", "JaNe", "password2");
        resp = http.request("PUT", "/foo/bar/4", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));
    }

    @Test
    public void testEmptyPassword()  throws Exception {
        publishAuth("server1", "foo", null, "readwrite");
View Full Code Here

        String data;
        data = jsonBuilder().startObject().field("blip", 1).endObject().string();

        HttpClient http = httpClient("server1");
        HttpClientResponse resp = http.request("PUT", "/foo/bar/1", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));

        http = httpClient("server1", "foo", "");
        resp = http.request("PUT", "/foo/bar/1", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));
    }
View Full Code Here

        HttpClientResponse resp = http.request("PUT", "/foo/bar/1", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));

        http = httpClient("server1", "foo", "");
        resp = http.request("PUT", "/foo/bar/1", data.getBytes());
        assertThat(resp.errorCode(), equalTo(401));
    }

    @Test
    public void testEmptyRoles()  throws Exception {
        publishAuth("server1", "foo", "bar", null);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.