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;
}
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);
}
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());
}
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));
}
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);
}
Aggregations