use of org.apache.ranger.view.VXAuditMap in project ranger by apache.
the class TestXUserREST method test56updateXAuditMap.
@Test
public void test56updateXAuditMap() {
VXAuditMap testvXAuditMap = createVXAuditMapObj();
testvXAuditMap.setResourceId(id);
Mockito.when(xUserMgr.updateXAuditMap(testvXAuditMap)).thenReturn(testvXAuditMap);
VXResource testVxResource = createVXResource();
Mockito.when(xResourceService.readResource(testvXAuditMap.getResourceId())).thenReturn(testVxResource);
VXAuditMap retvXAuditMap = xUserRest.updateXAuditMap(testvXAuditMap);
assertEquals(testvXAuditMap.getId(), retvXAuditMap.getId());
assertEquals(testvXAuditMap.getClass(), retvXAuditMap.getClass());
assertNotNull(retvXAuditMap);
Mockito.verify(xUserMgr).updateXAuditMap(testvXAuditMap);
Mockito.verify(xResourceService).readResource(testvXAuditMap.getResourceId());
}
use of org.apache.ranger.view.VXAuditMap in project ranger by apache.
the class TestXUserREST method test50getXAuditMapVXAuditMapNull.
@Test
public void test50getXAuditMapVXAuditMapNull() {
VXAuditMap testvXAuditMap = createVXAuditMapObj();
Mockito.when(xUserMgr.getXAuditMap(testvXAuditMap.getResourceId())).thenReturn(testvXAuditMap);
Mockito.when(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any())).thenThrow(new WebApplicationException());
thrown.expect(WebApplicationException.class);
VXAuditMap retVXAuditMap = xUserRest.getXAuditMap(testvXAuditMap.getResourceId());
assertEquals(testvXAuditMap.getId(), retVXAuditMap.getId());
assertEquals(testvXAuditMap.getClass(), retVXAuditMap.getClass());
assertNotNull(retVXAuditMap);
Mockito.verify(xUserMgr).getXAuditMap(testvXAuditMap.getResourceId());
Mockito.verify(xResourceService).readResource(null);
Mockito.verify(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any()));
}
use of org.apache.ranger.view.VXAuditMap in project ranger by apache.
the class TestXUserREST method test54createXAuditMapVxResourceNull.
@Test
public void test54createXAuditMapVxResourceNull() {
VXAuditMap testvXAuditMap = createVXAuditMapObj();
testvXAuditMap.setResourceId(null);
Mockito.when(xResourceService.readResource(testvXAuditMap.getResourceId())).thenReturn(null);
Mockito.when(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any())).thenThrow(new WebApplicationException());
thrown.expect(WebApplicationException.class);
VXAuditMap retvXAuditMap = xUserRest.createXAuditMap(testvXAuditMap);
assertEquals(testvXAuditMap.getId(), retvXAuditMap.getId());
assertEquals(testvXAuditMap.getClass(), retvXAuditMap.getClass());
assertNotNull(retvXAuditMap);
Mockito.verify(xUserMgr).createXAuditMap(testvXAuditMap);
Mockito.verify(xResourceService).readResource(testvXAuditMap.getResourceId());
Mockito.verify(restErrorUtil.createRESTException(Mockito.anyString(), (MessageEnums) Mockito.any()));
}
use of org.apache.ranger.view.VXAuditMap in project ranger by apache.
the class XAuditMapServiceBase method searchXAuditMaps.
/**
* @param searchCriteria
* @return
*/
public VXAuditMapList searchXAuditMaps(SearchCriteria searchCriteria) {
VXAuditMapList returnList = new VXAuditMapList();
List<VXAuditMap> xAuditMapList = new ArrayList<VXAuditMap>();
List<T> resultList = searchResources(searchCriteria, searchFields, sortFields, returnList);
// Iterate over the result list and create the return list
for (T gjXAuditMap : resultList) {
VXAuditMap vXAuditMap = populateViewBean(gjXAuditMap);
xAuditMapList.add(vXAuditMap);
}
returnList.setVXAuditMaps(xAuditMapList);
return returnList;
}
use of org.apache.ranger.view.VXAuditMap in project ranger by apache.
the class ServiceUtil method toVXResource.
public VXResource toVXResource(RangerPolicy policy, RangerService service) {
if (policy == null || service == null || toAssetType(service.getType()) == null) {
return null;
}
VXResource ret = new VXResource();
rangerObjectToDataObject(policy, ret);
ret.setAssetName(policy.getService());
ret.setAssetId(service.getId());
ret.setAssetType(toAssetType(service.getType()));
ret.setPolicyName(policy.getName());
ret.setDescription(policy.getDescription());
ret.setGuid(policy.getGuid());
ret.setResourceStatus(policy.getIsEnabled() ? RangerCommonEnums.STATUS_ENABLED : RangerCommonEnums.STATUS_DISABLED);
List<VXAuditMap> auditList = null;
if (policy.getIsAuditEnabled()) {
VXAuditMap auditMap = new VXAuditMap();
auditMap.setResourceId(policy.getId());
auditMap.setAuditType(AppConstants.XA_AUDIT_TYPE_ALL);
auditList = new ArrayList<VXAuditMap>();
auditList.add(auditMap);
}
ret.setAuditList(auditList);
for (Map.Entry<String, RangerPolicy.RangerPolicyResource> e : policy.getResources().entrySet()) {
RangerPolicy.RangerPolicyResource res = e.getValue();
String resType = e.getKey();
String resString = getResourceString(res.getValues());
if ("path".equalsIgnoreCase(resType)) {
ret.setName(resString);
ret.setIsRecursive(Boolean.TRUE.equals(res.getIsRecursive()) ? RangerCommonEnums.BOOL_TRUE : RangerCommonEnums.BOOL_FALSE);
} else if ("table".equalsIgnoreCase(resType)) {
ret.setTables(resString);
ret.setTableType(Boolean.TRUE.equals(res.getIsExcludes()) ? RangerCommonEnums.POLICY_EXCLUSION : RangerCommonEnums.POLICY_INCLUSION);
} else if ("column-family".equalsIgnoreCase(resType)) {
ret.setColumnFamilies(resString);
} else if ("column".equalsIgnoreCase(resType)) {
ret.setColumns(resString);
ret.setColumnType(Boolean.TRUE.equals(res.getIsExcludes()) ? RangerCommonEnums.POLICY_EXCLUSION : RangerCommonEnums.POLICY_INCLUSION);
} else if ("database".equalsIgnoreCase(resType)) {
ret.setDatabases(resString);
} else if ("udf".equalsIgnoreCase(resType)) {
ret.setUdfs(resString);
} else if ("topology".equalsIgnoreCase(resType)) {
ret.setTopologies(resString);
} else if ("service".equalsIgnoreCase(resType)) {
ret.setServices(resString);
}
}
updateResourceName(ret);
List<VXPermMap> permMapList = getVXPermMapList(policy);
ret.setPermMapList(permMapList);
return ret;
}
Aggregations