use of org.candlepin.model.Consumer in project candlepin by candlepin.
the class ConsumerCuratorPermissionsTest method testListForOwnerPermissionFiltering.
@Test
public void testListForOwnerPermissionFiltering() {
User u = setupOnlyMyConsumersPrincipal();
Consumer c1 = new Consumer("c1", u.getUsername(), owner, consumerType);
consumerCurator.create(c1);
Consumer c2 = new Consumer("c2", "anotheruser", owner, consumerType);
consumerCurator.create(c2);
List<Consumer> results = consumerCurator.listByOwner(owner).list();
assertEquals(1, results.size());
assertEquals(c1.getName(), results.get(0).getName());
}
use of org.candlepin.model.Consumer in project candlepin by candlepin.
the class UsernameConsumersPermissionTest method allowsListOrgConsumers.
@Test
public void allowsListOrgConsumers() {
Consumer c = new Consumer("consumer", username, owner, null);
assertTrue(perm.canAccess(owner, SubResource.CONSUMERS, Access.READ_ONLY));
}
use of org.candlepin.model.Consumer in project candlepin by candlepin.
the class UsernameConsumersPermissionTest method blocksConsumersInOtherOrgDespiteSameUsername.
@Test
public void blocksConsumersInOtherOrgDespiteSameUsername() {
Owner other = new Owner("ownerkey2", "My Org 2");
other.setId(TestUtil.randomString());
Consumer c = new Consumer("consumer", username, other, null);
assertFalse(perm.canAccess(c, SubResource.NONE, Access.READ_ONLY));
assertFalse(perm.canAccess(c, SubResource.NONE, Access.ALL));
}
use of org.candlepin.model.Consumer in project candlepin by candlepin.
the class UsernameConsumersPermissionTest method allowsUsernameConsumersModification.
@Test
public void allowsUsernameConsumersModification() {
Consumer c = new Consumer("consumer", username, owner, null);
assertTrue(perm.canAccess(c, SubResource.NONE, Access.ALL));
assertTrue(perm.canAccess(c, SubResource.NONE, Access.CREATE));
assertTrue(perm.canAccess(c, SubResource.NONE, Access.READ_ONLY));
}
use of org.candlepin.model.Consumer in project candlepin by candlepin.
the class EntitlerTest method testCreatedDevSkuWithNoSla.
@Test
public void testCreatedDevSkuWithNoSla() {
Owner owner = TestUtil.createOwner("o");
List<ProductData> devProdDTOs = new ArrayList<>();
final Product p1 = TestUtil.createProduct("dev-product", "Dev Product");
devProdDTOs.add(p1.toDTO());
Consumer devSystem = TestUtil.createConsumer(owner);
devSystem.setFact("dev_sku", p1.getId());
when(productAdapter.getProductsByIds(eq(owner), any(List.class))).thenReturn(devProdDTOs);
mockUpdateProduct(p1, owner);
this.mockContentImport(owner, Collections.<String, Content>emptyMap());
when(productManager.importProducts(eq(owner), any(Map.class), any(Map.class))).thenAnswer(new Answer<ImportResult<Product>>() {
@Override
public ImportResult<Product> answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
Map<String, ProductData> productData = (Map<String, ProductData>) args[1];
ImportResult<Product> importResult = new ImportResult<>();
Map<String, Product> output = importResult.getCreatedEntities();
// simulate a proper update.
for (ProductData pdata : productData.values()) {
if (pdata != null) {
if (p1.getId().equals(pdata.getId())) {
p1.clearAttributes();
if (pdata.getAttributes() != null) {
p1.setAttributes(pdata.getAttributes());
}
output.put(p1.getId(), p1);
} else {
Product product = new Product(pdata.getId(), pdata.getName());
// Do we care about this product? Probably not.
output.put(product.getId(), product);
}
}
}
return importResult;
}
});
Pool created = entitler.assembleDevPool(devSystem, owner, devSystem.getFact("dev_sku"));
assertEquals(entitler.DEFAULT_DEV_SLA, created.getProduct().getAttributeValue(Product.Attributes.SUPPORT_LEVEL));
}
Aggregations