Search in sources :

Example 1 with StandaloneAuthorizationManagerClient

use of org.wso2.carbon.apimgt.impl.utils.StandaloneAuthorizationManagerClient in project carbon-apimgt by wso2.

the class StandaloneAuthorizationManagerClientTestCase method testGetRolesOfUser.

@Test
public void testGetRolesOfUser() throws Exception {
    StandaloneAuthorizationManagerClient standaloneAuthorizationManagerClient = new StandaloneAuthorizationManagerClient();
    standaloneAuthorizationManagerClient.getRolesOfUser("john");
    Mockito.verify(userStoreManager, Mockito.times(1)).getRoleListOfUser("john");
}
Also used : StandaloneAuthorizationManagerClient(org.wso2.carbon.apimgt.impl.utils.StandaloneAuthorizationManagerClient) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with StandaloneAuthorizationManagerClient

use of org.wso2.carbon.apimgt.impl.utils.StandaloneAuthorizationManagerClient in project carbon-apimgt by wso2.

the class StandaloneAuthorizationManagerClientTestCase method testGetRolesOfUserException.

@Test(expected = APIManagementException.class)
public void testGetRolesOfUserException() throws Exception {
    StandaloneAuthorizationManagerClient standaloneAuthorizationManagerClient = new StandaloneAuthorizationManagerClient();
    Mockito.when(userStoreManager.getRoleListOfUser("john")).thenThrow(new UserStoreException());
    standaloneAuthorizationManagerClient.getRolesOfUser("john");
}
Also used : StandaloneAuthorizationManagerClient(org.wso2.carbon.apimgt.impl.utils.StandaloneAuthorizationManagerClient) UserStoreException(org.wso2.carbon.user.core.UserStoreException) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with StandaloneAuthorizationManagerClient

use of org.wso2.carbon.apimgt.impl.utils.StandaloneAuthorizationManagerClient in project carbon-apimgt by wso2.

the class StandaloneAuthorizationManagerClientTestCase method testIsUserAuthorizedException.

@Test(expected = APIManagementException.class)
public void testIsUserAuthorizedException() throws Exception {
    StandaloneAuthorizationManagerClient standaloneAuthorizationManagerClient = new StandaloneAuthorizationManagerClient();
    Mockito.when(authorizationManager.isUserAuthorized("john", "create", CarbonConstants.UI_PERMISSION_ACTION)).thenThrow(new UserStoreException());
    standaloneAuthorizationManagerClient.isUserAuthorized("john", "create");
}
Also used : StandaloneAuthorizationManagerClient(org.wso2.carbon.apimgt.impl.utils.StandaloneAuthorizationManagerClient) UserStoreException(org.wso2.carbon.user.core.UserStoreException) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with StandaloneAuthorizationManagerClient

use of org.wso2.carbon.apimgt.impl.utils.StandaloneAuthorizationManagerClient in project carbon-apimgt by wso2.

the class StandaloneAuthorizationManagerClientTestCase method testIsUserAuthorized.

@Test
public void testIsUserAuthorized() throws Exception {
    StandaloneAuthorizationManagerClient standaloneAuthorizationManagerClient = new StandaloneAuthorizationManagerClient();
    standaloneAuthorizationManagerClient.isUserAuthorized("john", "create");
    Mockito.verify(authorizationManager, Mockito.times(1)).isUserAuthorized("john", "create", CarbonConstants.UI_PERMISSION_ACTION);
}
Also used : StandaloneAuthorizationManagerClient(org.wso2.carbon.apimgt.impl.utils.StandaloneAuthorizationManagerClient) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with StandaloneAuthorizationManagerClient

use of org.wso2.carbon.apimgt.impl.utils.StandaloneAuthorizationManagerClient in project carbon-apimgt by wso2.

the class StandaloneAuthorizationManagerClientTestCase method testGetRoleNames.

@Test
public void testGetRoleNames() throws Exception {
    StandaloneAuthorizationManagerClient standaloneAuthorizationManagerClient = new StandaloneAuthorizationManagerClient();
    standaloneAuthorizationManagerClient.getRoleNames();
    Mockito.verify(userStoreManager, Mockito.times(1)).getRoleNames();
}
Also used : StandaloneAuthorizationManagerClient(org.wso2.carbon.apimgt.impl.utils.StandaloneAuthorizationManagerClient) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Test (org.junit.Test)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 StandaloneAuthorizationManagerClient (org.wso2.carbon.apimgt.impl.utils.StandaloneAuthorizationManagerClient)6 UserStoreException (org.wso2.carbon.user.core.UserStoreException)3