Search in sources :

Example 26 with UserPrincipal

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

the class ConsumerCuratorPermissionsTest method setupEditMyConsumersViewAllPrincipal.

private User setupEditMyConsumersViewAllPrincipal() {
    Set<Permission> perms = new HashSet<>();
    User u = new User("fakeuser", "dontcare");
    perms.add(new UsernameConsumersPermission(u, owner));
    perms.add(new OwnerPermission(owner, Access.READ_ONLY));
    Principal p = new UserPrincipal(u.getUsername(), perms, false);
    setupPrincipal(p);
    return u;
}
Also used : User(org.candlepin.model.User) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) UserPrincipal(org.candlepin.auth.UserPrincipal) HashSet(java.util.HashSet)

Example 27 with UserPrincipal

use of org.candlepin.auth.UserPrincipal 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)

Example 28 with UserPrincipal

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

the class ConsumerResourceIntegrationTest method testCreateConsumerVsDefaultServiceLevelForOwner.

@Test
@SuppressWarnings("checkstyle:indentation")
public void testCreateConsumerVsDefaultServiceLevelForOwner() {
    ConsumerDTO toSubmit = createConsumerDTO(CONSUMER_NAME, USER_NAME, null, standardSystemTypeDTO);
    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);
    assertEquals(DEFAULT_SERVICE_LEVEL, submitted.getServiceLevel());
}
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)

Example 29 with UserPrincipal

use of org.candlepin.auth.UserPrincipal 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)

Example 30 with UserPrincipal

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

the class OwnerResourceUeberCertOperationsTest method setUp.

@Before
public void setUp() {
    owner = ownerCurator.create(new Owner(OWNER_NAME));
    Role ownerAdminRole = createAdminRole(owner);
    roleCurator.create(ownerAdminRole);
    User user = new User("testing user", "pass");
    principal = new UserPrincipal("testing user", new ArrayList<>(permFactory.createPermissions(user, ownerAdminRole.getPermissions())), false);
    setupPrincipal(principal);
    or = new OwnerResource(ownerCurator, productCurator, null, consumerCurator, i18n, null, null, null, null, null, poolManager, null, null, null, null, consumerTypeCurator, entCertCurator, entitlementCurator, ueberCertCurator, ueberCertGenerator, null, null, contentOverrideValidator, serviceLevelValidator, null, null, null, null, null, this.modelTranslator);
}
Also used : Role(org.candlepin.model.Role) Owner(org.candlepin.model.Owner) User(org.candlepin.model.User) ArrayList(java.util.ArrayList) UserPrincipal(org.candlepin.auth.UserPrincipal) Before(org.junit.Before)

Aggregations

UserPrincipal (org.candlepin.auth.UserPrincipal)30 Test (org.junit.Test)18 Owner (org.candlepin.model.Owner)16 Principal (org.candlepin.auth.Principal)14 OwnerPermission (org.candlepin.auth.permissions.OwnerPermission)10 User (org.candlepin.model.User)10 Permission (org.candlepin.auth.permissions.Permission)9 HashSet (java.util.HashSet)7 ConsumerDTO (org.candlepin.dto.api.v1.ConsumerDTO)7 ConsumerType (org.candlepin.model.ConsumerType)6 ConsumerTypeDTO (org.candlepin.dto.api.v1.ConsumerTypeDTO)5 OwnerDTO (org.candlepin.dto.api.v1.OwnerDTO)4 Consumer (org.candlepin.model.Consumer)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 NoAuthPrincipal (org.candlepin.auth.NoAuthPrincipal)3 UsernameConsumersPermission (org.candlepin.auth.permissions.UsernameConsumersPermission)3 Role (org.candlepin.model.Role)3 ManifestFile (org.candlepin.sync.file.ManifestFile)3 TestUtil.createConsumerDTO (org.candlepin.test.TestUtil.createConsumerDTO)3