use of org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef in project ranger by apache.
the class TestServiceDBStore method rangerServiceDef.
private RangerServiceDef rangerServiceDef() {
List<RangerServiceConfigDef> configs = new ArrayList<RangerServiceConfigDef>();
RangerServiceConfigDef serviceConfigDefObj = new RangerServiceConfigDef();
serviceConfigDefObj.setDefaultValue("xyz");
serviceConfigDefObj.setDescription("ServiceDef");
serviceConfigDefObj.setItemId(Id);
serviceConfigDefObj.setLabel("Username");
serviceConfigDefObj.setMandatory(true);
serviceConfigDefObj.setName("username");
serviceConfigDefObj.setRbKeyDescription(null);
serviceConfigDefObj.setRbKeyLabel(null);
serviceConfigDefObj.setRbKeyValidationMessage(null);
serviceConfigDefObj.setSubType(null);
configs.add(serviceConfigDefObj);
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;
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef in project ranger by apache.
the class RangerServiceDefValidator method isValidConfigs.
boolean isValidConfigs(List<RangerServiceConfigDef> configs, List<RangerEnumDef> enumDefs, List<ValidationFailureDetails> failures) {
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("==> RangerServiceDefValidator.isValidConfigs(%s, %s, %s)", configs, enumDefs, failures));
}
boolean valid = true;
if (CollectionUtils.isEmpty(configs)) {
LOG.debug("Configs collection was null/empty! ok");
} else {
Set<Long> ids = new HashSet<Long>(configs.size());
Set<String> names = new HashSet<String>(configs.size());
for (RangerServiceConfigDef aConfig : configs) {
valid = isUnique(aConfig.getItemId(), ids, "config def itemId", "config defs", failures) && valid;
String configName = aConfig.getName();
valid = isUnique(configName, names, "config def name", "config defs", failures) && valid;
String type = aConfig.getType();
valid = isValidConfigType(type, configName, failures) && valid;
if ("enum".equals(type)) {
valid = isValidConfigOfEnumType(aConfig, enumDefs, failures) && valid;
}
}
}
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("<== RangerServiceDefValidator.isValidConfigs(%s, %s, %s): %s", configs, enumDefs, failures, valid));
}
return valid;
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef in project ranger by apache.
the class TestRangerServiceDefService 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 TestRangerServiceDefServiceBase method test4populateXXToRangerServiceConfigDef.
@Test
public void test4populateXXToRangerServiceConfigDef() {
XXServiceConfigDef serviceConfigDefObj = new XXServiceConfigDef();
RangerServiceConfigDef dbserviceConfigDefObj = rangerServiceDefService.populateXXToRangerServiceConfigDef(serviceConfigDefObj);
Assert.assertNotNull(dbserviceConfigDefObj);
}
use of org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef in project ranger by apache.
the class TestRangerServiceDefServiceBase method test3populateRangerServiceConfigDefToXX.
@Test
public void test3populateRangerServiceConfigDefToXX() {
RangerServiceConfigDef serviceConfigDefObj = new RangerServiceConfigDef();
XXServiceConfigDef configDefObj = new XXServiceConfigDef();
XXServiceDef serviceDefObj = new XXServiceDef();
Mockito.when((XXServiceConfigDef) rangerAuditFields.populateAuditFields(configDefObj, serviceDefObj)).thenReturn(configDefObj);
XXServiceConfigDef dbServiceConfigDef = rangerServiceDefService.populateRangerServiceConfigDefToXX(serviceConfigDefObj, configDefObj, serviceDefObj, 1);
Assert.assertNotNull(dbServiceConfigDef);
}
Aggregations