Search in sources :

Example 6 with Action

use of org.apache.wicket.authorization.Action in project wicket by apache.

the class ActionPermissionsTest method testAdd1.

/**
 * Test adding roles.
 *
 * @throws Exception
 */
@Test
public void testAdd1() throws Exception {
    ActionPermissions permissions = new ActionPermissions();
    Action mambo = new Action("mambo");
    permissions.authorize(mambo, new Roles("jonathan"));
    permissions.authorize(mambo, new Roles("johan"));
    permissions.authorize(mambo, new Roles("maurice"));
    permissions.authorize(mambo, new Roles("eelco"));
    assertEquals(4, permissions.rolesFor(mambo).size());
    permissions.unauthorize(mambo, new Roles("maurice"));
    assertEquals(3, permissions.rolesFor(mambo).size());
    permissions.authorizeAll(mambo);
    assertEquals(null, permissions.rolesFor(mambo));
}
Also used : Action(org.apache.wicket.authorization.Action) Roles(org.apache.wicket.authroles.authorization.strategies.role.Roles) Test(org.junit.Test)

Aggregations

Action (org.apache.wicket.authorization.Action)6 Test (org.junit.Test)6 Roles (org.apache.wicket.authroles.authorization.strategies.role.Roles)4 IAuthorizationStrategy (org.apache.wicket.authorization.IAuthorizationStrategy)2 IRoleCheckingStrategy (org.apache.wicket.authroles.authorization.strategies.role.IRoleCheckingStrategy)2 Label (org.apache.wicket.markup.html.basic.Label)2 Component (org.apache.wicket.Component)1 WebComponent (org.apache.wicket.markup.html.WebComponent)1 TextField (org.apache.wicket.markup.html.form.TextField)1 MockApplication (org.apache.wicket.mock.MockApplication)1 IRequestableComponent (org.apache.wicket.request.component.IRequestableComponent)1 WicketTester (org.apache.wicket.util.tester.WicketTester)1