Search in sources :

Example 6 with VXResource

use of org.apache.ranger.view.VXResource in project ranger by apache.

the class TestXUserREST method test53createXAuditMap.

@Test
public void test53createXAuditMap() {
    VXAuditMap testvXAuditMap = createVXAuditMapObj();
    Mockito.when(xUserMgr.createXAuditMap(testvXAuditMap)).thenReturn(testvXAuditMap);
    VXResource testVxResource = createVXResource();
    Mockito.when(xResourceService.readResource(testvXAuditMap.getResourceId())).thenReturn(testVxResource);
    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());
}
Also used : VXResource(org.apache.ranger.view.VXResource) VXAuditMap(org.apache.ranger.view.VXAuditMap) Test(org.junit.Test)

Example 7 with VXResource

use of org.apache.ranger.view.VXResource in project ranger by apache.

the class TestXUserREST method test52getXAuditMap.

@Test
public void test52getXAuditMap() {
    VXAuditMap testvXAuditMap = createVXAuditMapObj();
    Mockito.when(xUserMgr.getXAuditMap(id)).thenReturn(testvXAuditMap);
    VXResource testVxResource = createVXResource();
    Mockito.when(xResourceService.readResource(testvXAuditMap.getResourceId())).thenReturn(testVxResource);
    VXAuditMap retVXAuditMap = xUserRest.getXAuditMap(id);
    assertEquals(testvXAuditMap.getId(), retVXAuditMap.getId());
    assertEquals(testvXAuditMap.getClass(), retVXAuditMap.getClass());
    assertNotNull(retVXAuditMap);
    Mockito.verify(xUserMgr).getXAuditMap(id);
    Mockito.verify(xResourceService).readResource(testvXAuditMap.getResourceId());
}
Also used : VXResource(org.apache.ranger.view.VXResource) VXAuditMap(org.apache.ranger.view.VXAuditMap) Test(org.junit.Test)

Example 8 with VXResource

use of org.apache.ranger.view.VXResource 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());
}
Also used : VXResource(org.apache.ranger.view.VXResource) VXAuditMap(org.apache.ranger.view.VXAuditMap) Test(org.junit.Test)

Example 9 with VXResource

use of org.apache.ranger.view.VXResource in project ranger by apache.

the class TestXUserREST method createVXResource.

private VXResource createVXResource() {
    VXResource testVXResource = new VXResource();
    testVXResource.setAssetId(id);
    testVXResource.setAssetName("AdminAsset");
    testVXResource.setAssetType(1);
    testVXResource.setCreateDate(new Date());
    testVXResource.setOwner("Admin");
    testVXResource.setUpdateDate(new Date());
    testVXResource.setUpdatedBy("Admin");
    testVXResource.setParentId(id);
    testVXResource.setName("User");
    return testVXResource;
}
Also used : VXResource(org.apache.ranger.view.VXResource) Date(java.util.Date)

Example 10 with VXResource

use of org.apache.ranger.view.VXResource in project ranger by apache.

the class TestRangerBizUtil method testHasPermission_isAdmin.

@Test
public void testHasPermission_isAdmin() {
    VXResource vXResource = new VXResource();
    vXResource.setName(resourceName);
    vXResource.setAssetId(id);
    UserSessionBase currentUserSession = ContextUtil.getCurrentUserSession();
    currentUserSession.setUserAdmin(true);
    VXResponse resp = rangerBizUtil.hasPermission(vXResource, AppConstants.XA_PERM_TYPE_UNKNOWN);
    Assert.assertNotNull(resp);
    Assert.assertEquals(VXResponse.STATUS_SUCCESS, resp.getStatusCode());
}
Also used : VXResponse(org.apache.ranger.view.VXResponse) VXResource(org.apache.ranger.view.VXResource) UserSessionBase(org.apache.ranger.common.UserSessionBase) Test(org.junit.Test)

Aggregations

VXResource (org.apache.ranger.view.VXResource)28 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)9 VXResponse (org.apache.ranger.view.VXResponse)7 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)6 VXAuditMap (org.apache.ranger.view.VXAuditMap)6 VXPermMap (org.apache.ranger.view.VXPermMap)6 RangerService (org.apache.ranger.plugin.model.RangerService)5 VXResourceList (org.apache.ranger.view.VXResourceList)5 XXResource (org.apache.ranger.entity.XXResource)3 List (java.util.List)2 UserSessionBase (org.apache.ranger.common.UserSessionBase)2 XXAsset (org.apache.ranger.entity.XXAsset)2 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)2 VXPolicy (org.apache.ranger.view.VXPolicy)2 VXPolicyList (org.apache.ranger.view.VXPolicyList)2 File (java.io.File)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1