Search in sources :

Example 21 with RangerService

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

the class TestPublicAPIsv2 method test13updateService.

@Test
public void test13updateService() throws Exception {
    RangerService rangerService = rangerService();
    HttpServletRequest request = null;
    Mockito.when(serviceREST.updateService(rangerService, request)).thenReturn(rangerService);
    RangerService dbRangerService = publicAPIsv2.updateService(rangerService, Id, request);
    Assert.assertNotNull(dbRangerService);
    Assert.assertEquals(dbRangerService, rangerService);
    Assert.assertEquals(dbRangerService.getId(), rangerService.getId());
    Assert.assertEquals(dbRangerService.getName(), rangerService.getName());
    Mockito.verify(serviceREST).updateService(rangerService, request);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Example 22 with RangerService

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

the class TestPublicAPIsv2 method test16deleteServiceByName.

@Test
public void test16deleteServiceByName() throws Exception {
    RangerService rangerService = rangerService();
    String name = rangerService.getName();
    Mockito.when(serviceREST.getServiceByName(name)).thenReturn(rangerService);
    Mockito.doNothing().when(serviceREST).deleteService(rangerService.getId());
    publicAPIsv2.deleteServiceByName(name);
    Mockito.verify(serviceREST).deleteService(rangerService.getId());
    Mockito.verify(serviceREST).getServiceByName(name);
}
Also used : RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Example 23 with RangerService

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

the class TestPublicAPIsv2 method rangerService.

private RangerService rangerService() {
    Map<String, String> configs = new HashMap<String, String>();
    configs.put("username", "servicemgr");
    configs.put("password", "servicemgr");
    configs.put("namenode", "servicemgr");
    configs.put("hadoop.security.authorization", "No");
    configs.put("hadoop.security.authentication", "Simple");
    configs.put("hadoop.security.auth_to_local", "");
    configs.put("dfs.datanode.kerberos.principal", "");
    configs.put("dfs.namenode.kerberos.principal", "");
    configs.put("dfs.secondary.namenode.kerberos.principal", "");
    configs.put("hadoop.rpc.protection", "Privacy");
    configs.put("commonNameForCertificate", "");
    RangerService rangerService = new RangerService();
    rangerService.setId(Id);
    rangerService.setConfigs(configs);
    rangerService.setCreateTime(new Date());
    rangerService.setDescription("service policy");
    rangerService.setGuid("1427365526516_835_0");
    rangerService.setIsEnabled(true);
    rangerService.setName("HDFS_1");
    rangerService.setPolicyUpdateTime(new Date());
    rangerService.setType("1");
    rangerService.setUpdatedBy("Admin");
    rangerService.setUpdateTime(new Date());
    return rangerService;
}
Also used : HashMap(java.util.HashMap) RangerService(org.apache.ranger.plugin.model.RangerService) Date(java.util.Date)

Example 24 with RangerService

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

the class TestPublicAPIsv2 method test9getService.

@Test
public void test9getService() throws Exception {
    RangerService rangerService = rangerService();
    Mockito.when(serviceREST.getService(rangerService.getId())).thenReturn(rangerService);
    RangerService dbRangerService = publicAPIsv2.getService(Id);
    Assert.assertNotNull(dbRangerService);
    Assert.assertEquals(dbRangerService, rangerService);
    Assert.assertEquals(dbRangerService.getId(), rangerService.getId());
    Assert.assertEquals(dbRangerService.getName(), rangerService.getName());
    Mockito.verify(serviceREST).getService(Id);
}
Also used : RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Example 25 with RangerService

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

the class TestPublicAPIsv2 method test14updateServiceByName.

@Test
public void test14updateServiceByName() throws Exception {
    RangerService rangerService = rangerService();
    HttpServletRequest request = null;
    String name = rangerService.getName();
    Mockito.when(serviceREST.getServiceByName(name)).thenReturn(rangerService);
    Mockito.when(serviceREST.updateService(rangerService, request)).thenReturn(rangerService);
    RangerService dbRangerService = publicAPIsv2.updateServiceByName(rangerService, name, request);
    Assert.assertNotNull(dbRangerService);
    Assert.assertEquals(dbRangerService, rangerService);
    Assert.assertEquals(dbRangerService.getId(), rangerService.getId());
    Assert.assertEquals(dbRangerService.getName(), rangerService.getName());
    Mockito.verify(serviceREST).updateService(rangerService, request);
    Mockito.verify(serviceREST).getServiceByName(name);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Aggregations

RangerService (org.apache.ranger.plugin.model.RangerService)163 Test (org.junit.Test)85 RangerPolicy (org.apache.ranger.plugin.model.RangerPolicy)52 ArrayList (java.util.ArrayList)39 WebApplicationException (javax.ws.rs.WebApplicationException)30 XXServiceDef (org.apache.ranger.entity.XXServiceDef)26 SearchFilter (org.apache.ranger.plugin.util.SearchFilter)24 VXString (org.apache.ranger.view.VXString)24 XXService (org.apache.ranger.entity.XXService)23 Path (javax.ws.rs.Path)22 Produces (javax.ws.rs.Produces)21 Date (java.util.Date)20 HashMap (java.util.HashMap)16 XXServiceDefDao (org.apache.ranger.db.XXServiceDefDao)16 HttpServletRequest (javax.servlet.http.HttpServletRequest)15 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)14 IOException (java.io.IOException)12 GET (javax.ws.rs.GET)12 XXTrxLog (org.apache.ranger.entity.XXTrxLog)12 RangerServiceDef (org.apache.ranger.plugin.model.RangerServiceDef)12