Search in sources :

Example 96 with RangerServiceDef

use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.

the class TestPublicAPIsv2 method test2getServiceDefByName.

@Test
public void test2getServiceDefByName() throws Exception {
    RangerServiceDef rangerServiceDef = rangerServiceDef();
    String name = rangerServiceDef.getName();
    Mockito.when(serviceREST.getServiceDefByName(name)).thenReturn(rangerServiceDef);
    RangerServiceDef dbRangerServiceDef = publicAPIsv2.getServiceDefByName(name);
    Assert.assertNotNull(dbRangerServiceDef);
    Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
    Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
    Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
    Mockito.verify(serviceREST).getServiceDefByName(name);
}
Also used : RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) Test(org.junit.Test)

Example 97 with RangerServiceDef

use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.

the class TestPublicAPIsv2 method test1getServiceDef.

@Test
public void test1getServiceDef() throws Exception {
    RangerServiceDef rangerServiceDef = rangerServiceDef();
    Mockito.when(serviceREST.getServiceDef(rangerServiceDef.getId())).thenReturn(rangerServiceDef);
    RangerServiceDef dbRangerServiceDef = publicAPIsv2.getServiceDef(Id);
    Assert.assertNotNull(dbRangerServiceDef);
    Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
    Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
    Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
    Mockito.verify(serviceREST).getServiceDef(Id);
}
Also used : RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) Test(org.junit.Test)

Example 98 with RangerServiceDef

use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.

the class TestPublicAPIsv2 method test6updateServiceDefByName.

@Test
public void test6updateServiceDefByName() throws Exception {
    RangerServiceDef rangerServiceDef = rangerServiceDef();
    String name = rangerServiceDef.getName();
    Mockito.when(serviceREST.getServiceDefByName(name)).thenReturn(rangerServiceDef);
    Mockito.when(serviceREST.updateServiceDef(rangerServiceDef)).thenReturn(rangerServiceDef);
    RangerServiceDef dbRangerServiceDef = publicAPIsv2.updateServiceDefByName(rangerServiceDef, name);
    Assert.assertNotNull(dbRangerServiceDef);
    Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
    Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
    Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
    Mockito.verify(serviceREST).updateServiceDef(rangerServiceDef);
    Mockito.verify(serviceREST).getServiceDefByName(name);
}
Also used : RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) Test(org.junit.Test)

Example 99 with RangerServiceDef

use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.

the class TestServiceREST method test2updateServiceDef.

@Test
public void test2updateServiceDef() throws Exception {
    RangerServiceDef rangerServiceDef = rangerServiceDef();
    Mockito.when(validatorFactory.getServiceDefValidator(svcStore)).thenReturn(serviceDefValidator);
    Mockito.when(svcStore.updateServiceDef((RangerServiceDef) Mockito.any())).thenReturn(rangerServiceDef);
    RangerServiceDef dbRangerServiceDef = serviceREST.updateServiceDef(rangerServiceDef);
    Assert.assertNotNull(dbRangerServiceDef);
    Assert.assertEquals(dbRangerServiceDef, rangerServiceDef);
    Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
    Assert.assertEquals(dbRangerServiceDef.getName(), rangerServiceDef.getName());
    Assert.assertEquals(dbRangerServiceDef.getImplClass(), rangerServiceDef.getImplClass());
    Assert.assertEquals(dbRangerServiceDef.getLabel(), rangerServiceDef.getLabel());
    Assert.assertEquals(dbRangerServiceDef.getDescription(), rangerServiceDef.getDescription());
    Assert.assertEquals(dbRangerServiceDef.getRbKeyDescription(), rangerServiceDef.getRbKeyDescription());
    Assert.assertEquals(dbRangerServiceDef.getUpdatedBy(), rangerServiceDef.getUpdatedBy());
    Assert.assertEquals(dbRangerServiceDef.getUpdateTime(), rangerServiceDef.getUpdateTime());
    Assert.assertEquals(dbRangerServiceDef.getVersion(), rangerServiceDef.getVersion());
    Assert.assertEquals(dbRangerServiceDef.getConfigs(), rangerServiceDef.getConfigs());
    Mockito.verify(validatorFactory).getServiceDefValidator(svcStore);
    Mockito.verify(svcStore).updateServiceDef(rangerServiceDef);
}
Also used : RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) Test(org.junit.Test)

Example 100 with RangerServiceDef

use of org.apache.ranger.plugin.model.RangerServiceDef in project ranger by apache.

the class TestServiceREST method test4getServiceDefById.

@Test
public void test4getServiceDefById() throws Exception {
    RangerServiceDef rangerServiceDef = rangerServiceDef();
    XXServiceDef xServiceDef = serviceDef();
    XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
    Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
    Mockito.when(xServiceDefDao.getById(Id)).thenReturn(xServiceDef);
    Mockito.when(!bizUtil.hasAccess(xServiceDef, null)).thenReturn(true);
    Mockito.when(svcStore.getServiceDef(rangerServiceDef.getId())).thenReturn(rangerServiceDef);
    RangerServiceDef dbRangerServiceDef = serviceREST.getServiceDef(rangerServiceDef.getId());
    Assert.assertNotNull(dbRangerServiceDef);
    Assert.assertEquals(dbRangerServiceDef.getId(), rangerServiceDef.getId());
    Mockito.verify(svcStore).getServiceDef(rangerServiceDef.getId());
    Mockito.verify(daoManager).getXXServiceDef();
    Mockito.verify(bizUtil).hasAccess(xServiceDef, null);
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) XXServiceDefDao(org.apache.ranger.db.XXServiceDefDao) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) Test(org.junit.Test)

Aggregations

RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)105 Test (org.junit.Test)52 ArrayList (java.util.ArrayList)38 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)19 XXServiceDef (org.apache.ranger.entity.XXServiceDef)18 Date (java.util.Date)15 HashMap (java.util.HashMap)13 ServicePolicies (org.apache.ranger.plugin.util.ServicePolicies)13 RangerService (org.apache.ranger.plugin.model.RangerService)12 RangerResourceDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerResourceDef)12 RangerServiceConfigDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerServiceConfigDef)12 RangerAccessTypeDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef)11 VXString (org.apache.ranger.view.VXString)10 RangerPolicyItem (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItem)9 RangerContextEnricherDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerContextEnricherDef)9 RangerPolicyConditionDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerPolicyConditionDef)9 RangerPolicyItemAccess (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess)8 RangerPolicyResource (org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyResource)8 RangerEnumDef (org.apache.ranger.plugin.model.RangerServiceDef.RangerEnumDef)8 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)7