/** * Determines if there is a MasterCoprocessor deployed which implements * {@link org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsService.Interface}. */ boolean hasVisibilityLabelsServiceCoprocessor(MasterCoprocessorHost cpHost) { return checkCoprocessorWithService( cpHost.findCoprocessors(MasterCoprocessor.class), VisibilityLabelsService.Interface.class); }
/** * Determines if there is a MasterCoprocessor deployed which implements * {@link org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService.Interface}. */ boolean hasAccessControlServiceCoprocessor(MasterCoprocessorHost cpHost) { return checkCoprocessorWithService( cpHost.findCoprocessors(MasterCoprocessor.class), AccessControlService.Interface.class); }
@SuppressWarnings("unchecked") @Before public void setup() { masterServices = mock(MasterRpcServices.class); when(masterServices.hasAccessControlServiceCoprocessor( any(MasterCoprocessorHost.class))).thenCallRealMethod(); when(masterServices.hasVisibilityLabelsServiceCoprocessor( any(MasterCoprocessorHost.class))).thenCallRealMethod(); when(masterServices.checkCoprocessorWithService( any(List.class), any(Class.class))).thenCallRealMethod(); }
@Test public void testAccessControlServices() { MasterCoprocessor defaultImpl = new AccessController(); MasterCoprocessor customImpl = new MockAccessController(); MasterCoprocessor unrelatedImpl = new JMXListener(); assertTrue(masterServices.checkCoprocessorWithService( Collections.singletonList(defaultImpl), AccessControlService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Collections.singletonList(customImpl), AccessControlService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( Collections.emptyList(), AccessControlService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( null, AccessControlService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( Collections.singletonList(unrelatedImpl), AccessControlService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Arrays.asList(unrelatedImpl, customImpl), AccessControlService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Arrays.asList(unrelatedImpl, defaultImpl), AccessControlService.Interface.class)); }
@Test public void testVisibilityLabelServices() { MasterCoprocessor defaultImpl = new VisibilityController(); MasterCoprocessor customImpl = new MockVisibilityController(); MasterCoprocessor unrelatedImpl = new JMXListener(); assertTrue(masterServices.checkCoprocessorWithService( Collections.singletonList(defaultImpl), VisibilityLabelsService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Collections.singletonList(customImpl), VisibilityLabelsService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( Collections.emptyList(), VisibilityLabelsService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( null, VisibilityLabelsService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( Collections.singletonList(unrelatedImpl), VisibilityLabelsService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Arrays.asList(unrelatedImpl, customImpl), VisibilityLabelsService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Arrays.asList(unrelatedImpl, defaultImpl), VisibilityLabelsService.Interface.class)); } }
@SuppressWarnings("unchecked") @Before public void setup() { masterServices = mock(MasterRpcServices.class); when(masterServices.hasAccessControlServiceCoprocessor( any(MasterCoprocessorHost.class))).thenCallRealMethod(); when(masterServices.hasVisibilityLabelsServiceCoprocessor( any(MasterCoprocessorHost.class))).thenCallRealMethod(); when(masterServices.checkCoprocessorWithService( any(List.class), any(Class.class))).thenCallRealMethod(); }
@Test public void testAccessControlServices() { MasterCoprocessor defaultImpl = new AccessController(); MasterCoprocessor customImpl = new MockAccessController(); MasterCoprocessor unrelatedImpl = new JMXListener(); assertTrue(masterServices.checkCoprocessorWithService( Collections.singletonList(defaultImpl), AccessControlService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Collections.singletonList(customImpl), AccessControlService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( Collections.emptyList(), AccessControlService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( null, AccessControlService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( Collections.singletonList(unrelatedImpl), AccessControlService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Arrays.asList(unrelatedImpl, customImpl), AccessControlService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Arrays.asList(unrelatedImpl, defaultImpl), AccessControlService.Interface.class)); }
@Test public void testVisibilityLabelServices() { MasterCoprocessor defaultImpl = new VisibilityController(); MasterCoprocessor customImpl = new MockVisibilityController(); MasterCoprocessor unrelatedImpl = new JMXListener(); assertTrue(masterServices.checkCoprocessorWithService( Collections.singletonList(defaultImpl), VisibilityLabelsService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Collections.singletonList(customImpl), VisibilityLabelsService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( Collections.emptyList(), VisibilityLabelsService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( null, VisibilityLabelsService.Interface.class)); assertFalse(masterServices.checkCoprocessorWithService( Collections.singletonList(unrelatedImpl), VisibilityLabelsService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Arrays.asList(unrelatedImpl, customImpl), VisibilityLabelsService.Interface.class)); assertTrue(masterServices.checkCoprocessorWithService( Arrays.asList(unrelatedImpl, defaultImpl), VisibilityLabelsService.Interface.class)); } }