Search in sources :

Example 21 with Client

use of org.apache.hadoop.hbase.rest.client.Client in project hbase by apache.

the class TestSecurityHeadersFilter method testHstsAndCspSettings.

@Test
public void testHstsAndCspSettings() throws Exception {
    TEST_UTIL.getConfiguration().set("hbase.http.filter.hsts.value", "max-age=63072000;includeSubDomains;preload");
    TEST_UTIL.getConfiguration().set("hbase.http.filter.csp.value", "default-src https: data: 'unsafe-inline' 'unsafe-eval'");
    TEST_UTIL.startMiniCluster();
    REST_TEST_UTIL.startServletContainer(TEST_UTIL.getConfiguration());
    client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort()));
    String path = "/version/cluster";
    Response response = client.get(path);
    assertThat(response.getCode(), equalTo(200));
    assertThat("Header 'Strict-Transport-Security' is missing from Rest response", response.getHeader("Strict-Transport-Security"), is(not((String) null)));
    assertThat("Header 'Strict-Transport-Security' has invalid value", response.getHeader("Strict-Transport-Security"), equalTo("max-age=63072000;includeSubDomains;preload"));
    assertThat("Header 'Content-Security-Policy' is missing from Rest response", response.getHeader("Content-Security-Policy"), is(not((String) null)));
    assertThat("Header 'Content-Security-Policy' has invalid value", response.getHeader("Content-Security-Policy"), equalTo("default-src https: data: 'unsafe-inline' 'unsafe-eval'"));
}
Also used : Response(org.apache.hadoop.hbase.rest.client.Response) Cluster(org.apache.hadoop.hbase.rest.client.Cluster) Client(org.apache.hadoop.hbase.rest.client.Client) Test(org.junit.Test)

Aggregations

Client (org.apache.hadoop.hbase.rest.client.Client)21 Cluster (org.apache.hadoop.hbase.rest.client.Cluster)19 BeforeClass (org.junit.BeforeClass)14 Admin (org.apache.hadoop.hbase.client.Admin)6 ColumnFamilyDescriptor (org.apache.hadoop.hbase.client.ColumnFamilyDescriptor)5 TableDescriptorBuilder (org.apache.hadoop.hbase.client.TableDescriptorBuilder)5 CellModel (org.apache.hadoop.hbase.rest.model.CellModel)5 CellSetModel (org.apache.hadoop.hbase.rest.model.CellSetModel)5 RowModel (org.apache.hadoop.hbase.rest.model.RowModel)5 ScannerModel (org.apache.hadoop.hbase.rest.model.ScannerModel)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 Put (org.apache.hadoop.hbase.client.Put)2 Table (org.apache.hadoop.hbase.client.Table)2 RemoteAdmin (org.apache.hadoop.hbase.rest.client.RemoteAdmin)2 Response (org.apache.hadoop.hbase.rest.client.Response)2 TableListModel (org.apache.hadoop.hbase.rest.model.TableListModel)2 JacksonJaxbJsonProvider (org.apache.hbase.thirdparty.com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider)2 BasicHeader (org.apache.http.message.BasicHeader)2 ArrayList (java.util.ArrayList)1