use of org.apache.wicket.authorization.IUnauthorizedResourceRequestListener in project wicket by apache.
the class ResourceAuthorizationTest method rejectWithException.
/**
* https://issues.apache.org/jira/browse/WICKET-5012
*/
@Test
public void rejectWithException() {
tester.getApplication().getSecuritySettings().setAuthorizationStrategy(new RejectingAuthorizationStrategy());
tester.getApplication().getSecuritySettings().setUnauthorizedResourceRequestListener(new IUnauthorizedResourceRequestListener() {
@Override
public void onUnauthorizedRequest(IResource resource, PageParameters parameters) {
throw new RuntimeException("Not authorized to request: " + resource);
}
});
TestResource resource = new TestResource();
expectedException.expect(RuntimeException.class);
expectedException.expectMessage("Not authorized to request: " + resource);
tester.startResource(resource);
}
Aggregations