Package com.sonian.elasticsearch.http.jetty

Examples of com.sonian.elasticsearch.http.jetty.HttpClient


    }

    @Test
    public void testSuccess() throws Exception {
        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));
    }
View Full Code Here


    }

    @Test
    public void testFail()  throws Exception {
        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));
    }
View Full Code Here

        publishAuth("server1", "john", "password1", "readwrite");
        publishAuth("server1", "jane", "password2", "readwrite");
        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));

        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));

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

    public void testEmptyPassword()  throws Exception {
        publishAuth("server1", "foo", null, "readwrite");
        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

    public void testEmptyRoles()  throws Exception {
        publishAuth("server1", "foo", "bar", null);
        String data;
        data = jsonBuilder().startObject().field("blip", 1).endObject().string();

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

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

TOP

Related Classes of com.sonian.elasticsearch.http.jetty.HttpClient

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.