@Test(expected = ForbiddenException.class)
public void noAccessToOtherConsumer() throws Exception {
Method method = FakeResource.class.getMethod(
"someConsumerOnlyMethod", String.class);
MockHttpRequest req = MockHttpRequest.create("GET",
"http://localhost/candlepin/status");
ResourceMethod rmethod = mock(ResourceMethod.class);
when(rmethod.getMethod()).thenReturn(method);
Class clazz = FakeResource.class;
when(rmethod.getResourceClass()).thenReturn(clazz);
Consumer c = createConsumer(createOwner());
Consumer c2 = createConsumer(createOwner());
methodInjector.setArguments(new Object[] {c2.getUuid()});
when(consumerCurator.getConsumer(eq(c.getUuid()))).thenReturn(c);
when(consumerCurator.findByUuid(eq(c2.getUuid()))).thenReturn(c2);
// create mock certs to trigger SSLAuth provider
X509Certificate[] certs = new X509Certificate[1];
X509Certificate cert = mock(X509Certificate.class);
certs[0] = cert;
req.setAttribute("javax.servlet.request.X509Certificate", certs);
java.security.Principal p = mock(java.security.Principal.class);
when(p.getName()).thenReturn("CN=" + c.getUuid() + ", C=US, L=Raleigh");
when(cert.getSubjectDN()).thenReturn(p);