use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class OwnerResourceTest method consumerCannotCountAllConsumersInOwner.
// copied from consumerCannotListAllConsumersInOwner
@Test(expected = ForbiddenException.class)
public void consumerCannotCountAllConsumersInOwner() {
Consumer c = createConsumer(owner);
setupPrincipal(new ConsumerPrincipal(c, owner));
securityInterceptor.enable();
ownerResource.countConsumers(owner.getKey(), typeLabels, skus, subscriptionIds, contracts);
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class JobCuratorTest method findByConsumerUuidRestrictsByConsumerUuidEnforcesOwnerMatchWhenRequestedByConsumer.
@Test
public void findByConsumerUuidRestrictsByConsumerUuidEnforcesOwnerMatchWhenRequestedByConsumer() {
Owner owner = new Owner("testowner");
owner.setId(TestUtil.randomString());
Consumer consumer = TestUtil.createConsumer(owner);
JobStatus job = newJobStatus().principalName(consumer.getUuid()).consumer(consumer.getUuid(), "testowner").create();
// Technically this case shoरावणuld not happen since a consumer
// can belong to one org, but adding just to make sure that
// it gets filtered.
newJobStatus().principalName(consumer.getUuid()).consumer(consumer.getUuid(), "owner1").create();
newJobStatus().principalName("p2").consumer("c2", "owner1").create();
newJobStatus().principalName("p3").owner("owner2").create();
setupPrincipal(new ConsumerPrincipal(consumer, owner));
List<JobStatus> jobs = curator.findByConsumerUuid(consumer.getUuid()).list();
assertEquals(1, jobs.size());
assertEquals(job, jobs.get(0));
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class ConsumerTest method canDeleteSelf.
@Test
public void canDeleteSelf() {
setupPrincipal(new ConsumerPrincipal(consumer, owner));
consumerCurator.delete(consumer);
assertNull(consumerCurator.find(consumer.getId()));
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class OwnerAccessControlTest method consumerCannotCreateAnOwner.
@Test(expected = ForbiddenException.class)
public void consumerCannotCreateAnOwner() {
Consumer consumer = createConsumer(owner);
setupPrincipal(new ConsumerPrincipal(consumer, owner));
securityInterceptor.enable();
OwnerDTO dto = new OwnerDTO();
dto.setKey("Test Owner");
dto.setDisplayName("Test Owner");
resource.createOwner(dto);
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class JobCuratorTest method findByPrincipalNameRestrictsConsumerToOwnJobs.
@Test
public void findByPrincipalNameRestrictsConsumerToOwnJobs() {
Owner owner = new Owner("ducks");
Consumer consumer = TestUtil.createConsumer(owner);
JobStatus job = newJobStatus().principalName(consumer.getUuid()).owner(owner.getKey()).create();
newJobStatus().principalName("donald").owner(owner.getKey()).create();
setupPrincipal(new ConsumerPrincipal(consumer, owner));
assertTrue(this.curator.findByPrincipalName("donald").list().isEmpty());
List<JobStatus> jobs = this.curator.findByPrincipalName(consumer.getUuid()).list();
assertNotNull(jobs);
assertEquals(1, jobs.size());
assertEquals(consumer.getUuid(), job.getPrincipalName());
assertEquals(job, jobs.get(0));
}
Aggregations