Search in sources :

Example 6 with MockSecurityHelper

use of org.pentaho.test.platform.engine.security.MockSecurityHelper in project data-access by pentaho.

the class DatasourceWebServicesSecurityTest method setUp.

@Before
public void setUp() throws Exception {
    manager = new MockBackingRepositoryLifecycleManager(new MockSecurityHelper());
    repo = context.mock(IUnifiedRepository.class);
    booter = new MicroPlatform("target/test-classes/solution1");
    booter.define(IPasswordService.class, KettlePasswordService.class, Scope.GLOBAL);
    booter.define(IDatabaseConnection.class, DatabaseConnection.class, Scope.GLOBAL);
    booter.define(IDatabaseDialectService.class, DatabaseDialectService.class, Scope.GLOBAL);
    booter.define(IMondrianCatalogService.class, MondrianCatalogHelper.class, Scope.GLOBAL);
    booter.define(ICacheManager.class, CacheManager.class, Scope.GLOBAL);
    booter.defineInstance(IUserRoleListService.class, context.mock(IUserRoleListService.class));
    final IAuthorizationPolicy policy = context.mock(IAuthorizationPolicy.class);
    booter.defineInstance(IAuthorizationPolicy.class, policy);
    booter.defineInstance(IUnifiedRepository.class, repo);
    booter.setSettingsProvider(new SystemSettings());
    booter.start();
    context.checking(new Expectations() {

        {
            oneOf(policy);
            will(returnValue(false));
            oneOf(policy);
            will(returnValue(false));
            oneOf(policy);
            will(returnValue(false));
        }
    });
    PentahoSessionHolder.setStrategyName(PentahoSessionHolder.MODE_GLOBAL);
    SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL);
}
Also used : MockSecurityHelper(org.pentaho.test.platform.engine.security.MockSecurityHelper) Expectations(org.jmock.Expectations) IAuthorizationPolicy(org.pentaho.platform.api.engine.IAuthorizationPolicy) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) IUserRoleListService(org.pentaho.platform.api.engine.IUserRoleListService) SystemSettings(org.pentaho.platform.engine.core.system.SystemSettings) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Before(org.junit.Before)

Aggregations

MockSecurityHelper (org.pentaho.test.platform.engine.security.MockSecurityHelper)6 Before (org.junit.Before)4 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)4 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)4 IUserRoleListService (org.pentaho.platform.api.engine.IUserRoleListService)3 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)3 SystemSettings (org.pentaho.platform.engine.core.system.SystemSettings)3 File (java.io.File)2 Expectations (org.jmock.Expectations)2 Matchers.anyString (org.mockito.Matchers.anyString)2 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)2 PluginClassLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader)2 PluginResourceLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader)2 Mockery (org.jmock.Mockery)1 JUnit4Mockery (org.jmock.integration.junit4.JUnit4Mockery)1 ICacheManager (org.pentaho.platform.api.engine.ICacheManager)1 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)1 ITenant (org.pentaho.platform.api.mt.ITenant)1 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)1 Tenant (org.pentaho.platform.core.mt.Tenant)1