Search in sources :

Example 61 with Principal

use of org.candlepin.auth.Principal in project candlepin by candlepin.

the class ConsumerResourceCreationTest method registerWithNoReleaseVer.

@Test
public void registerWithNoReleaseVer() {
    Principal p = new TrustedUserPrincipal("anyuser");
    ConsumerDTO consumer = TestUtil.createConsumerDTO("consumername", null, null, systemDto);
    resource.create(consumer, p, USER, owner.getKey(), null, true);
}
Also used : TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) ConsumerDTO(org.candlepin.dto.api.v1.ConsumerDTO) TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) NoAuthPrincipal(org.candlepin.auth.NoAuthPrincipal) Test(org.junit.Test)

Example 62 with Principal

use of org.candlepin.auth.Principal in project candlepin by candlepin.

the class ConsumerResourceCreationTest method registerWithNoInstalledProducts.

@Test
public void registerWithNoInstalledProducts() {
    Principal p = new TrustedUserPrincipal("anyuser");
    ConsumerDTO consumer = TestUtil.createConsumerDTO("consumerName", null, null, systemDto);
    resource.create(consumer, p, USER, owner.getKey(), null, true);
}
Also used : TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) ConsumerDTO(org.candlepin.dto.api.v1.ConsumerDTO) TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) NoAuthPrincipal(org.candlepin.auth.NoAuthPrincipal) Test(org.junit.Test)

Example 63 with Principal

use of org.candlepin.auth.Principal in project candlepin by candlepin.

the class ConsumerResourceCreationTest method setStatusOnCreate.

@Test
public void setStatusOnCreate() {
    Principal p = new TrustedUserPrincipal("anyuser");
    ConsumerDTO consumer = TestUtil.createConsumerDTO("consumername", null, null, systemDto);
    resource.create(consumer, p, USER, owner.getKey(), null, true);
    // Should be called with the consumer, null date (now),
    // no compliantUntil, and not update the consumer record
    verify(complianceRules).getStatus(any(Consumer.class), eq((Date) null), eq(false), eq(false));
}
Also used : TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) Consumer(org.candlepin.model.Consumer) ConsumerDTO(org.candlepin.dto.api.v1.ConsumerDTO) TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) NoAuthPrincipal(org.candlepin.auth.NoAuthPrincipal) Date(java.util.Date) Test(org.junit.Test)

Example 64 with Principal

use of org.candlepin.auth.Principal in project candlepin by candlepin.

the class ConsumerResourceCreationTest method failIfOnlyActivationKeyDoesNotExistForOrg.

@Test(expected = BadRequestException.class)
public void failIfOnlyActivationKeyDoesNotExistForOrg() {
    Principal p = new NoAuthPrincipal();
    List<String> keys = new ArrayList<>();
    keys.add("NoSuchKey");
    ConsumerDTO consumer = TestUtil.createConsumerDTO("sys.example.com", null, null, systemDto);
    resource.create(consumer, p, null, owner.getKey(), createKeysString(keys), true);
}
Also used : NoAuthPrincipal(org.candlepin.auth.NoAuthPrincipal) ConsumerDTO(org.candlepin.dto.api.v1.ConsumerDTO) ArrayList(java.util.ArrayList) TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) NoAuthPrincipal(org.candlepin.auth.NoAuthPrincipal) Test(org.junit.Test)

Example 65 with Principal

use of org.candlepin.auth.Principal in project candlepin by candlepin.

the class ConsumerResourceCreationTest method createConsumer.

protected ConsumerDTO createConsumer(String consumerName) {
    Collection<Permission> perms = new HashSet<>();
    perms.add(new OwnerPermission(owner, Access.ALL));
    Principal principal = new UserPrincipal(USER, perms, false);
    List<String> empty = Collections.emptyList();
    return createConsumer(consumerName, principal, empty);
}
Also used : OwnerPermission(org.candlepin.auth.permissions.OwnerPermission) OwnerPermission(org.candlepin.auth.permissions.OwnerPermission) Permission(org.candlepin.auth.permissions.Permission) TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) NoAuthPrincipal(org.candlepin.auth.NoAuthPrincipal) TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) HashSet(java.util.HashSet)

Aggregations

Principal (org.candlepin.auth.Principal)74 Test (org.junit.Test)54 UserPrincipal (org.candlepin.auth.UserPrincipal)40 NoAuthPrincipal (org.candlepin.auth.NoAuthPrincipal)20 ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)17 ConsumerDTO (org.candlepin.dto.api.v1.ConsumerDTO)15 Consumer (org.candlepin.model.Consumer)15 Owner (org.candlepin.model.Owner)15 TrustedUserPrincipal (org.candlepin.auth.TrustedUserPrincipal)14 Date (java.util.Date)12 ConsumerType (org.candlepin.model.ConsumerType)11 HashSet (java.util.HashSet)10 Pool (org.candlepin.model.Pool)10 JobDetail (org.quartz.JobDetail)10 Method (java.lang.reflect.Method)9 Permission (org.candlepin.auth.permissions.Permission)9 JobDataMap (org.quartz.JobDataMap)9 CandlepinQuery (org.candlepin.model.CandlepinQuery)8 File (java.io.File)7 FileInputStream (java.io.FileInputStream)7