Search in sources :

Example 11 with OwnerPermission

use of org.candlepin.auth.permissions.OwnerPermission in project candlepin by candlepin.

the class ConsumerResourceIntegrationTest method testCreateConsumer.

@Test
@SuppressWarnings("checkstyle:indentation")
public void testCreateConsumer() {
    ConsumerDTO toSubmit = createConsumerDTO(CONSUMER_NAME, USER_NAME, null, standardSystemTypeDTO);
    toSubmit.setFact(METADATA_NAME, METADATA_VALUE);
    ConsumerDTO submitted = consumerResource.create(toSubmit, new UserPrincipal(someuser.getUsername(), Arrays.asList(new Permission[] { new OwnerPermission(owner, Access.ALL) }), false), someuser.getUsername(), owner.getKey(), null, true);
    assertNotNull(submitted);
    assertNotNull(consumerCurator.find(submitted.getId()));
    assertEquals(standardSystemType.getLabel(), submitted.getType().getLabel());
    assertEquals(METADATA_VALUE, submitted.getFact(METADATA_NAME));
}
Also used : OwnerPermission(org.candlepin.auth.permissions.OwnerPermission) ConsumerDTO(org.candlepin.dto.api.v1.ConsumerDTO) TestUtil.createConsumerDTO(org.candlepin.test.TestUtil.createConsumerDTO) UserPrincipal(org.candlepin.auth.UserPrincipal) Test(org.junit.Test)

Aggregations

OwnerPermission (org.candlepin.auth.permissions.OwnerPermission)11 UserPrincipal (org.candlepin.auth.UserPrincipal)8 Test (org.junit.Test)8 Owner (org.candlepin.model.Owner)7 Principal (org.candlepin.auth.Principal)6 Permission (org.candlepin.auth.permissions.Permission)6 HashSet (java.util.HashSet)5 User (org.candlepin.model.User)4 ConsumerDTO (org.candlepin.dto.api.v1.ConsumerDTO)2 TestUtil.createConsumerDTO (org.candlepin.test.TestUtil.createConsumerDTO)2 JobDetail (org.quartz.JobDetail)2 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 NoAuthPrincipal (org.candlepin.auth.NoAuthPrincipal)1 TrustedUserPrincipal (org.candlepin.auth.TrustedUserPrincipal)1 UsernameConsumersPermission (org.candlepin.auth.permissions.UsernameConsumersPermission)1 PermissionBlueprint (org.candlepin.model.PermissionBlueprint)1 Role (org.candlepin.model.Role)1 RefreshPoolsJob (org.candlepin.pinsetter.tasks.RefreshPoolsJob)1 JobDataMap (org.quartz.JobDataMap)1