Java Code Examples for org.apache.hadoop.hbase.coprocessor.ObserverContextImpl

The following examples show how to use org.apache.hadoop.hbase.coprocessor.ObserverContextImpl. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: hbase   Source File: TestWithDisabledAuthorization.java    License: Apache License 2.0 6 votes vote down vote up
/** Test region server observer */
@Test
public void testPassiveRegionServerOperations() throws Exception {
  // preStopRegionServer
  verifyAllowed(new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preStopRegionServer(ObserverContextImpl.createAndPrepare(RSCP_ENV));
      return null;
    }
  }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE);

  // preRollWALWriterRequest
  verifyAllowed(new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preRollWALWriterRequest(ObserverContextImpl.createAndPrepare(RSCP_ENV));
      return null;
    }
  }, SUPERUSER, USER_ADMIN, USER_RW, USER_RO, USER_OWNER, USER_CREATE, USER_QUAL, USER_NONE);

}
 
Example 2
Source Project: hbase   Source File: TestAccessController3.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testTableCreate() throws Exception {
  AccessTestAction createTable = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
        new TableDescriptorBuilder.ModifyableTableDescriptor(
          TableName.valueOf(name.getMethodName()));
      tableDescriptor.setColumnFamily(
        new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(TEST_FAMILY));
      ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV),
        tableDescriptor, null);
      return null;
    }
  };

  // verify that superuser can create tables
  verifyAllowed(createTable, SUPERUSER, USER_ADMIN, USER_GROUP_CREATE, USER_GROUP_ADMIN);

  // all others should be denied
  verifyDenied(createTable, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE);
}
 
Example 3
Source Project: hbase   Source File: TestNamespaceCommands.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testModifyNamespace() throws Exception {
  AccessTestAction modifyNamespace = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preModifyNamespace(ObserverContextImpl.createAndPrepare(CP_ENV),
        null, // not needed by AccessController
        NamespaceDescriptor.create(TEST_NAMESPACE).addConfiguration("abc", "156").build());
      return null;
    }
  };

  // modifyNamespace: superuser | global(A) | NS(A)
  verifyAllowed(modifyNamespace, SUPERUSER, USER_GLOBAL_ADMIN, USER_GROUP_ADMIN);
  verifyDenied(modifyNamespace, USER_GLOBAL_CREATE, USER_GLOBAL_WRITE, USER_GLOBAL_READ,
    USER_GLOBAL_EXEC, USER_NS_ADMIN, USER_NS_CREATE, USER_NS_WRITE, USER_NS_READ, USER_NS_EXEC,
    USER_GROUP_READ, USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 4
Source Project: hbase   Source File: TestNamespaceCommands.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGetNamespaceDescriptor() throws Exception {
  AccessTestAction getNamespaceAction = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preGetNamespaceDescriptor(ObserverContextImpl.createAndPrepare(CP_ENV),
        TEST_NAMESPACE);
      return null;
    }
  };
  // getNamespaceDescriptor : superuser | global(A) | NS(A)
  verifyAllowed(getNamespaceAction, SUPERUSER, USER_GLOBAL_ADMIN, USER_NS_ADMIN,
    USER_GROUP_ADMIN);
  verifyDenied(getNamespaceAction, USER_GLOBAL_CREATE, USER_GLOBAL_WRITE, USER_GLOBAL_READ,
    USER_GLOBAL_EXEC, USER_NS_CREATE, USER_NS_WRITE, USER_NS_READ, USER_NS_EXEC,
    USER_TABLE_CREATE, USER_TABLE_WRITE, USER_GROUP_READ, USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 5
Source Project: hbase   Source File: TestNamespaceCommands.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCreateTableWithNamespace() throws Exception {
  AccessTestAction createTable = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
        new TableDescriptorBuilder.ModifyableTableDescriptor(TableName.valueOf(TEST_TABLE));
      tableDescriptor.setColumnFamily(
        new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(TEST_FAMILY));
      ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV),
        tableDescriptor, null);
      return null;
    }
  };

  //createTable            : superuser | global(AC) | NS(AC)
  verifyAllowed(createTable, SUPERUSER, USER_GLOBAL_CREATE, USER_NS_CREATE, USER_GROUP_CREATE,
    USER_GLOBAL_ADMIN, USER_NS_ADMIN, USER_GROUP_ADMIN);
  verifyDenied(createTable, USER_GLOBAL_WRITE, USER_GLOBAL_READ, USER_GLOBAL_EXEC,
    USER_NS_WRITE, USER_NS_READ, USER_NS_EXEC, USER_TABLE_CREATE, USER_TABLE_WRITE,
    USER_GROUP_READ, USER_GROUP_WRITE);
}
 
Example 6
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testTableCreate() throws Exception {
  AccessTestAction createTable = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      TableDescriptorBuilder.ModifyableTableDescriptor tableDescriptor =
        new TableDescriptorBuilder.ModifyableTableDescriptor(
          TableName.valueOf(name.getMethodName()));
      tableDescriptor.setColumnFamily(
        new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(TEST_FAMILY));
      ACCESS_CONTROLLER.preCreateTable(ObserverContextImpl.createAndPrepare(CP_ENV),
        tableDescriptor, null);
      return null;
    }
  };

  // verify that superuser can create tables
  verifyAllowed(createTable, SUPERUSER, USER_ADMIN, USER_GROUP_CREATE, USER_GROUP_ADMIN);

  // all others should be denied
  verifyDenied(createTable, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE);
}
 
Example 7
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testTableModify() throws Exception {
  AccessTestAction modifyTable = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      TableDescriptorBuilder tableDescriptorBuilder =
        TableDescriptorBuilder.newBuilder(TEST_TABLE);
      ColumnFamilyDescriptor columnFamilyDescriptor =
        ColumnFamilyDescriptorBuilder.newBuilder(TEST_FAMILY).build();
      tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
      columnFamilyDescriptor = ColumnFamilyDescriptorBuilder
        .newBuilder(Bytes.toBytes("fam_" + User.getCurrent().getShortName())).build();
      tableDescriptorBuilder.setColumnFamily(columnFamilyDescriptor);
      ACCESS_CONTROLLER.preModifyTable(ObserverContextImpl.createAndPrepare(CP_ENV),
          TEST_TABLE,
          null,  // not needed by AccessController
          tableDescriptorBuilder.build());
      return null;
    }
  };

  verifyAllowed(modifyTable, SUPERUSER, USER_ADMIN, USER_CREATE, USER_OWNER, USER_GROUP_CREATE,
    USER_GROUP_ADMIN);
  verifyDenied(modifyTable, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ, USER_GROUP_WRITE);
}
 
Example 8
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testTableTruncate() throws Exception {
  AccessTestAction truncateTable = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER
          .preTruncateTable(ObserverContextImpl.createAndPrepare(CP_ENV),
            TEST_TABLE);
      return null;
    }
  };

  verifyAllowed(truncateTable, SUPERUSER, USER_ADMIN, USER_CREATE, USER_OWNER, USER_GROUP_CREATE,
    USER_GROUP_ADMIN);
  verifyDenied(truncateTable, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ, USER_GROUP_WRITE);
}
 
Example 9
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testGetProcedures() throws Exception {
  final TableName tableName = TableName.valueOf(name.getMethodName());
  final ProcedureExecutor<MasterProcedureEnv> procExec =
      TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor();
  Procedure proc = new TestTableDDLProcedure(procExec.getEnvironment(), tableName);
  proc.setOwner(USER_OWNER);
  procExec.submitProcedure(proc);
  final List<Procedure<MasterProcedureEnv>> procList = procExec.getProcedures();

  AccessTestAction getProceduresAction = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER
      .postGetProcedures(ObserverContextImpl.createAndPrepare(CP_ENV));
     return null;
    }
  };

  verifyAllowed(getProceduresAction, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
  verifyAllowed(getProceduresAction, USER_OWNER);
  verifyIfNull(
    getProceduresAction, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ, USER_GROUP_WRITE);
}
 
Example 10
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMove() throws Exception {
  List<HRegionLocation> regions;
  try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) {
    regions = locator.getAllRegionLocations();
  }
  HRegionLocation location = regions.get(0);
  final RegionInfo hri = location.getRegion();
  final ServerName server = location.getServerName();
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preMove(ObserverContextImpl.createAndPrepare(CP_ENV),
        hri, server, server);
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 11
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testAssign() throws Exception {
  List<HRegionLocation> regions;
  try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) {
    regions = locator.getAllRegionLocations();
  }
  HRegionLocation location = regions.get(0);
  final RegionInfo hri = location.getRegion();
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preAssign(ObserverContextImpl.createAndPrepare(CP_ENV), hri);
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 12
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testUnassign() throws Exception {
  List<HRegionLocation> regions;
  try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) {
    regions = locator.getAllRegionLocations();
  }
  HRegionLocation location = regions.get(0);
  final RegionInfo hri = location.getRegion();
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preUnassign(ObserverContextImpl.createAndPrepare(CP_ENV), hri, false);
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 13
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testRegionOffline() throws Exception {
  List<HRegionLocation> regions;
  try (RegionLocator locator = systemUserConnection.getRegionLocator(TEST_TABLE)) {
    regions = locator.getAllRegionLocations();
  }
  HRegionLocation location = regions.get(0);
  final RegionInfo hri = location.getRegion();
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preRegionOffline(ObserverContextImpl.createAndPrepare(CP_ENV), hri);
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 14
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testSplitWithSplitRow() throws Exception {
  final TableName tableName = TableName.valueOf(name.getMethodName());
  createTestTable(tableName);
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preSplitRegion(
          ObserverContextImpl.createAndPrepare(CP_ENV),
          tableName,
          TEST_ROW);
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
      USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 15
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testPrepareAndCleanBulkLoad() throws Exception {
  AccessTestAction prepareBulkLoadAction = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.prePrepareBulkLoad(ObserverContextImpl.createAndPrepare(RCP_ENV));
      return null;
    }
  };
  AccessTestAction cleanupBulkLoadAction = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preCleanupBulkLoad(ObserverContextImpl.createAndPrepare(RCP_ENV));
      return null;
    }
  };
  verifyAnyCreate(prepareBulkLoadAction);
  verifyAnyCreate(cleanupBulkLoadAction);
}
 
Example 16
private static ObserverContext<RegionCoprocessorEnvironment> mockRegionEnv(byte[] startKey, byte[] endKey) {
    HRegionInfo mockRInfo = mock(HRegionInfo.class);
    when(mockRInfo.getRegionNameAsString()).thenReturn(REGION_NAME);
    when(mockRInfo.getStartKey()).thenReturn(startKey);
    when(mockRInfo.getEndKey()).thenReturn(endKey);

    /*
    ConsistencyControl mockCC = mock(ConsistencyControl.class);
    when(mockCC.memstoreReadPoint()).thenReturn(1313L);
    */
    HRegion mockRegion = mock(HRegion.class);
    when(mockRegion.getRegionInfo()).thenReturn(mockRInfo);

    RegionCoprocessorEnvironment mockEnv = mock(RegionCoprocessorEnvironment.class);
    when(mockEnv.getRegion()).thenReturn(mockRegion);
    when(mockEnv.getRegionInfo()).thenReturn(mockRInfo);
    ObserverContextImpl<RegionCoprocessorEnvironment> fakeCtx = new ObserverContextImpl<RegionCoprocessorEnvironment>(null);
    fakeCtx.prepare(mockEnv);
    return fakeCtx;
}
 
Example 17
Source Project: hbase   Source File: TestNamespaceCommands.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateAndDeleteNamespace() throws Exception {
  AccessTestAction createNamespace = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preCreateNamespace(ObserverContextImpl.createAndPrepare(CP_ENV),
        NamespaceDescriptor.create(TEST_NAMESPACE2).build());
      return null;
    }
  };

  AccessTestAction deleteNamespace = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preDeleteNamespace(ObserverContextImpl.createAndPrepare(CP_ENV),
        TEST_NAMESPACE2);
      return null;
    }
  };

  // createNamespace: superuser | global(A)
  verifyAllowed(createNamespace, SUPERUSER, USER_GLOBAL_ADMIN, USER_GROUP_ADMIN);
  // all others should be denied
  verifyDenied(createNamespace, USER_GLOBAL_CREATE, USER_GLOBAL_WRITE, USER_GLOBAL_READ,
    USER_GLOBAL_EXEC, USER_NS_ADMIN, USER_NS_CREATE, USER_NS_WRITE, USER_NS_READ, USER_NS_EXEC,
    USER_TABLE_CREATE, USER_TABLE_WRITE, USER_GROUP_READ, USER_GROUP_WRITE, USER_GROUP_CREATE);

  // deleteNamespace: superuser | global(A) | NS(A)
  verifyAllowed(deleteNamespace, SUPERUSER, USER_GLOBAL_ADMIN, USER_GROUP_ADMIN);
  verifyDenied(deleteNamespace, USER_GLOBAL_CREATE, USER_GLOBAL_WRITE, USER_GLOBAL_READ,
    USER_GLOBAL_EXEC, USER_NS_ADMIN, USER_NS_CREATE, USER_NS_WRITE, USER_NS_READ, USER_NS_EXEC,
    USER_TABLE_CREATE, USER_TABLE_WRITE, USER_GROUP_READ, USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 18
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testTableDelete() throws Exception {
  AccessTestAction deleteTable = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER
          .preDeleteTable(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_TABLE);
      return null;
    }
  };

  verifyAllowed(deleteTable, SUPERUSER, USER_ADMIN, USER_CREATE, USER_OWNER, USER_GROUP_CREATE,
    USER_GROUP_ADMIN);
  verifyDenied(deleteTable, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ, USER_GROUP_WRITE);
}
 
Example 19
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testTableDisable() throws Exception {
  AccessTestAction disableTable = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preDisableTable(ObserverContextImpl.createAndPrepare(CP_ENV),
        TEST_TABLE);
      return null;
    }
  };

  AccessTestAction disableAclTable = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preDisableTable(ObserverContextImpl.createAndPrepare(CP_ENV),
        PermissionStorage.ACL_TABLE_NAME);
      return null;
    }
  };

  verifyAllowed(disableTable, SUPERUSER, USER_ADMIN, USER_CREATE, USER_OWNER, USER_GROUP_CREATE,
    USER_GROUP_ADMIN);
  verifyDenied(disableTable, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ, USER_GROUP_WRITE);

  // No user should be allowed to disable _acl_ table
  verifyDenied(disableAclTable, SUPERUSER, USER_ADMIN, USER_CREATE, USER_OWNER, USER_RW, USER_RO,
    USER_GROUP_CREATE, USER_GROUP_ADMIN, USER_GROUP_READ, USER_GROUP_WRITE);
}
 
Example 20
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testTableEnable() throws Exception {
  AccessTestAction enableTable = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER
          .preEnableTable(ObserverContextImpl.createAndPrepare(CP_ENV), TEST_TABLE);
      return null;
    }
  };

  verifyAllowed(enableTable, SUPERUSER, USER_ADMIN, USER_CREATE, USER_OWNER, USER_GROUP_CREATE,
    USER_GROUP_ADMIN);
  verifyDenied(enableTable, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ, USER_GROUP_WRITE);
}
 
Example 21
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testAbortProcedure() throws Exception {
  long procId = 1;
  AccessTestAction abortProcedureAction = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preAbortProcedure(ObserverContextImpl.createAndPrepare(CP_ENV), procId);
     return null;
    }
  };

  verifyAllowed(abortProcedureAction, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
}
 
Example 22
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testGetLocks() throws Exception {
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preGetLocks(ObserverContextImpl.createAndPrepare(CP_ENV));
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE,
    USER_GROUP_READ, USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 23
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSetSplitOrMergeEnabled() throws Exception {
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preSetSplitOrMergeEnabled(ObserverContextImpl.createAndPrepare(CP_ENV),
        true, MasterSwitchType.MERGE);
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 24
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testBalance() throws Exception {
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preBalance(ObserverContextImpl.createAndPrepare(CP_ENV));
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 25
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testBalanceSwitch() throws Exception {
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preBalanceSwitch(ObserverContextImpl.createAndPrepare(CP_ENV), true);
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 26
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testShutdown() throws Exception {
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preShutdown(ObserverContextImpl.createAndPrepare(CP_ENV));
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 27
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testStopMaster() throws Exception {
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preStopMaster(ObserverContextImpl.createAndPrepare(CP_ENV));
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}
 
Example 28
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testFlush() throws Exception {
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preFlush(ObserverContextImpl.createAndPrepare(RCP_ENV),
        FlushLifeCycleTracker.DUMMY);
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_CREATE, USER_GROUP_CREATE,
    USER_GROUP_ADMIN);
  verifyDenied(action, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ, USER_GROUP_WRITE);
}
 
Example 29
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testCompact() throws Exception {
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preCompact(ObserverContextImpl.createAndPrepare(RCP_ENV), null, null,
        ScanType.COMPACT_RETAIN_DELETES, null, null);
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_OWNER, USER_CREATE, USER_GROUP_CREATE,
    USER_GROUP_ADMIN);
  verifyDenied(action, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ, USER_GROUP_WRITE);
}
 
Example 30
Source Project: hbase   Source File: TestAccessController.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testStopRegionServer() throws Exception {
  AccessTestAction action = new AccessTestAction() {
    @Override
    public Object run() throws Exception {
      ACCESS_CONTROLLER.preStopRegionServer(ObserverContextImpl.createAndPrepare(RSCP_ENV));
      return null;
    }
  };

  verifyAllowed(action, SUPERUSER, USER_ADMIN, USER_GROUP_ADMIN);
  verifyDenied(action, USER_CREATE, USER_OWNER, USER_RW, USER_RO, USER_NONE, USER_GROUP_READ,
    USER_GROUP_WRITE, USER_GROUP_CREATE);
}