Search in sources :

Example 6 with VXAsset

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;
}
Also used : VXAsset(org.apache.ranger.view.VXAsset)

Example 7 with VXAsset

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;
}
Also used : VXAsset(org.apache.ranger.view.VXAsset) ArrayList(java.util.ArrayList) VXAssetList(org.apache.ranger.view.VXAssetList)

Example 8 with VXAsset

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;
}
Also used : VXAsset(org.apache.ranger.view.VXAsset)

Example 9 with 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);
}
Also used : VXAsset(org.apache.ranger.view.VXAsset) BaseDao(org.apache.ranger.common.db.BaseDao) XXAsset(org.apache.ranger.entity.XXAsset) XXDBBase(org.apache.ranger.entity.XXDBBase) Test(org.junit.Test)

Example 10 with VXAsset

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());
}
Also used : VXAsset(org.apache.ranger.view.VXAsset) RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) ServicePolicies(org.apache.ranger.plugin.util.ServicePolicies) ArrayList(java.util.ArrayList) RangerService(org.apache.ranger.plugin.model.RangerService) Date(java.util.Date) X509Certificate(java.security.cert.X509Certificate) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Aggregations

VXAsset (org.apache.ranger.view.VXAsset)16 Test (org.junit.Test)10 RangerService (org.apache.ranger.plugin.model.RangerService)9 ArrayList (java.util.ArrayList)3 VXAssetList (org.apache.ranger.view.VXAssetList)3 VXRepository (org.apache.ranger.view.VXRepository)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)2 X509Certificate (java.security.cert.X509Certificate)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 BaseDao (org.apache.ranger.common.db.BaseDao)1 XXServiceDao (org.apache.ranger.db.XXServiceDao)1 XXAsset (org.apache.ranger.entity.XXAsset)1 XXDBBase (org.apache.ranger.entity.XXDBBase)1 XXService (org.apache.ranger.entity.XXService)1 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)1 ServicePolicies (org.apache.ranger.plugin.util.ServicePolicies)1 VXLong (org.apache.ranger.view.VXLong)1