use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class PoolResourceTest method testConsumerCannotListPoolsForAnotherOwnersConsumer.
@Test(expected = NotFoundException.class)
public void testConsumerCannotListPoolsForAnotherOwnersConsumer() {
Principal p = setupPrincipal(new ConsumerPrincipal(foreignConsumer, owner2));
securityInterceptor.enable();
poolResource.list(null, passConsumer.getUuid(), null, false, null, p, null);
}
use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class PoolResourceTest method testListForOrg.
@Test
public void testListForOrg() {
List<PoolDTO> pools = poolResource.list(owner1.getId(), null, null, false, null, adminPrincipal, null);
assertEquals(2, pools.size());
Principal p = setupPrincipal(owner2, Access.ALL);
pools = poolResource.list(owner2.getId(), null, null, false, null, p, null);
assertEquals(1, pools.size());
}
use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class PoolResourceTest method consumerCanListOwnersPools.
@Test
public void consumerCanListOwnersPools() {
Principal p = setupPrincipal(new ConsumerPrincipal(passConsumer, owner1));
securityInterceptor.enable();
poolResource.list(owner1.getId(), null, null, false, null, p, null);
}
use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class UserResourceTest method testListAllOwners.
@Test
public void testListAllOwners() {
User user = new User();
user.setUsername("dummyuser" + TestUtil.randomInt());
user.setPassword("password");
userResource.createUser(user);
Owner owner1 = createOwner();
Owner owner2 = createOwner();
Role owner1Role = new Role(owner1.getKey() + " role");
Role owner2Role = new Role(owner2.getKey() + " role");
owner1Role.addPermission(new PermissionBlueprint(PermissionType.OWNER, owner1, Access.ALL));
owner1Role.addPermission(new PermissionBlueprint(PermissionType.OWNER, owner2, Access.READ_ONLY));
owner1Role.addUser(user);
owner2Role.addUser(user);
roleCurator.create(owner1Role);
roleCurator.create(owner2Role);
Set<Permission> perms = new HashSet<>();
perms.add(new OwnerPermission(owner1, Access.ALL));
perms.add(new OwnerPermission(owner2, Access.READ_ONLY));
Principal userPrincipal = new UserPrincipal(user.getUsername(), perms, false);
// Requesting the list of owners for this user should assume ALL, and not
// return owner2:
Iterable<Owner> response = userResource.listUsersOwners(user.getUsername(), userPrincipal);
List<Owner> owners = new LinkedList<>();
for (Object entity : response) {
owners.add((Owner) entity);
}
assertEquals(1, owners.size());
assertEquals(owner1.getKey(), owners.get(0).getKey());
}
use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class PinsetterAsyncFilterTest method noJobMapPrincipal.
@Test
public void noJobMapPrincipal() {
List<Permission> permissions = Arrays.asList(new Permission[] { new OwnerPermission(new Owner("test_owner"), Access.ALL) });
Principal principal = new UserPrincipal("testing", permissions, false);
when(this.principalProvider.get()).thenReturn(principal);
JobDetail detail = newJob(RefreshPoolsJob.class).build();
when(response.getEntity()).thenReturn(detail);
this.interceptor.postProcess(response);
Assert.assertEquals(principal, detail.getJobDataMap().get(PinsetterJobListener.PRINCIPAL_KEY));
}
Aggregations