Search in sources :

Example 26 with VXResource

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

the class TestRangerBizUtil method testHasPermission_When_disableAccessControl.

@Test
public void testHasPermission_When_disableAccessControl() {
    VXResource vXResource = null;
    rangerBizUtil.enableResourceAccessControl = false;
    VXResponse resp = rangerBizUtil.hasPermission(vXResource, AppConstants.XA_PERM_TYPE_UNKNOWN);
    Assert.assertNotNull(resp);
}
Also used : VXResponse(org.apache.ranger.view.VXResponse) VXResource(org.apache.ranger.view.VXResource) Test(org.junit.Test)

Example 27 with VXResource

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

the class TestAssetREST method testUpdateXResource.

@Test
public void testUpdateXResource() {
    VXResource vxResource = vxResource(Id);
    RangerPolicy rangerPolicy = rangerPolicy(Id);
    RangerService rangerService = rangerService(Id);
    Mockito.when(serviceREST.getService(vxResource.getAssetId())).thenReturn(rangerService);
    Mockito.when(serviceREST.updatePolicy(rangerPolicy)).thenReturn(rangerPolicy);
    Mockito.when(serviceUtil.toRangerPolicy(vxResource, rangerService)).thenReturn(rangerPolicy);
    Mockito.when(serviceUtil.toVXResource(rangerPolicy, rangerService)).thenReturn(vxResource);
    VXResource actualvxResource = assetREST.updateXResource(vxResource);
    Assert.assertNotNull(actualvxResource);
    Assert.assertEquals(vxResource, actualvxResource);
    Mockito.verify(serviceREST).getService(vxResource.getAssetId());
    Mockito.verify(serviceREST).updatePolicy(rangerPolicy);
    Mockito.verify(serviceUtil).toRangerPolicy(vxResource, rangerService);
    Mockito.verify(serviceUtil).toVXResource(rangerPolicy, rangerService);
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) VXResource(org.apache.ranger.view.VXResource) RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Example 28 with VXResource

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

the class TestAssetREST method testGetXResource.

@Test
public void testGetXResource() {
    VXResource expectedvxResource = vxResource(Id);
    RangerPolicy rangerPolicy = rangerPolicy(Id);
    RangerService rangerService = rangerService(Id);
    Mockito.when(serviceREST.getPolicy(Id)).thenReturn(rangerPolicy);
    Mockito.when(serviceREST.getServiceByName(rangerPolicy.getService())).thenReturn(rangerService);
    Mockito.when(serviceUtil.toVXResource(rangerPolicy, rangerService)).thenReturn(expectedvxResource);
    VXResource actualvxResource = assetREST.getXResource(Id);
    Assert.assertNotNull(actualvxResource);
    Assert.assertEquals(expectedvxResource, actualvxResource);
}
Also used : RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) VXResource(org.apache.ranger.view.VXResource) RangerService(org.apache.ranger.plugin.model.RangerService) 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