use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestServiceREST method rangerServiceDef.
private RangerServiceDef rangerServiceDef() {
List<RangerServiceConfigDef> configs = new ArrayList<RangerServiceConfigDef>();
List<RangerResourceDef> resources = new ArrayList<RangerResourceDef>();
List<RangerAccessTypeDef> accessTypes = new ArrayList<RangerAccessTypeDef>();
List<RangerPolicyConditionDef> policyConditions = new ArrayList<RangerPolicyConditionDef>();
List<RangerContextEnricherDef> contextEnrichers = new ArrayList<RangerContextEnricherDef>();
List<RangerEnumDef> enums = new ArrayList<RangerEnumDef>();
RangerServiceDef rangerServiceDef = new RangerServiceDef();
rangerServiceDef.setId(Id);
rangerServiceDef.setImplClass("RangerServiceHdfs");
rangerServiceDef.setLabel("HDFS Repository");
rangerServiceDef.setDescription("HDFS Repository");
rangerServiceDef.setRbKeyDescription(null);
rangerServiceDef.setUpdatedBy("Admin");
rangerServiceDef.setUpdateTime(new Date());
rangerServiceDef.setConfigs(configs);
rangerServiceDef.setResources(resources);
rangerServiceDef.setAccessTypes(accessTypes);
rangerServiceDef.setPolicyConditions(policyConditions);
rangerServiceDef.setContextEnrichers(contextEnrichers);
rangerServiceDef.setEnums(enums);
return rangerServiceDef;
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestServiceREST method test5getServiceDefByName.
@Test
public void test5getServiceDefByName() throws Exception {
RangerServiceDef rangerServiceDef = rangerServiceDef();
XXServiceDef xServiceDef = serviceDef();
XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
Mockito.when(xServiceDefDao.findByName(xServiceDef.getName())).thenReturn(xServiceDef);
Mockito.when(!bizUtil.hasAccess(xServiceDef, null)).thenReturn(true);
Mockito.when(svcStore.getServiceDefByName(rangerServiceDef.getName())).thenReturn(rangerServiceDef);
RangerServiceDef dbRangerServiceDef = serviceREST.getServiceDefByName(rangerServiceDef.getName());
Assert.assertNotNull(dbRangerServiceDef);
Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
Mockito.verify(svcStore).getServiceDefByName(rangerServiceDef.getName());
Mockito.verify(daoManager).getXXServiceDef();
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class TestServiceREST method test12deleteServiceDef.
@Test
public void test12deleteServiceDef() {
RangerServiceDef rangerServiceDef = rangerServiceDef();
XXServiceDef xServiceDef = serviceDef();
XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
Mockito.when(validatorFactory.getServiceDefValidator(svcStore)).thenReturn(serviceDefValidator);
Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
Mockito.when(xServiceDefDao.getById(Id)).thenReturn(xServiceDef);
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
serviceREST.deleteServiceDef(rangerServiceDef.getId(), request);
Mockito.verify(validatorFactory).getServiceDefValidator(svcStore);
Mockito.verify(daoManager).getXXServiceDef();
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class RangerDefaultPolicyEvaluatorTest method getMockServiceDef.
RangerServiceDef getMockServiceDef(List<RangerPolicyConditionDef> conditionDefs) {
// create a service def
RangerServiceDef serviceDef = mock(RangerServiceDef.class);
when(serviceDef.getPolicyConditions()).thenReturn(conditionDefs);
return serviceDef;
}
use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.
the class RangerDefaultPolicyEvaluatorTest method getMockServiceDef.
RangerServiceDef getMockServiceDef(Map<String, String[]> pairs) {
// create a service def
RangerServiceDef serviceDef = mock(RangerServiceDef.class);
if (pairs == null) {
return serviceDef;
}
List<RangerPolicyConditionDef> conditions = getMockPolicyConditionDefs(pairs);
when(serviceDef.getPolicyConditions()).thenReturn(conditions);
return serviceDef;
}
Aggregations