use of org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef in project ranger by apache.
the class TestRangerServiceValidator method test_isValid_missingRequiredParameter.
@Test
public void test_isValid_missingRequiredParameter() throws Exception {
// Create/Update: simulate a condition where required parameters are missing
Object[][] input = new Object[][] { { "param1", true }, { "param2", true }, { "param3", false }, { "param4", false } };
List<RangerServiceConfigDef> configDefs = _utils.createServiceConditionDefs(input);
RangerServiceDef serviceDef = mock(RangerServiceDef.class);
when(serviceDef.getConfigs()).thenReturn(configDefs);
// wire this service def into store
when(_store.getServiceDefByName("aType")).thenReturn(serviceDef);
// create a service with some require parameters missing
RangerService service = mock(RangerService.class);
when(service.getType()).thenReturn("aType");
when(service.getName()).thenReturn("aName");
// required parameters param2 is missing
String[] params = new String[] { "param1", "param3", "param4", "param5" };
Map<String, String> paramMap = _utils.createMap(params);
when(service.getConfigs()).thenReturn(paramMap);
// service does not exist in the store
when(_store.getServiceByName("aService")).thenReturn(null);
for (Action action : cu) {
// it should be invalid
checkFailure_isValid(_validator, service, action, _failures, "missing", "configuration", "param2");
}
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef in project ranger by apache.
the class TestRangerValidator method test_getRequiredParameters.
@Test
public void test_getRequiredParameters() {
// reasonable protection against null things
Set<String> parameters = _validator.getRequiredParameters(null);
Assert.assertNotNull(parameters);
Assert.assertTrue(parameters.isEmpty());
RangerServiceDef serviceDef = mock(RangerServiceDef.class);
when(serviceDef.getConfigs()).thenReturn(null);
parameters = _validator.getRequiredParameters(null);
Assert.assertNotNull(parameters);
Assert.assertTrue(parameters.isEmpty());
List<RangerServiceConfigDef> configs = new ArrayList<>();
when(serviceDef.getConfigs()).thenReturn(configs);
parameters = _validator.getRequiredParameters(null);
Assert.assertNotNull(parameters);
Assert.assertTrue(parameters.isEmpty());
Object[][] input = new Object[][] { { "param1", false }, { "param2", true }, { "param3", true }, { "param4", false } };
configs = _utils.createServiceConditionDefs(input);
when(serviceDef.getConfigs()).thenReturn(configs);
parameters = _validator.getRequiredParameters(serviceDef);
Assert.assertTrue("result does not contain: param2", parameters.contains("param2"));
Assert.assertTrue("result does not contain: param3", parameters.contains("param3"));
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef in project ranger by apache.
the class TestServiceREST method rangerServiceDef.
public 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.RangerServiceConfigDef in project ranger by apache.
the class TestAssetREST 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.RangerServiceConfigDef in project ranger by apache.
the class TestPublicAPIsv2 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.setName("RangerServiceHdfs");
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;
}
Aggregations