Search in sources :

Example 6 with UserRealmInfo

use of org.wso2.carbon.user.mgt.stub.types.carbon.UserRealmInfo in project carbon-identity-framework by wso2.

the class UserRealmProxyTest method testGetUserRealmInfo.

@Test
public void testGetUserRealmInfo() throws Exception {
    Mockito.when(realm.getAuthorizationManager()).thenReturn(authorizationManager);
    Mockito.when(realm.getClaimManager()).thenReturn(claimManager);
    Mockito.when(authorizationManager.isUserAuthorized("admin", "/permission/admin/manage/identity", CarbonConstants.UI_PERMISSION_ACTION)).thenReturn(true);
    Mockito.when(realm.getRealmConfiguration()).thenReturn(this.getSampleRelaimConfiguration());
    Mockito.when(realm.getUserStoreManager()).thenReturn(userStoreManagerWithAb);
    ClaimMapping claimMapping = new ClaimMapping();
    claimMapping.setMappedAttribute("test1");
    claimMapping.setMappedAttribute("test2");
    claimMapping.setMappedAttribute("test3");
    Claim claim = new Claim();
    claim.setClaimUri("testURI");
    claim.setValue("testClaim");
    claimMapping.setClaim(claim);
    Mockito.when(claimManager.getAllClaimMappings(UserCoreConstants.DEFAULT_CARBON_DIALECT)).thenReturn(new ClaimMapping[] { claimMapping });
    Mockito.when(userStoreManagerWithAb.getRealmConfiguration()).thenReturn(this.getSampleRelaimConfiguration());
    Mockito.when(userStoreManagerWithAb.isBulkImportSupported()).thenReturn(false);
    UserRealmInfo realmInfo = userRealmProxy.getUserRealmInfo();
    Assert.assertEquals(realmInfo.getEveryOneRole(), "everyone");
    Assert.assertEquals(realmInfo.getAdminRole(), "admin");
}
Also used : ClaimMapping(org.wso2.carbon.user.api.ClaimMapping) UserRealmInfo(org.wso2.carbon.user.mgt.common.UserRealmInfo) Claim(org.wso2.carbon.user.api.Claim) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

UserRealmInfo (org.wso2.carbon.user.mgt.stub.types.carbon.UserRealmInfo)4 Test (org.testng.annotations.Test)3 ArrayList (java.util.ArrayList)2 Claim (org.wso2.carbon.user.api.Claim)2 ClaimMapping (org.wso2.carbon.user.api.ClaimMapping)2 UserRealmInfo (org.wso2.carbon.user.mgt.common.UserRealmInfo)2 ISIntegrationTest (org.wso2.identity.integration.common.utils.ISIntegrationTest)2 Gson (com.google.gson.Gson)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 ResourceBundle (java.util.ResourceBundle)1 ServletException (javax.servlet.ServletException)1 HttpSession (javax.servlet.http.HttpSession)1 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 BeforeTest (org.testng.annotations.BeforeTest)1 SetEnvironment (org.wso2.carbon.automation.engine.annotations.SetEnvironment)1 RegistryException (org.wso2.carbon.registry.api.RegistryException)1