use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class PoolResourceTest method consumerCannotListPoolsForAnotherOwner.
@Test(expected = NotFoundException.class)
public void consumerCannotListPoolsForAnotherOwner() {
Principal p = setupPrincipal(new ConsumerPrincipal(foreignConsumer, owner2));
securityInterceptor.enable();
poolResource.list(owner1.getId(), null, null, false, null, p, null);
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class JobCuratorTest method findByUserFiltersByOwnerAccessAndUUIDWhenRequestedByConsumer.
@Test
public void findByUserFiltersByOwnerAccessAndUUIDWhenRequestedByConsumer() {
Owner owner = new Owner("testowner");
owner.setId(TestUtil.randomString());
Consumer consumer = TestUtil.createConsumer(owner);
JobStatus job = newJobStatus().principalName(consumer.getUuid()).owner(owner.getKey()).create();
newJobStatus().principalName("p1").owner("owner1").create();
newJobStatus().principalName("p2").owner("owner1").create();
newJobStatus().principalName("p3").owner("owner2").create();
setupPrincipal(new ConsumerPrincipal(consumer, owner));
assertTrue(this.curator.findByOwnerKey("owner1").list().isEmpty());
assertTrue(this.curator.findByOwnerKey("owner2").list().isEmpty());
List<JobStatus> found = this.curator.findByOwnerKey("testowner").list();
assertEquals(1, found.size());
assertEquals(job, found.get(0));
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class ConsumerResourceIntegrationTest method consumerShouldNotSeeAnotherConsumersEntitlements.
@Test(expected = NotFoundException.class)
public void consumerShouldNotSeeAnotherConsumersEntitlements() {
Consumer evilConsumer = TestUtil.createConsumer(standardSystemType, owner);
consumerCurator.create(evilConsumer);
consumerResource.bind(consumer.getUuid(), pool.getId().toString(), null, 1, null, null, false, null, null);
consumerResource.bind(consumer.getUuid(), pool.getId().toString(), null, 1, null, null, false, null, null);
consumerResource.bind(evilConsumer.getUuid(), pool.getId().toString(), null, 1, null, null, false, null, null);
setupPrincipal(new ConsumerPrincipal(evilConsumer, owner));
securityInterceptor.enable();
consumerResource.listEntitlements(consumer.getUuid(), null, true, "", new ArrayList<>(), null);
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class ConsumerResourceIntegrationTest method testCanGetOwnedConsumersCerts.
@Test
public void testCanGetOwnedConsumersCerts() {
consumerResource.bind(consumer.getUuid(), pool.getId().toString(), null, 1, null, null, false, null, null);
consumerResource.bind(consumer.getUuid(), pool.getId().toString(), null, 1, null, null, false, null, null);
consumerResource.bind(consumer.getUuid(), pool.getId().toString(), null, 1, null, null, false, null, null);
setupPrincipal(new ConsumerPrincipal(consumer, owner));
assertEquals(3, consumerResource.getEntitlementCertificates(consumer.getUuid(), null).size());
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class ConsumerResourceIntegrationTest method testConsumerCannotListAllConsumers.
@Test(expected = ForbiddenException.class)
public void testConsumerCannotListAllConsumers() {
setupPrincipal(new ConsumerPrincipal(consumer, owner));
securityInterceptor.enable();
consumerResource.list(null, null, null, new ArrayList<>(), null, null, null);
}
Aggregations