use of org.apache.ranger.plugin.service.ResourceLookupContext in project ranger by apache.
the class TestNiFiClient method testGetResourcesNoUserInput.
@Test
public void testGetResourcesNoUserInput() throws Exception {
ResourceLookupContext resourceLookupContext = Mockito.mock(ResourceLookupContext.class);
when(resourceLookupContext.getUserInput()).thenReturn("");
final List<String> expectedResources = new ArrayList<>();
expectedResources.add("/system");
expectedResources.add("/controller");
expectedResources.add("/flow");
expectedResources.add("/provenance");
expectedResources.add("/proxy");
expectedResources.add("/resources");
List<String> resources = niFiClient.getResources(resourceLookupContext);
Assert.assertNotNull(resources);
Assert.assertEquals(expectedResources.size(), resources.size());
resources.removeAll(expectedResources);
Assert.assertEquals(0, resources.size());
}
use of org.apache.ranger.plugin.service.ResourceLookupContext in project ranger by apache.
the class TestNiFiClient method testGetResourcesWithUserInputBeginning.
@Test
public void testGetResourcesWithUserInputBeginning() throws Exception {
ResourceLookupContext resourceLookupContext = Mockito.mock(ResourceLookupContext.class);
when(resourceLookupContext.getUserInput()).thenReturn("/pr");
final List<String> expectedResources = new ArrayList<>();
expectedResources.add("/provenance");
expectedResources.add("/proxy");
List<String> resources = niFiClient.getResources(resourceLookupContext);
Assert.assertNotNull(resources);
Assert.assertEquals(expectedResources.size(), resources.size());
resources.removeAll(expectedResources);
Assert.assertEquals(0, resources.size());
}
use of org.apache.ranger.plugin.service.ResourceLookupContext in project ranger by apache.
the class TestNiFiClient method testGetResourcesWithUserInputAnywhere.
@Test
public void testGetResourcesWithUserInputAnywhere() throws Exception {
ResourceLookupContext resourceLookupContext = Mockito.mock(ResourceLookupContext.class);
when(resourceLookupContext.getUserInput()).thenReturn("trol");
final List<String> expectedResources = new ArrayList<>();
expectedResources.add("/controller");
List<String> resources = niFiClient.getResources(resourceLookupContext);
Assert.assertNotNull(resources);
Assert.assertEquals(expectedResources.size(), resources.size());
resources.removeAll(expectedResources);
Assert.assertEquals(0, resources.size());
}
use of org.apache.ranger.plugin.service.ResourceLookupContext in project ranger by apache.
the class TestNiFiClient method testGetResourcesErrorResponse.
@Test
public void testGetResourcesErrorResponse() throws Exception {
final String errorMsg = "unknown error";
niFiClient = new MockNiFiClient(errorMsg, Response.Status.BAD_REQUEST.getStatusCode());
ResourceLookupContext resourceLookupContext = Mockito.mock(ResourceLookupContext.class);
when(resourceLookupContext.getUserInput()).thenReturn("");
try {
niFiClient.getResources(resourceLookupContext);
Assert.fail("should have thrown exception");
} catch (Exception e) {
Assert.assertTrue(e.getMessage().contains(errorMsg));
}
}
use of org.apache.ranger.plugin.service.ResourceLookupContext in project ranger by apache.
the class TestRangerServiceHBase method setup.
@Before
public void setup() {
configs = new HashMap<String, String>();
lookupContext = new ResourceLookupContext();
buildHbaseConnectionConfig();
buildLookupContext();
sd = new RangerServiceDef(sdName, "org.apache.ranger.services.hbase.RangerServiceHBase", "TestService", "test servicedef description", null, null, null, null, null, null, null);
svc = new RangerService(sdName, serviceName, "unit test hbase resource lookup and validateConfig", null, configs);
svcHBase = new RangerServiceHBase();
svcHBase.init(sd, svc);
}
Aggregations