use of org.apache.wicket.authroles.authorization.strategies.role.IRoleCheckingStrategy in project wicket by apache.
the class InstantiationPermissionsTest method testRemove3.
/**
* Test consistency in behavior between authorizing a role for a class and then unauthorizing it
* with {@link #testRemove2()}.
*/
@Test
public void testRemove3() {
MetaDataRoleAuthorizationStrategy strategy = new MetaDataRoleAuthorizationStrategy(new IRoleCheckingStrategy() {
@Override
public boolean hasAnyRole(Roles roles) {
return false;
}
});
tester.getApplication().setMetaData(MetaDataRoleAuthorizationStrategy.INSTANTIATION_PERMISSIONS, new InstantiationPermissions());
MetaDataRoleAuthorizationStrategy.authorize(Page.class, "martijn");
MetaDataRoleAuthorizationStrategy.unauthorize(Page.class, "martijn");
assertFalse(strategy.isInstantiationAuthorized(Page.class));
}
use of org.apache.wicket.authroles.authorization.strategies.role.IRoleCheckingStrategy in project wicket by apache.
the class ActionPermissionsTest method testRemove3.
/**
* Test consistency in behavior between authorizing a role for an action and then unauthorizing
* it with {@link #testRemove2()}.
*/
@Test
public void testRemove3() {
Label label = new Label("label", "text");
Action mambo = new Action("mambo");
MetaDataRoleAuthorizationStrategy strategy = new MetaDataRoleAuthorizationStrategy(new IRoleCheckingStrategy() {
@Override
public boolean hasAnyRole(Roles roles) {
return false;
}
});
label.setMetaData(MetaDataRoleAuthorizationStrategy.ACTION_PERMISSIONS, new ActionPermissions());
MetaDataRoleAuthorizationStrategy.authorize(label, mambo, "johan");
MetaDataRoleAuthorizationStrategy.unauthorize(label, mambo, "johan");
assertFalse(strategy.isActionAuthorized(label, mambo));
}
use of org.apache.wicket.authroles.authorization.strategies.role.IRoleCheckingStrategy in project wicket by apache.
the class ActionPermissionsTest method testRemove2.
/**
* Test for issue <a href="http://issues.apache.org/jira/browse/WICKET-1152">WICKET-1152</a>.
*/
@Test
public void testRemove2() {
Label label = new Label("label", "text");
Action mambo = new Action("mambo");
MetaDataRoleAuthorizationStrategy strategy = new MetaDataRoleAuthorizationStrategy(new IRoleCheckingStrategy() {
@Override
public boolean hasAnyRole(Roles roles) {
return false;
}
});
label.setMetaData(MetaDataRoleAuthorizationStrategy.ACTION_PERMISSIONS, new ActionPermissions());
MetaDataRoleAuthorizationStrategy.unauthorize(label, mambo, "johan");
assertFalse(strategy.isActionAuthorized(label, mambo));
}
use of org.apache.wicket.authroles.authorization.strategies.role.IRoleCheckingStrategy in project wicket by apache.
the class InstantiationPermissionsTest method testRemove2.
/**
* Test for issue <a href="http://issues.apache.org/jira/browse/WICKET-1152">WICKET-1152</a>.
*/
@Test
public void testRemove2() {
MetaDataRoleAuthorizationStrategy strategy = new MetaDataRoleAuthorizationStrategy(new IRoleCheckingStrategy() {
@Override
public boolean hasAnyRole(Roles roles) {
return false;
}
});
tester.getApplication().setMetaData(MetaDataRoleAuthorizationStrategy.INSTANTIATION_PERMISSIONS, new InstantiationPermissions());
MetaDataRoleAuthorizationStrategy.unauthorize(Page.class, "martijn");
assertFalse(strategy.isInstantiationAuthorized(Page.class));
}
Aggregations