Search in sources :

Example 66 with Principal

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

the class ConsumerResourceCreationTest method registerWithEmptyReleaseVer.

@Test
public void registerWithEmptyReleaseVer() {
    Principal p = new TrustedUserPrincipal("anyuser");
    ConsumerDTO consumer = TestUtil.createConsumerDTO("consumername", null, null, systemDto);
    consumer.setReleaseVersion("");
    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 67 with Principal

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

the class ConsumerResourceCreationTest method registerWithNullReleaseVer.

@Test
public void registerWithNullReleaseVer() {
    Principal p = new TrustedUserPrincipal("anyuser");
    ConsumerDTO consumer = TestUtil.createConsumerDTO("consumername", null, null, systemDto);
    consumer.setReleaseVersion(null);
    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 68 with Principal

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

the class ConsumerResourceCreationTest method cannotMixUsernameWithActivationKeys.

@Test(expected = BadRequestException.class)
public void cannotMixUsernameWithActivationKeys() {
    Principal p = new NoAuthPrincipal();
    List<String> keys = mockActivationKeys();
    ConsumerDTO consumer = TestUtil.createConsumerDTO("sys.example.com", null, null, systemDto);
    resource.create(consumer, p, USER, owner.getKey(), createKeysString(keys), true);
}
Also used : NoAuthPrincipal(org.candlepin.auth.NoAuthPrincipal) 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 69 with Principal

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

the class ConsumerResourceCreationTest method authRequired.

@Test(expected = ForbiddenException.class)
public void authRequired() {
    Principal p = new NoAuthPrincipal();
    List<String> empty = Collections.emptyList();
    createConsumer("sys.example.com", p, empty);
}
Also used : NoAuthPrincipal(org.candlepin.auth.NoAuthPrincipal) 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 70 with Principal

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

the class ConsumerResourceCreationTest method passIfOnlyOneActivationKeyDoesNotExistForOrg.

@Test
public void passIfOnlyOneActivationKeyDoesNotExistForOrg() {
    Principal p = new NoAuthPrincipal();
    List<String> keys = mockActivationKeys();
    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) TrustedUserPrincipal(org.candlepin.auth.TrustedUserPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) NoAuthPrincipal(org.candlepin.auth.NoAuthPrincipal) Test(org.junit.Test)

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