ShiroAuthorizingParamInterceptor implements MethodInterceptor { @VisibleForTesting Permission makeTargetPermission(String methodName, IJobKey jobKey) { return Permissions.createJobScopedPermission(methodName, jobKey); }  @Override Object invoke(MethodInvocation invocation);  }
@Test public void testCreateJobWithScopedPermission() throws TException { JobConfiguration jobConfiguration = new JobConfiguration().setKey(JOB_KEY.newBuilder()); Response response = Responses.ok(); expect(subject .isPermitted(interceptor.makeTargetPermission("createJob", JOB_KEY))) .andReturn(true); expect(thrift.createJob(jobConfiguration)).andReturn(response); replayAndInitialize(); assertSame(response, decoratedThrift.createJob(jobConfiguration)); }
@Test public void testKillTasksWithTargetedPermission() throws TException { expect(subject.isPermitted(interceptor.makeTargetPermission("killTasks", JOB_KEY))) .andReturn(false); expect(subject.getPrincipal()).andReturn("zmanji"); replayAndInitialize(); assertEquals( ResponseCode.AUTH_FAILED, decoratedThrift.killTasks(JOB_KEY.newBuilder(), null).getResponseCode()); }