use of org.candlepin.model.Pool in project candlepin by candlepin.
the class PoolManagerFunctionalTest method testDevPoolRemovalAtUnbind.
@Test
public void testDevPoolRemovalAtUnbind() throws EntitlementRefusedException {
Owner owner = createOwner();
Product p = TestUtil.createProduct("test-product", "Test Product");
productCurator.create(p);
Consumer devSystem = new Consumer("dev", "user", owner, systemType);
devSystem.setFact("dev_sku", p.getId());
devSystem.addInstalledProduct(new ConsumerInstalledProduct(p));
consumerCurator.create(devSystem);
Pool pool1 = createPool(owner, p, 10L, TestUtil.createDate(2000, 3, 2), TestUtil.createDate(2050, 3, 2));
pool1.setAttribute(Pool.Attributes.DEVELOPMENT_POOL, "true");
pool1.setAttribute(Pool.Attributes.REQUIRES_CONSUMER, devSystem.getUuid());
poolCurator.create(pool1);
Pool pool2 = createPool(owner, p, 10L, TestUtil.createDate(2000, 3, 2), TestUtil.createDate(2050, 3, 2));
poolCurator.create(pool2);
List<String> possPools = new ArrayList<>();
possPools.add(pool1.getId());
AutobindData ad = new AutobindData(devSystem, owner);
ad.setPossiblePools(possPools);
List<Entitlement> results = poolManager.entitleByProducts(ad);
assertEquals(1, results.size());
assertEquals(results.get(0).getPool(), pool1);
Entitlement e = entitlementCurator.find(results.get(0).getId());
poolManager.revokeEntitlement(e);
assertNull(poolCurator.find(pool1.getId()));
assertNotNull(poolCurator.find(pool2.getId()));
}
use of org.candlepin.model.Pool in project candlepin by candlepin.
the class PoolManagerFunctionalTest method testDeletePool.
@Test
public void testDeletePool() throws Exception {
Pool pool = createPool(o, socketLimitedProduct, 100L, TestUtil.createDate(2000, 3, 2), TestUtil.createDate(2050, 3, 2));
poolCurator.create(pool);
List<Pool> pools = poolCurator.listByOwner(o).list();
assertEquals(5, poolCurator.listByOwner(o).list().size());
poolManager.deletePools(Arrays.asList(pool, pools.get(0)));
pools = poolCurator.listByOwner(o).list();
assertEquals(3, pools.size());
poolManager.deletePools(pools);
pools = poolCurator.listByOwner(o).list();
assertTrue(pools.isEmpty());
}
use of org.candlepin.model.Pool in project candlepin by candlepin.
the class PoolManagerFunctionalTest method testCleanupExpiredPools.
@Test
public void testCleanupExpiredPools() {
long ct = System.currentTimeMillis();
Date activeStart = new Date(ct + 3600000);
Date activeEnd = new Date(ct + 7200000);
Date expiredStart = new Date(ct - 7200000);
Date expiredEnd = new Date(ct - 3600000);
Owner owner = this.createOwner();
Product product1 = this.createProduct("test-product-1", "Test Product 1", owner);
Product product2 = this.createProduct("test-product-2", "Test Product 2", owner);
Pool activePool = this.createPool(owner, product1, 1L, activeStart, activeEnd);
Pool expiredPool = this.createPool(owner, product2, 1L, expiredStart, expiredEnd);
this.poolManager.cleanupExpiredPools();
assertNotNull(this.poolCurator.find(activePool.getId()));
assertNull(this.poolCurator.find(expiredPool.getId()));
}
use of org.candlepin.model.Pool in project candlepin by candlepin.
the class PoolManagerFunctionalTest method testListForConsumerExcludesWarnings.
@Test
public void testListForConsumerExcludesWarnings() {
Page<List<Pool>> results = poolManager.listAvailableEntitlementPools(parentSystem, null, parentSystem.getOwnerId(), (String) null, null, null, true, new PoolFilterBuilder(), new PageRequest(), false, false, null);
assertEquals(4, results.getPageData().size());
Pool pool = createPool(o, socketLimitedProduct, 100L, TestUtil.createDate(2000, 3, 2), TestUtil.createDate(2050, 3, 2));
poolCurator.create(pool);
parentSystem.setFact("cpu.cpu_socket(s)", "4");
results = poolManager.listAvailableEntitlementPools(parentSystem, null, parentSystem.getOwnerId(), (String) null, null, null, false, new PoolFilterBuilder(), new PageRequest(), false, false, null);
// Pool in error should not be included. Should have the same number of
// initial pools.
assertEquals(4, results.getPageData().size());
}
use of org.candlepin.model.Pool in project candlepin by candlepin.
the class TrustedUserPrincipalTest method access.
@Test
public void access() {
Consumer c = mock(Consumer.class);
Pool p = mock(Pool.class);
assertTrue(principal.canAccess(c, SubResource.NONE, Access.ALL));
assertTrue(principal.canAccess(null, SubResource.NONE, Access.NONE));
assertTrue(principal.canAccessAll(null, SubResource.NONE, Access.NONE));
assertTrue(principal.canAccess(p, SubResource.NONE, Access.ALL));
assertTrue(principal.canAccess("always true", SubResource.NONE, Access.READ_ONLY));
}
Aggregations