use of org.apache.ranger.view.VXAsset in project ranger by apache.
the class ServiceUtil method toVXAsset.
public VXAsset toVXAsset(RangerService service) {
if (service == null || toAssetType(service.getType()) == null) {
return null;
}
VXAsset ret = new VXAsset();
rangerObjectToDataObject(service, ret);
ret.setAssetType(toAssetType(service.getType()));
ret.setName(service.getName());
ret.setDescription(service.getDescription());
ret.setActiveStatus(service.getIsEnabled() ? RangerCommonEnums.STATUS_ENABLED : RangerCommonEnums.STATUS_DISABLED);
ret.setConfig(jsonUtil.readMapToString(service.getConfigs()));
return ret;
}
use of org.apache.ranger.view.VXAsset in project ranger by apache.
the class XAssetServiceBase method searchXAssets.
/**
* @param searchCriteria
* @return
*/
public VXAssetList searchXAssets(SearchCriteria searchCriteria) {
VXAssetList returnList = new VXAssetList();
List<VXAsset> xAssetList = new ArrayList<VXAsset>();
List<T> resultList = searchResources(searchCriteria, searchFields, sortFields, returnList);
// Iterate over the result list and create the return list
for (T gjXAsset : resultList) {
VXAsset vXAsset = populateViewBean(gjXAsset);
xAssetList.add(vXAsset);
}
returnList.setVXAssets(xAssetList);
return returnList;
}
use of org.apache.ranger.view.VXAsset in project ranger by apache.
the class XRepositoryService method mapPublicToXAObject.
public VXAsset mapPublicToXAObject(VXRepository vXRepo) {
VXAsset vXAsset = new VXAsset();
vXAsset = super.mapBaseAttributesToXAObject(vXRepo, vXAsset);
vXAsset.setName(vXRepo.getName());
vXAsset.setDescription(vXRepo.getDescription());
vXAsset.setAssetType(AppConstants.getEnumFor_AssetType(vXRepo.getRepositoryType()));
vXAsset.setConfig(vXRepo.getConfig());
int actStatus = (!vXRepo.getIsActive()) ? RangerCommonEnums.STATUS_DISABLED : RangerCommonEnums.STATUS_ENABLED;
vXAsset.setActiveStatus(actStatus);
return vXAsset;
}
use of org.apache.ranger.view.VXAsset in project ranger by apache.
the class TestRangerBizUtil method testGetMObject_VXDataObject.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testGetMObject_VXDataObject() {
VXAsset vXDataObject = new VXAsset();
vXDataObject.setId(id);
BaseDao baseDao = Mockito.mock(BaseDao.class);
Mockito.when(daoManager.getDaoForClassType(vXDataObject.getMyClassType())).thenReturn(baseDao);
Mockito.when(baseDao.getById(vXDataObject.getId())).thenReturn(new XXAsset());
XXDBBase xXDBaseChk = rangerBizUtil.getMObject(vXDataObject);
Assert.assertNotNull(xXDBaseChk);
}
use of org.apache.ranger.view.VXAsset in project ranger by apache.
the class TestAssetREST method testGetResourceJSON.
@Test
public void testGetResourceJSON() {
RangerService rangerService = rangerService(Id);
String file = "testGetResourceJSON";
VXAsset vXAsset = vXAsset(Id);
Date date = new Date();
String strdt = date.toString();
X509Certificate[] certchain = new X509Certificate[1];
certchain[0] = Mockito.mock(X509Certificate.class);
ServicePolicies servicePolicies = servicePolicies();
RangerPolicy rangerPolicy = rangerPolicy(Id);
List<RangerPolicy> policies = new ArrayList<RangerPolicy>();
policies.add(rangerPolicy);
Mockito.when(request.getParameter("epoch")).thenReturn(strdt);
Mockito.when(request.getAttribute("javax.servlet.request.X509Certificate")).thenReturn(certchain);
Mockito.when(request.getHeader("X-FORWARDED-FOR")).thenReturn("valid");
Mockito.when(request.isSecure()).thenReturn(true);
Mockito.when(request.getParameter("policyCount")).thenReturn("4");
Mockito.when(request.getParameter("agentId")).thenReturn("12");
// Mockito.when(PropertiesUtil.getBooleanProperty("ranger.service.http.enabled",true)).thenReturn(true);
try {
Mockito.when(serviceREST.getServicePoliciesIfUpdated(Mockito.anyString(), Mockito.anyLong(), Mockito.anyLong(), Mockito.anyString(), Mockito.anyString(), (HttpServletRequest) Mockito.any())).thenReturn(servicePolicies);
} catch (Exception e) {
fail("test failed due to: " + e.getMessage());
}
Mockito.when(serviceUtil.getServiceByName("hdfs_dev")).thenReturn(rangerService);
Mockito.when(serviceUtil.toVXAsset(rangerService)).thenReturn(vXAsset);
Mockito.when(assetMgr.getLatestRepoPolicy((VXAsset) Mockito.any(), Mockito.<VXResource>anyList(), Mockito.anyLong(), (X509Certificate[]) Mockito.any(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.anyString())).thenReturn(file);
String actualFile = assetREST.getResourceJSON(request, "hdfs_dev");
Assert.assertEquals(file, actualFile);
Mockito.verify(serviceUtil).getServiceByName("hdfs_dev");
Mockito.verify(serviceUtil).toVXAsset(rangerService);
Mockito.verify(request).getParameter("epoch");
Mockito.verify(request).getAttribute("javax.servlet.request.X509Certificate");
Mockito.verify(request).getHeader("X-FORWARDED-FOR");
Mockito.verify(request).isSecure();
Mockito.verify(request).getParameter("policyCount");
Mockito.verify(request).getParameter("agentId");
Mockito.verify(assetMgr).getLatestRepoPolicy((VXAsset) Mockito.any(), Mockito.<VXResource>anyList(), Mockito.anyLong(), (X509Certificate[]) Mockito.any(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.anyString());
}
Aggregations