use of org.xwiki.configuration.ConfigurationSource in project xwiki-platform by xwiki.
the class VelocityContextInitializerTest method registerComponents.
@Override
protected void registerComponents() throws Exception {
super.registerComponents();
registerMockComponent(ScriptService.class, "officeimporter", "importer");
registerMockComponent(ScriptService.class, "officemanager", "manager");
final ConfigurationSource configurationSource = registerMockComponent(ConfigurationSource.class);
getMockery().checking(new Expectations() {
{
oneOf(configurationSource).getProperty("velocity.tools", Properties.class);
will(returnValue(new Properties()));
}
});
}
use of org.xwiki.configuration.ConfigurationSource in project xwiki-platform by xwiki.
the class ActivityStreamImpl method addHiddenEventsFilter.
/**
* This method will add a where clause to filter events fired from hidden documents. The clause will not be added to
* the query if the user has specified that he wish to see hidden documents in his profile. If the clause is added
* this method will also add a 'where' to the query if it is missing.
*
* @param query The query to add the filter to
*/
private void addHiddenEventsFilter(StringBuffer query) {
ConfigurationSource source = Utils.getComponent(ConfigurationSource.class, "user");
Integer preference = source.getProperty("displayHiddenDocuments", Integer.class);
if (preference == null || preference != 1) {
if (!query.toString().contains(" where ")) {
query.append(" where ");
}
query.append(" (act.hidden <> true or act.hidden is null) and ");
}
}
use of org.xwiki.configuration.ConfigurationSource in project xwiki-platform by xwiki.
the class SecureGroovyCompilationCustomizerTest method executeWithSecureCustomizerWhenProgrammingRights.
@Test
public void executeWithSecureCustomizerWhenProgrammingRights() throws Exception {
final ConfigurationSource source = registerMockComponent(ConfigurationSource.class);
final ContextualAuthorizationManager cam = registerMockComponent(ContextualAuthorizationManager.class);
getMockery().checking(new Expectations() {
{
oneOf(source).getProperty("groovy.compilationCustomizers", Collections.emptyList());
will(returnValue(Arrays.asList("secure")));
oneOf(cam).hasAccess(Right.PROGRAM);
will(returnValue(true));
}
});
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngineFactory groovyScriptEngineFactory = getComponentManager().getInstance(ScriptEngineFactory.class, "groovy");
manager.registerEngineName("groovy", groovyScriptEngineFactory);
final ScriptEngine engine = manager.getEngineByName("groovy");
// Verify that the Secure AST Customizer is not active by running a Groovy script that raise an exception
// when the Secure AST Customizer is active
engine.eval("synchronized(this) { }");
}
use of org.xwiki.configuration.ConfigurationSource in project xwiki-platform by xwiki.
the class SecureGroovyCompilationCustomizerTest method setUpWhenNoProgrammingRights.
private void setUpWhenNoProgrammingRights() throws Exception {
final ConfigurationSource source = registerMockComponent(ConfigurationSource.class);
final ContextualAuthorizationManager cam = registerMockComponent(ContextualAuthorizationManager.class);
getMockery().checking(new Expectations() {
{
oneOf(source).getProperty("groovy.compilationCustomizers", Collections.emptyList());
will(returnValue(Arrays.asList("secure")));
oneOf(cam).hasAccess(Right.PROGRAM);
will(returnValue(false));
}
});
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngineFactory groovyScriptEngineFactory = getComponentManager().getInstance(ScriptEngineFactory.class, "groovy");
manager.registerEngineName("groovy", groovyScriptEngineFactory);
this.engine = manager.getEngineByName("groovy");
}
use of org.xwiki.configuration.ConfigurationSource in project xwiki-platform by xwiki.
the class DefaultMailStorageConfigurationTest method discardSuccessStatusesFalseWhenDefinedInMailConfig.
@Test
public void discardSuccessStatusesFalseWhenDefinedInMailConfig() throws Exception {
ConfigurationSource mailConfigSource = this.mocker.getInstance(ConfigurationSource.class, "mailsend");
when(mailConfigSource.getProperty("discardSuccessStatuses")).thenReturn(0);
assertEquals(false, this.mocker.getComponentUnderTest().discardSuccessStatuses());
}
Aggregations