Search in sources :

Example 1 with ConnectionFactory

use of org.forgerock.openam.sm.datalayer.api.ConnectionFactory in project OpenAM by OpenRock.

the class UpgradeEntitlementSubConfigsStepTest method setUp.

@BeforeMethod
public void setUp() throws IllegalAccessException, InstantiationException {
    mockTypes = new HashSet<ApplicationType>(3);
    final ApplicationType type1 = newType("type1");
    final ApplicationType type2 = newType("type2");
    final ApplicationType type3 = newType("type3");
    mockTypes.addAll(Arrays.asList(type1, type2, type3));
    this.type1 = type1;
    mockApplications = new HashSet<Application>(3);
    final Application application1 = newApplication("application1", type1);
    final Application application2 = newApplication("application2", type1);
    final Application application3 = newApplication("application3", type1);
    mockApplications.addAll(Arrays.asList(application1, application2, application3));
    entitlementService = mock(EntitlementConfiguration.class);
    adminTokenAction = mock(PrivilegedAction.class);
    connectionFactory = mock(ConnectionFactory.class);
    resourceTypeConfiguration = mock(ResourceTypeConfiguration.class);
    upgradeStep = new SafeUpgradeEntitlementSubConfigsStep(entitlementService, resourceTypeConfiguration, adminTokenAction, connectionFactory);
    final HashSet<String> conditions = new HashSet<String>();
    conditions.add("condition.entry.1");
    conditions.add("condition.entry.2");
    final HashSet<String> subjects = new HashSet<String>();
    subjects.add("subject.entry.1");
    subjects.add("subject.entry.2");
    final HashSet<String> resources = new HashSet<String>();
    resources.add("http://*");
    resources.add("https://*");
    app = newApplication("application4", type1);
    app.setConditions(conditions);
    app.setSubjects(subjects);
    app.setEntitlementCombinerName(DEFAULT_COMBINER);
}
Also used : ApplicationType(com.sun.identity.entitlement.ApplicationType) ConnectionFactory(org.forgerock.openam.sm.datalayer.api.ConnectionFactory) PrivilegedAction(java.security.PrivilegedAction) EntitlementConfiguration(com.sun.identity.entitlement.EntitlementConfiguration) ResourceTypeConfiguration(org.forgerock.openam.entitlement.configuration.ResourceTypeConfiguration) Application(com.sun.identity.entitlement.Application) HashSet(java.util.HashSet) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with ConnectionFactory

use of org.forgerock.openam.sm.datalayer.api.ConnectionFactory in project OpenAM by OpenRock.

the class UpgradeResourceTypeStepTest method setUp.

@BeforeMethod
public void setUp() throws Exception {
    privilegedAction = mock(PrivilegedAction.class);
    resourceTypeService = mock(ResourceTypeService.class);
    connectionFactory = mock(ConnectionFactory.class);
    configManager = mock(ServiceConfigManager.class);
    upgradeResourceTypeStep = new UpgradeResourceTypeStep(configManager, resourceTypeService, privilegedAction, connectionFactory, Collections.<String>emptySet()) {

        @Override
        protected Document getEntitlementXML() throws UpgradeException {
            return document;
        }

        @Override
        protected Set<String> getRealmNamesFromParent() throws UpgradeException {
            return realms;
        }

        @Override
        protected Set<String> policiesEligibleForUpgrade(String appName, String realm) throws UpgradeException {
            return policies;
        }
    };
    when(document.getElementsByTagName(anyString())).thenReturn(new NodeList() {

        @Override
        public Node item(int i) {
            return null;
        }

        @Override
        public int getLength() {
            return 0;
        }
    });
    // Mock global and application type service configuration
    ServiceConfig globalConfig = mock(ServiceConfig.class);
    when(configManager.getGlobalConfig(anyString())).thenReturn(globalConfig);
    ServiceConfig appTypesConfig = mock(ServiceConfig.class);
    when(globalConfig.getSubConfig(anyString())).thenReturn(appTypesConfig);
    // Mock organisation and application service configuration
    ServiceConfig orgConfig = mock(ServiceConfig.class);
    when(configManager.getOrganizationConfig(anyString(), anyString())).thenReturn(orgConfig);
    ServiceConfig appsConfig = mock(ServiceConfig.class);
    when(orgConfig.getSubConfig(anyString())).thenReturn(appsConfig);
    // Mock application names
    when(appsConfig.getSubConfigNames()).thenReturn(Collections.singleton("MyApplication"));
    // Mock application data
    ServiceConfig appConfig = mock(ServiceConfig.class);
    when(appsConfig.getSubConfig("MyApplication")).thenReturn(appConfig);
    when(appConfig.getAttributes()).thenReturn(appData);
    // Mock application type on application and application type data
    ServiceConfig appTypeConfig = mock(ServiceConfig.class);
    when(appTypesConfig.getSubConfig("MyApplicationType")).thenReturn(appTypeConfig);
    when(appTypeConfig.getAttributes()).thenReturn(appTypeData);
    setupDataStructures();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) ResourceTypeService(org.forgerock.openam.entitlement.service.ResourceTypeService) Document(org.w3c.dom.Document) UpgradeException(org.forgerock.openam.upgrade.UpgradeException) ConnectionFactory(org.forgerock.openam.sm.datalayer.api.ConnectionFactory) PrivilegedAction(java.security.PrivilegedAction) ServiceConfig(com.sun.identity.sm.ServiceConfig) ServiceConfigManager(com.sun.identity.sm.ServiceConfigManager) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

PrivilegedAction (java.security.PrivilegedAction)2 HashSet (java.util.HashSet)2 ConnectionFactory (org.forgerock.openam.sm.datalayer.api.ConnectionFactory)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 Application (com.sun.identity.entitlement.Application)1 ApplicationType (com.sun.identity.entitlement.ApplicationType)1 EntitlementConfiguration (com.sun.identity.entitlement.EntitlementConfiguration)1 ServiceConfig (com.sun.identity.sm.ServiceConfig)1 ServiceConfigManager (com.sun.identity.sm.ServiceConfigManager)1 Set (java.util.Set)1 ResourceTypeConfiguration (org.forgerock.openam.entitlement.configuration.ResourceTypeConfiguration)1 ResourceTypeService (org.forgerock.openam.entitlement.service.ResourceTypeService)1 UpgradeException (org.forgerock.openam.upgrade.UpgradeException)1 Document (org.w3c.dom.Document)1 Node (org.w3c.dom.Node)1 NodeList (org.w3c.dom.NodeList)1