HBASE-9849 [REST] Forbidden schema delete in read only mode (Julian Zhou)
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1541644 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
fe5865d9e3
commit
feca3e26c4
|
@ -236,6 +236,10 @@ public class SchemaResource extends ResourceBase {
|
|||
LOG.debug("DELETE " + uriInfo.getAbsolutePath());
|
||||
}
|
||||
servlet.getMetrics().incrementRequests(1);
|
||||
if (servlet.isReadOnly()) {
|
||||
return Response.status(Response.Status.FORBIDDEN).type(MIMETYPE_TEXT)
|
||||
.entity("Forbidden" + CRLF).build();
|
||||
}
|
||||
try {
|
||||
HBaseAdmin admin = servlet.getAdmin();
|
||||
boolean success = false;
|
||||
|
|
|
@ -123,14 +123,17 @@ public class TestSchemaResource {
|
|||
model = testTableSchemaModel.fromJSON(Bytes.toString(response.getBody()));
|
||||
testTableSchemaModel.checkModel(model, TABLE1);
|
||||
|
||||
// delete the table
|
||||
client.delete(schemaPath);
|
||||
|
||||
// make sure HBase concurs
|
||||
assertFalse(admin.tableExists(TABLE1));
|
||||
// test delete schema operation is forbidden in read-only mode
|
||||
response = client.delete(schemaPath);
|
||||
assertEquals(response.getCode(), 403);
|
||||
|
||||
// return read-only setting back to default
|
||||
conf.set("hbase.rest.readonly", "false");
|
||||
|
||||
// delete the table and make sure HBase concurs
|
||||
response = client.delete(schemaPath);
|
||||
assertEquals(response.getCode(), 200);
|
||||
assertFalse(admin.tableExists(TABLE1));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -171,14 +174,17 @@ public class TestSchemaResource {
|
|||
model.getObjectFromMessage(response.getBody());
|
||||
testTableSchemaModel.checkModel(model, TABLE2);
|
||||
|
||||
// delete the table
|
||||
client.delete(schemaPath);
|
||||
|
||||
// make sure HBase concurs
|
||||
assertFalse(admin.tableExists(TABLE2));
|
||||
// test delete schema operation is forbidden in read-only mode
|
||||
response = client.delete(schemaPath);
|
||||
assertEquals(response.getCode(), 403);
|
||||
|
||||
// return read-only setting back to default
|
||||
conf.set("hbase.rest.readonly", "false");
|
||||
|
||||
// delete the table and make sure HBase concurs
|
||||
response = client.delete(schemaPath);
|
||||
assertEquals(response.getCode(), 200);
|
||||
assertFalse(admin.tableExists(TABLE2));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue