Search in sources :

Example 31 with Owner

use of org.candlepin.model.Owner in project candlepin by candlepin.

the class OwnerResourceTest method testSetBadLogLevel.

@Test(expected = BadRequestException.class)
public void testSetBadLogLevel() {
    Owner owner = new Owner("Test Owner", "test");
    ownerCurator.create(owner);
    ownerResource.setLogLevel(owner.getKey(), "THISLEVELISBAD");
}
Also used : Owner(org.candlepin.model.Owner) Test(org.junit.Test)

Example 32 with Owner

use of org.candlepin.model.Owner in project candlepin by candlepin.

the class OwnerResourceTest method ownersAtomFeed.

@Test
public void ownersAtomFeed() {
    Owner owner2 = new Owner("anotherOwner");
    ownerCurator.create(owner2);
    Event e1 = createConsumerCreatedEvent(owner);
    // Make an event from another owner:
    createConsumerCreatedEvent(owner2);
    // Make sure we're acting as the correct owner admin:
    setupPrincipal(owner, Access.ALL);
    securityInterceptor.enable();
    Feed feed = ownerResource.getOwnerAtomFeed(owner.getKey());
    assertEquals(1, feed.getEntries().size());
    Entry entry = feed.getEntries().get(0);
    assertEquals(e1.getTimestamp(), entry.getPublished());
}
Also used : Owner(org.candlepin.model.Owner) Entry(org.jboss.resteasy.plugins.providers.atom.Entry) Event(org.candlepin.audit.Event) Feed(org.jboss.resteasy.plugins.providers.atom.Feed) Test(org.junit.Test)

Example 33 with Owner

use of org.candlepin.model.Owner in project candlepin by candlepin.

the class OwnerResourceTest method testActivationKeyRequiresName.

@Test(expected = BadRequestException.class)
public void testActivationKeyRequiresName() {
    OwnerCurator oc = mock(OwnerCurator.class);
    ProductCurator pc = mock(ProductCurator.class);
    Owner o = new Owner();
    o.setKey("owner-key");
    OwnerResource ownerres = new OwnerResource(oc, pc, null, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, this.modelTranslator);
    when(oc.lookupByKey(anyString())).thenReturn(o);
    ActivationKeyDTO key = new ActivationKeyDTO();
    key = ownerres.createActivationKey(owner.getKey(), key);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ActivationKeyDTO(org.candlepin.dto.api.v1.ActivationKeyDTO) ProductCurator(org.candlepin.model.ProductCurator) Test(org.junit.Test)

Example 34 with Owner

use of org.candlepin.model.Owner in project candlepin by candlepin.

the class OwnerResourceTest method ownerAdminCannotAccessAnotherOwnersPools.

@Test(expected = NotFoundException.class)
public void ownerAdminCannotAccessAnotherOwnersPools() {
    Owner evilOwner = new Owner("evilowner");
    ownerCurator.create(evilOwner);
    Principal principal = setupPrincipal(evilOwner, Access.ALL);
    Product p = this.createProduct(owner);
    Pool pool1 = TestUtil.createPool(owner, p);
    Pool pool2 = TestUtil.createPool(owner, p);
    poolCurator.create(pool1);
    poolCurator.create(pool2);
    securityInterceptor.enable();
    // Filtering should just cause this to return no results:
    ownerResource.listPools(owner.getKey(), null, null, null, null, true, null, null, new ArrayList<>(), false, false, null, null, principal, null);
}
Also used : Owner(org.candlepin.model.Owner) Product(org.candlepin.model.Product) Pool(org.candlepin.model.Pool) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) Test(org.junit.Test)

Example 35 with Owner

use of org.candlepin.model.Owner in project candlepin by candlepin.

the class PersonConsumerResourceCreationLiberalNameRules method initConsumerType.

@Override
public ConsumerType initConsumerType() {
    ConsumerType systemtype = new ConsumerType(ConsumerType.ConsumerTypeEnum.PERSON);
    // create an owner, an ownerperm, and roles for the user we provide
    // as coming from userService
    owner = new Owner("test_owner");
    PermissionBlueprint p = new PermissionBlueprint(PermissionType.OWNER, owner, Access.ALL);
    User user = new User("anyuser", "");
    role = new Role();
    role.addPermission(p);
    role.addUser(user);
    when(userService.findByLogin("anyuser")).thenReturn(user);
    return systemtype;
}
Also used : Role(org.candlepin.model.Role) Owner(org.candlepin.model.Owner) User(org.candlepin.model.User) PermissionBlueprint(org.candlepin.model.PermissionBlueprint) ConsumerType(org.candlepin.model.ConsumerType)

Aggregations

Owner (org.candlepin.model.Owner)405 Test (org.junit.Test)254 Product (org.candlepin.model.Product)153 Consumer (org.candlepin.model.Consumer)127 Pool (org.candlepin.model.Pool)79 Date (java.util.Date)72 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)71 ArrayList (java.util.ArrayList)58 Produces (javax.ws.rs.Produces)52 ConsumerType (org.candlepin.model.ConsumerType)52 ApiOperation (io.swagger.annotations.ApiOperation)50 HashSet (java.util.HashSet)44 Entitlement (org.candlepin.model.Entitlement)44 Path (javax.ws.rs.Path)42 HashMap (java.util.HashMap)41 ApiResponses (io.swagger.annotations.ApiResponses)40 Content (org.candlepin.model.Content)39 BadRequestException (org.candlepin.common.exceptions.BadRequestException)37 Subscription (org.candlepin.model.dto.Subscription)32 List (java.util.List)29