use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class OwnerResourceTest method consumerListPoolsGetCalculatedAttributes.
@Test
public void consumerListPoolsGetCalculatedAttributes() {
Product p = this.createProduct(owner);
Pool pool1 = TestUtil.createPool(owner, p);
poolCurator.create(pool1);
Consumer c = this.createConsumer(owner);
Principal principal = setupPrincipal(new ConsumerPrincipal(c, owner));
securityInterceptor.enable();
List<PoolDTO> pools = ownerResource.listPools(owner.getKey(), c.getUuid(), null, p.getId(), null, true, null, null, new ArrayList<>(), false, false, null, null, principal, null);
assertEquals(1, pools.size());
PoolDTO returnedPool = pools.get(0);
assertNotNull(returnedPool.getCalculatedAttributes());
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class OwnerResourceTest method testUnmappedGuestConsumerCanListPoolsForFuture.
@Test
public void testUnmappedGuestConsumerCanListPoolsForFuture() {
Consumer c = this.createConsumer(owner);
c.setFact("virt.is_guest", "true");
c.setFact("virt.uuid", "system_uuid");
consumerCurator.merge(c);
Principal principal = setupPrincipal(new ConsumerPrincipal(c, owner));
securityInterceptor.enable();
Date now = new Date();
Product p = this.createProduct(owner);
Pool pool1 = TestUtil.createPool(owner, p);
pool1.setAttribute(Pool.Attributes.VIRT_ONLY, "true");
pool1.setAttribute(Pool.Attributes.DERIVED_POOL, "true");
pool1.setAttribute(Pool.Attributes.PHYSICAL_ONLY, "false");
pool1.setAttribute(Pool.Attributes.UNMAPPED_GUESTS_ONLY, "true");
pool1.setStartDate(now);
pool1.setEndDate(new Date(now.getTime() + 1000L * 60 * 60 * 24 * 365));
Pool pool2 = TestUtil.createPool(owner, p);
pool2.setAttribute(Pool.Attributes.VIRT_ONLY, "true");
pool2.setAttribute(Pool.Attributes.DERIVED_POOL, "true");
pool2.setAttribute(Pool.Attributes.PHYSICAL_ONLY, "false");
pool2.setAttribute(Pool.Attributes.UNMAPPED_GUESTS_ONLY, "true");
pool2.setStartDate(new Date(now.getTime() + 2 * 1000L * 60 * 60 * 24 * 365));
pool2.setEndDate(new Date(now.getTime() + 3 * 1000L * 60 * 60 * 24 * 365));
poolCurator.create(pool1);
poolCurator.create(pool2);
List<PoolDTO> nowList = ownerResource.listPools(owner.getKey(), c.getUuid(), null, null, null, false, new Date(), null, new ArrayList<>(), false, false, null, null, principal, null);
assertEquals(1, nowList.size());
assert (nowList.get(0).getId().equals(pool1.getId()));
Date activeOn = new Date(pool2.getStartDate().getTime() + 1000L * 60 * 60 * 24);
List<PoolDTO> futureList = ownerResource.listPools(owner.getKey(), c.getUuid(), null, null, null, false, activeOn, null, new ArrayList<>(), false, false, null, null, principal, null);
assertEquals(1, futureList.size());
assert (futureList.get(0).getId().equals(pool2.getId()));
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class OwnerResourceTest method testConsumerRoleCannotAccessOwnerAtomFeed.
@Test(expected = ForbiddenException.class)
public void testConsumerRoleCannotAccessOwnerAtomFeed() {
Consumer c = createConsumer(owner);
setupPrincipal(new ConsumerPrincipal(c, owner));
securityInterceptor.enable();
ownerResource.getOwnerAtomFeed(owner.getKey());
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class OwnerResourceTest method consumerCannotListAllConsumersInOwner.
@Test(expected = ForbiddenException.class)
public void consumerCannotListAllConsumersInOwner() {
Consumer c = createConsumer(owner);
setupPrincipal(new ConsumerPrincipal(c, owner));
securityInterceptor.enable();
ownerResource.listConsumers(owner.getKey(), null, null, new ArrayList<>(), null, null, null, null, null, null);
}
use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.
the class OwnerResourceTest method testConsumerCanListPools.
@Test
public void testConsumerCanListPools() {
Consumer c = createConsumer(owner);
Principal principal = setupPrincipal(new ConsumerPrincipal(c, owner));
securityInterceptor.enable();
ownerResource.listPools(owner.getKey(), null, null, null, null, false, null, null, new ArrayList<>(), false, false, null, null, principal, null);
}
Aggregations