Search in sources :

Example 16 with ActionConfig

use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.

the class TestCopyFormToContext method setUp.

/*
     * @see TestCase#setUp()
     */
protected void setUp() throws Exception {
    context = new MockActionContext();
    ModuleConfigImpl moduleConfig = new ModuleConfigImpl("/");
    context.setModuleConfig(moduleConfig);
    FormBeanConfig fooFBC = new FormBeanConfig();
    fooFBC.setName("foo");
    fooFBC.setType("org.apache.struts.mock.MockFormBean");
    moduleConfig.addFormBeanConfig(fooFBC);
    FormBeanConfig barFBC = new FormBeanConfig();
    barFBC.setName("bar");
    // use a different type so we can verify lookups better
    barFBC.setType("org.apache.struts.action.DynaActionForm");
    FormPropertyConfig fpc = new FormPropertyConfig();
    fpc.setName("property");
    fpc.setType("java.lang.String");
    fpc.setInitial("test");
    barFBC.addFormPropertyConfig(fpc);
    moduleConfig.addFormBeanConfig(barFBC);
    ActionConfig testActionConfig = new ActionConfig();
    testActionConfig.setPath("/Test");
    testActionConfig.setName("foo");
    testActionConfig.setScope("request");
    moduleConfig.addActionConfig(testActionConfig);
    // otherwise, ActionConfigMatcher will be null and we'll get an NPE...
    moduleConfig.freeze();
}
Also used : FormPropertyConfig(org.apache.struts.config.FormPropertyConfig) ActionConfig(org.apache.struts.config.ActionConfig) FormBeanConfig(org.apache.struts.config.FormBeanConfig) MockActionContext(org.apache.struts.chain.contexts.MockActionContext) ModuleConfigImpl(org.apache.struts.config.impl.ModuleConfigImpl)

Example 17 with ActionConfig

use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.

the class TestAuthorizeAction method testAuthorizeNoRoles.

public void testAuthorizeNoRoles() throws Exception {
    ActionConfig config = new ActionConfig();
    config.setPath("/testAuthorizeNoRoles");
    this.saContext.setActionConfig(config);
    boolean result = command.execute(saContext);
    assertFalse(result);
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig)

Example 18 with ActionConfig

use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.

the class TestAuthorizeAction method testAuthorizeOneRole.

public void testAuthorizeOneRole() throws Exception {
    ActionConfig config = new ActionConfig();
    config.setPath("/testAuthorizeOneRole");
    config.setRoles("administrator");
    this.saContext.setActionConfig(config);
    boolean result = command.execute(saContext);
    assertFalse(result);
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig)

Example 19 with ActionConfig

use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.

the class TestAuthorizeAction method testAuthorizeOneOfManyRoles.

public void testAuthorizeOneOfManyRoles() throws Exception {
    ActionConfig config = new ActionConfig();
    config.setPath("/testAuthorizeOneOfManyRoles");
    config.setRoles("administrator,roustabout,memory");
    this.saContext.setActionConfig(config);
    boolean result = command.execute(saContext);
    assertFalse(result);
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig)

Example 20 with ActionConfig

use of org.apache.struts.config.ActionConfig in project sonarqube by SonarSource.

the class TestAuthorizeAction method testNotAuthorizedOneRole.

public void testNotAuthorizedOneRole() throws Exception {
    ActionConfig config = new ActionConfig();
    config.setPath("/testNotAuthorizedOneRole");
    config.setRoles("roustabout");
    this.saContext.setActionConfig(config);
    try {
        boolean result = command.execute(saContext);
    } catch (UnauthorizedActionException ex) {
    }
}
Also used : ActionConfig(org.apache.struts.config.ActionConfig) UnauthorizedActionException(org.apache.struts.chain.commands.UnauthorizedActionException)

Aggregations

ActionConfig (org.apache.struts.config.ActionConfig)76 ForwardConfig (org.apache.struts.config.ForwardConfig)14 UnavailableException (javax.servlet.UnavailableException)8 ActionForm (org.apache.struts.action.ActionForm)8 ExceptionConfig (org.apache.struts.config.ExceptionConfig)8 FormBeanConfig (org.apache.struts.config.FormBeanConfig)8 ModuleConfig (org.apache.struts.config.ModuleConfig)8 ServletException (javax.servlet.ServletException)6 MalformedURLException (java.net.MalformedURLException)4 Map (java.util.Map)4 Action (org.apache.struts.action.Action)4 UnauthorizedActionException (org.apache.struts.chain.commands.UnauthorizedActionException)4 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 MissingResourceException (java.util.MissingResourceException)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 JspException (javax.servlet.jsp.JspException)2 ActionErrors (org.apache.struts.action.ActionErrors)2 MockActionContext (org.apache.struts.chain.contexts.MockActionContext)2 ServletActionContext (org.apache.struts.chain.contexts.ServletActionContext)2