Search in sources :

Example 11 with RangerServiceConfigDef

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;
}
Also used : RangerServiceConfigDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef) ArrayList(java.util.ArrayList) RangerEnumDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef) RangerPolicyConditionDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef) Date(java.util.Date) RangerAccessTypeDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef) RangerContextEnricherDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) RangerResourceDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)

Example 12 with RangerServiceConfigDef

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;
}
Also used : RangerServiceConfigDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef) HashSet(java.util.HashSet)

Example 13 with RangerServiceConfigDef

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;
}
Also used : RangerServiceConfigDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef) ArrayList(java.util.ArrayList) RangerEnumDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef) RangerPolicyConditionDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef) Date(java.util.Date) RangerAccessTypeDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef) RangerContextEnricherDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) RangerResourceDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)

Example 14 with RangerServiceConfigDef

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);
}
Also used : RangerServiceConfigDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef) XXServiceConfigDef(org.apache.ranger.entity.XXServiceConfigDef) Test(org.junit.Test)

Example 15 with RangerServiceConfigDef

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);
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) RangerServiceConfigDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef) XXServiceConfigDef(org.apache.ranger.entity.XXServiceConfigDef) Test(org.junit.Test)

Aggregations

RangerServiceConfigDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef)30 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)22 ArrayList (java.util.ArrayList)20 Test (org.junit.Test)13 RangerAccessTypeDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef)11 RangerContextEnricherDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef)11 RangerEnumDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef)11 RangerPolicyConditionDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef)11 RangerResourceDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)11 RangerService (org.apache.ranger.plugin.model.RangerService)10 HashMap (java.util.HashMap)8 Date (java.util.Date)7 ValidationErrorCode (org.apache.ranger.plugin.errors.ValidationErrorCode)6 XXServiceConfigDef (org.apache.ranger.entity.XXServiceConfigDef)4 XXServiceDef (org.apache.ranger.entity.XXServiceDef)4 RangerDataMaskDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerDataMaskDef)3 RangerDataMaskTypeDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerDataMaskTypeDef)3 RangerRowFilterDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerRowFilterDef)3 VXString (org.apache.ranger.view.VXString)3 XXAccessTypeDefDao (org.apache.ranger.db.XXAccessTypeDefDao)2