Search in sources :

Example 36 with VXResponse

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

the class TestRangerBizUtil method testHasPermission_When_NoResource.

@Test
public void testHasPermission_When_NoResource() {
    VXResource vXResource = null;
    VXResponse resp = rangerBizUtil.hasPermission(vXResource, AppConstants.XA_PERM_TYPE_UNKNOWN);
    Assert.assertNotNull(resp);
    Assert.assertEquals(VXResponse.STATUS_ERROR, resp.getStatusCode());
    Assert.assertEquals("Please provide valid policy.", resp.getMsgDesc());
}
Also used : VXResponse(org.apache.ranger.view.VXResponse) VXResource(org.apache.ranger.view.VXResource) Test(org.junit.Test)

Example 37 with VXResponse

use of org.apache.ranger.view.VXResponse 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 38 with VXResponse

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

the class TestUserMgr method test13ChangePasswordAsAdmin.

@Test
public void test13ChangePasswordAsAdmin() {
    setup();
    XXPortalUserDao userDao = Mockito.mock(XXPortalUserDao.class);
    VXPortalUser userProfile = userProfile();
    VXPasswordChange pwdChange = new VXPasswordChange();
    pwdChange.setId(userProfile.getId());
    pwdChange.setLoginId(userProfile.getLoginId());
    pwdChange.setOldPassword(userProfile.getPassword());
    pwdChange.setEmailAddress(userProfile.getEmailAddress());
    pwdChange.setUpdPassword(userProfile.getPassword());
    XXPortalUser user = new XXPortalUser();
    Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
    Mockito.when(userDao.findByLoginId(Mockito.nullable(String.class))).thenReturn(user);
    Mockito.when(stringUtil.equals(Mockito.anyString(), Mockito.nullable(String.class))).thenReturn(true);
    Mockito.when(daoManager.getXXPortalUser()).thenReturn(userDao);
    Mockito.when(stringUtil.validatePassword(Mockito.anyString(), Mockito.any(String[].class))).thenReturn(true);
    VXResponse dbVXResponse = userMgr.changePassword(pwdChange);
    Assert.assertNotNull(dbVXResponse);
    Assert.assertEquals(userProfile.getStatus(), dbVXResponse.getStatusCode());
    Mockito.verify(stringUtil).equals(Mockito.anyString(), Mockito.nullable(String.class));
    Mockito.verify(stringUtil).validatePassword(Mockito.anyString(), Mockito.any(String[].class));
}
Also used : VXResponse(org.apache.ranger.view.VXResponse) XXPortalUser(org.apache.ranger.entity.XXPortalUser) VXPasswordChange(org.apache.ranger.view.VXPasswordChange) XXPortalUserDao(org.apache.ranger.db.XXPortalUserDao) VXPortalUser(org.apache.ranger.view.VXPortalUser) VXString(org.apache.ranger.view.VXString) Test(org.junit.Test)

Example 39 with VXResponse

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

the class TestAssetREST method testConfigTest.

@Test
public void testConfigTest() {
    RangerService rangerService = rangerService(Id);
    VXResponse expectedVxResponse = new VXResponse();
    expectedVxResponse.setStatusCode(VXResponse.STATUS_SUCCESS);
    expectedVxResponse.setMsgDesc("test connection successful");
    VXAsset vXAsset = vXAsset(Id);
    Mockito.when(serviceUtil.toRangerService(vXAsset)).thenReturn(rangerService);
    Mockito.when(serviceREST.validateConfig(rangerService)).thenReturn(expectedVxResponse);
    VXResponse actualVxResponse = assetREST.configTest(vXAsset);
    Assert.assertNotNull(actualVxResponse);
    Assert.assertEquals(expectedVxResponse, actualVxResponse);
    Mockito.verify(serviceUtil).toRangerService(vXAsset);
    Mockito.verify(serviceREST).validateConfig(rangerService);
}
Also used : VXResponse(org.apache.ranger.view.VXResponse) VXAsset(org.apache.ranger.view.VXAsset) RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Example 40 with VXResponse

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

the class TestServiceREST method test35validateConfig.

@Test
public void test35validateConfig() throws Exception {
    RangerService rangerService = rangerService();
    Mockito.when(serviceMgr.validateConfig(rangerService, svcStore)).thenReturn(vXResponse);
    VXResponse dbVXResponse = serviceREST.validateConfig(rangerService);
    Assert.assertNotNull(dbVXResponse);
    Mockito.verify(serviceMgr).validateConfig(rangerService, svcStore);
}
Also used : VXResponse(org.apache.ranger.view.VXResponse) RangerService(org.apache.ranger.plugin.model.RangerService) Test(org.junit.Test)

Aggregations

VXResponse (org.apache.ranger.view.VXResponse)40 Test (org.junit.Test)13 ArrayList (java.util.ArrayList)12 WebApplicationException (javax.ws.rs.WebApplicationException)10 XXPortalUser (org.apache.ranger.entity.XXPortalUser)7 VXMessage (org.apache.ranger.view.VXMessage)7 VXString (org.apache.ranger.view.VXString)7 IOException (java.io.IOException)6 VXResource (org.apache.ranger.view.VXResource)6 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 RESTResponse (org.apache.ranger.admin.client.datatype.RESTResponse)5 UserSessionBase (org.apache.ranger.common.UserSessionBase)5 XXPortalUserDao (org.apache.ranger.db.XXPortalUserDao)5 XXResource (org.apache.ranger.entity.XXResource)5 POST (javax.ws.rs.POST)4 Response (javax.ws.rs.core.Response)3 RangerPerfTracer (org.apache.ranger.plugin.util.RangerPerfTracer)3 VXPasswordChange (org.apache.ranger.view.VXPasswordChange)3 VXPortalUser (org.apache.ranger.view.VXPortalUser)3