Search in sources :

Example 16 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class TestRangerServiceServiceBase method service.

private XXService service() {
    XXService xService = new XXService();
    xService.setAddedByUserId(Id);
    xService.setCreateTime(new Date());
    xService.setDescription("Hdfs service");
    xService.setGuid("serviceguid");
    xService.setId(Id);
    xService.setIsEnabled(true);
    xService.setName("Hdfs");
    xService.setPolicyUpdateTime(new Date());
    xService.setPolicyVersion(1L);
    xService.setType(1L);
    xService.setUpdatedByUserId(Id);
    xService.setUpdateTime(new Date());
    return xService;
}
Also used : XXService(org.apache.ranger.entity.XXService) Date(java.util.Date)

Example 17 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class TestPublicAPIs method xService.

private XXService xService() {
    XXService xService = new XXService();
    xService.setAddedByUserId(Id);
    xService.setCreateTime(new Date());
    xService.setDescription("Hdfs service");
    xService.setGuid("serviceguid");
    xService.setId(Id);
    xService.setIsEnabled(true);
    xService.setName("Hdfs");
    xService.setPolicyUpdateTime(new Date());
    xService.setPolicyVersion(1L);
    xService.setType(1L);
    xService.setUpdatedByUserId(Id);
    xService.setUpdateTime(new Date());
    return xService;
}
Also used : XXService(org.apache.ranger.entity.XXService) Date(java.util.Date)

Example 18 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class TestServiceREST method test17updatePolicyFalse.

@Test
public void test17updatePolicyFalse() throws Exception {
    RangerPolicy rangerPolicy = rangerPolicy();
    String userName = "admin";
    Set<String> userGroupsList = new HashSet<String>();
    userGroupsList.add("group1");
    userGroupsList.add("group2");
    List<RangerAccessTypeDef> rangerAccessTypeDefList = new ArrayList<RangerServiceDef.RangerAccessTypeDef>();
    RangerAccessTypeDef rangerAccessTypeDefObj = new RangerAccessTypeDef();
    rangerAccessTypeDefObj.setLabel("Read");
    rangerAccessTypeDefObj.setName("read");
    rangerAccessTypeDefObj.setRbKeyLabel(null);
    rangerAccessTypeDefList.add(rangerAccessTypeDefObj);
    XXServiceDef xServiceDef = serviceDef();
    XXService xService = xService();
    XXServiceDefDao xServiceDefDao = Mockito.mock(XXServiceDefDao.class);
    XXServiceDao xServiceDao = Mockito.mock(XXServiceDao.class);
    Mockito.when(validatorFactory.getPolicyValidator(svcStore)).thenReturn(policyValidator);
    Mockito.when(bizUtil.isAdmin()).thenReturn(true);
    Mockito.when(bizUtil.getCurrentUserLoginId()).thenReturn(userName);
    Mockito.when(daoManager.getXXService()).thenReturn(xServiceDao);
    Mockito.when(xServiceDao.findByName(Mockito.anyString())).thenReturn(xService);
    Mockito.when(daoManager.getXXServiceDef()).thenReturn(xServiceDefDao);
    Mockito.when(xServiceDefDao.getById(xService.getType())).thenReturn(xServiceDef);
    RangerPolicy dbRangerPolicy = serviceREST.updatePolicy(rangerPolicy);
    Assert.assertNull(dbRangerPolicy);
    Mockito.verify(validatorFactory).getPolicyValidator(svcStore);
}
Also used : RangerAccessTypeDef(org.apache.ranger.plugin.model.RangerServiceDef.RangerAccessTypeDef) XXServiceDef(org.apache.ranger.entity.XXServiceDef) RangerPolicy(org.apache.ranger.plugin.model.RangerPolicy) XXServiceDefDao(org.apache.ranger.db.XXServiceDefDao) RangerServiceDef(org.apache.ranger.plugin.model.RangerServiceDef) ArrayList(java.util.ArrayList) VXString(org.apache.ranger.view.VXString) XXService(org.apache.ranger.entity.XXService) XXServiceDao(org.apache.ranger.db.XXServiceDao) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 19 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class TestServiceREST method xService.

private XXService xService() {
    XXService xService = new XXService();
    xService.setAddedByUserId(Id);
    xService.setCreateTime(new Date());
    xService.setDescription("Hdfs service");
    xService.setGuid("serviceguid");
    xService.setId(Id);
    xService.setIsEnabled(true);
    xService.setName("Hdfs");
    xService.setPolicyUpdateTime(new Date());
    xService.setPolicyVersion(1L);
    xService.setType(1L);
    xService.setUpdatedByUserId(Id);
    xService.setUpdateTime(new Date());
    return xService;
}
Also used : XXService(org.apache.ranger.entity.XXService) Date(java.util.Date)

Example 20 with XXService

use of org.apache.ranger.entity.XXService in project ranger by apache.

the class TestTagREST method test56getSecureServiceTagsIfUpdatedIsAllowedFalse.

@Test
public void test56getSecureServiceTagsIfUpdatedIsAllowedFalse() {
    boolean isAdmin = false;
    boolean isKeyAdmin = false;
    boolean isAllowed = false;
    ServiceTags oldServiceTag = new ServiceTags();
    oldServiceTag.setServiceName(serviceName);
    oldServiceTag.setTagVersion(5L);
    XXService xService = new XXService();
    xService.setId(id);
    xService.setName(serviceName);
    xService.setType(5L);
    XXServiceDef xServiceDef = new XXServiceDef();
    xServiceDef.setId(id);
    xServiceDef.setVersion(5L);
    RangerService rangerService = new RangerService();
    rangerService.setId(id);
    rangerService.setName(serviceName);
    XXServiceDao xXServiceDao = Mockito.mock(XXServiceDao.class);
    XXServiceDefDao xXServiceDefDao = Mockito.mock(XXServiceDefDao.class);
    Mockito.when(bizUtil.isAdmin()).thenReturn(isAdmin);
    Mockito.when(bizUtil.isKeyAdmin()).thenReturn(isKeyAdmin);
    Mockito.when(daoManager.getXXService()).thenReturn(xXServiceDao);
    Mockito.when(xXServiceDao.findByName(serviceName)).thenReturn(xService);
    Mockito.when(daoManager.getXXServiceDef()).thenReturn(xXServiceDefDao);
    Mockito.when(xXServiceDefDao.getById(xService.getType())).thenReturn(xServiceDef);
    try {
        Mockito.when(svcStore.getServiceByName(serviceName)).thenReturn(rangerService);
    } catch (Exception e) {
    }
    Mockito.when(bizUtil.isUserAllowed(rangerService, Allowed_User_List_For_Tag_Download)).thenReturn(isAllowed);
    Mockito.when(restErrorUtil.createRESTException(Mockito.anyInt(), Mockito.anyString(), Mockito.anyBoolean())).thenThrow(new WebApplicationException());
    thrown.expect(WebApplicationException.class);
    tagREST.getSecureServiceTagsIfUpdated(serviceName, lastKnownVersion, 0L, pluginId, null);
    Mockito.verify(bizUtil).isAdmin();
    Mockito.verify(bizUtil).isKeyAdmin();
    Mockito.verify(daoManager).getXXService();
    Mockito.verify(xXServiceDao).findByName(serviceName);
    Mockito.verify(daoManager).getXXServiceDef();
    Mockito.verify(xXServiceDefDao).getById(xService.getType());
    try {
        Mockito.verify(svcStore).getServiceByName(serviceName);
    } catch (Exception e) {
    }
    Mockito.verify(bizUtil).isUserAllowed(rangerService, Allowed_User_List_For_Tag_Download);
    Mockito.verify(restErrorUtil).createRESTException(Mockito.anyInt(), Mockito.anyString(), Mockito.anyBoolean());
}
Also used : XXServiceDef(org.apache.ranger.entity.XXServiceDef) XXServiceDefDao(org.apache.ranger.db.XXServiceDefDao) WebApplicationException(javax.ws.rs.WebApplicationException) ServiceTags(org.apache.ranger.plugin.util.ServiceTags) RangerService(org.apache.ranger.plugin.model.RangerService) XXService(org.apache.ranger.entity.XXService) XXServiceDao(org.apache.ranger.db.XXServiceDao) ExpectedException(org.junit.rules.ExpectedException) WebApplicationException(javax.ws.rs.WebApplicationException) Test(org.junit.Test)

Aggregations

XXService (org.apache.ranger.entity.XXService)73 XXServiceDef (org.apache.ranger.entity.XXServiceDef)34 RangerService (org.apache.ranger.plugin.model.RangerService)23 Test (org.junit.Test)21 XXServiceDao (org.apache.ranger.db.XXServiceDao)19 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)19 VXString (org.apache.ranger.view.VXString)19 XXServiceDefDao (org.apache.ranger.db.XXServiceDefDao)17 ArrayList (java.util.ArrayList)14 XXServiceVersionInfo (org.apache.ranger.entity.XXServiceVersionInfo)14 Date (java.util.Date)13 WebApplicationException (javax.ws.rs.WebApplicationException)11 IOException (java.io.IOException)9 ServiceTags (org.apache.ranger.plugin.util.ServiceTags)9 XXServiceVersionInfoDao (org.apache.ranger.db.XXServiceVersionInfoDao)7 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)7 UnknownHostException (java.net.UnknownHostException)6 XXServiceConfigMap (org.apache.ranger.entity.XXServiceConfigMap)6 JSONException (org.codehaus.jettison.json.JSONException)6 HashMap (java.util.HashMap)5