use of org.xwiki.rendering.transformation.MacroTransformationContext in project xwiki-platform by xwiki.
the class NestedScriptMacroValidatorTest method testNoNestedScript.
@Test
public void testNoNestedScript() throws Exception {
MacroTransformationContext context = buildContext("script", "script");
CancelableEvent event = new ScriptEvaluatingEvent();
this.validator.onEvent(event, context, null);
Assert.assertTrue(event.isCanceled());
}
use of org.xwiki.rendering.transformation.MacroTransformationContext in project xwiki-platform by xwiki.
the class NestedScriptMacroValidatorTest method testNestedScriptMacroEnabledInterceptsNestedChain.
@Test
public void testNestedScriptMacroEnabledInterceptsNestedChain() throws Exception {
MacroTransformationContext context = buildContext("script", "nestedscriptmacroenabled", "script");
CancelableEvent event = new ScriptEvaluatingEvent();
this.validator.onEvent(event, context, null);
Assert.assertFalse(event.isCanceled());
}
use of org.xwiki.rendering.transformation.MacroTransformationContext in project xwiki-platform by xwiki.
the class NestedScriptMacroValidatorTest method testIncludeInterceptsNestedChain.
@Test
public void testIncludeInterceptsNestedChain() throws Exception {
MacroTransformationContext context = buildContext("script", "include", "script");
CancelableEvent event = new ScriptEvaluatingEvent();
this.validator.onEvent(event, context, null);
Assert.assertFalse(event.isCanceled());
}
use of org.xwiki.rendering.transformation.MacroTransformationContext in project xwiki-platform by xwiki.
the class VelocityMacroSecurityTest method testRestrictedByContext.
@Test(expected = MacroExecutionException.class)
public void testRestrictedByContext() throws Exception {
VelocityMacroParameters params = new VelocityMacroParameters();
MacroTransformationContext context = new MacroTransformationContext();
context.setSyntax(Syntax.XWIKI_2_0);
context.setCurrentMacroBlock(new MacroBlock("velocity", Collections.<String, String>emptyMap(), false));
context.setId("page1");
// Restrict the transformation context.
context.getTransformationContext().setRestricted(true);
when(authorizationManager.hasAccess(Right.SCRIPT)).thenReturn(true);
mocker.getComponentUnderTest().execute(params, "#macro(testMacrosAreLocal)mymacro#end", context);
}
use of org.xwiki.rendering.transformation.MacroTransformationContext in project xwiki-platform by xwiki.
the class VelocityMacroSecurityTest method testRestrictedByRights.
@Test(expected = MacroExecutionException.class)
public void testRestrictedByRights() throws Exception {
VelocityMacroParameters params = new VelocityMacroParameters();
MacroTransformationContext context = new MacroTransformationContext();
context.setSyntax(Syntax.XWIKI_2_0);
context.setCurrentMacroBlock(new MacroBlock("velocity", Collections.<String, String>emptyMap(), false));
context.setId("page1");
context.getTransformationContext().setRestricted(false);
// Restrict the SCRIPT right.
when(authorizationManager.hasAccess(Right.SCRIPT)).thenReturn(false);
mocker.getComponentUnderTest().execute(params, "#macro(testMacrosAreLocal)mymacro#end", context);
verify(authorizationManager.hasAccess(Right.SCRIPT));
}
Aggregations