use of org.candlepin.auth.UserPrincipal in project candlepin by candlepin.
the class DatabaseTestFixture method setupPrincipal.
protected Principal setupPrincipal(String username, Owner owner, Access verb) {
OwnerPermission p = new OwnerPermission(owner, verb);
// Only need a detached owner permission here:
Principal ownerAdmin = new UserPrincipal(username, Arrays.asList(new Permission[] { p }), false);
setupPrincipal(ownerAdmin);
return ownerAdmin;
}
use of org.candlepin.auth.UserPrincipal in project candlepin by candlepin.
the class DatabaseTestFixture method setupAdminPrincipal.
protected Principal setupAdminPrincipal(String username) {
UserPrincipal principal = new UserPrincipal(username, null, true);
setupPrincipal(principal);
return principal;
}
use of org.candlepin.auth.UserPrincipal in project candlepin by candlepin.
the class ManifestManagerTest method ensureEventSentWhenManifestGeneratedAndStored.
@Test
public void ensureEventSentWhenManifestGeneratedAndStored() throws Exception {
Consumer consumer = this.createMockConsumer(true);
Cdn cdn = new Cdn("test-cdn", "Test CDN", "");
String webAppPrefix = "webapp-prefix";
String apiUrl = "api-url";
Event event = mock(Event.class);
when(eventFactory.exportCreated(eq(consumer))).thenReturn(event);
UserPrincipal principal = TestUtil.createOwnerPrincipal();
when(principalProvider.get()).thenReturn(principal);
ManifestFile manifest = mock(ManifestFile.class);
when(fileService.store(eq(ManifestFileType.EXPORT), any(File.class), eq(principal.getName()), any(String.class))).thenReturn(manifest);
when(consumerCurator.verifyAndLookupConsumer(eq(consumer.getUuid()))).thenReturn(consumer);
when(cdnCurator.lookupByLabel(eq(cdn.getLabel()))).thenReturn(cdn);
manager.generateAndStoreManifest(consumer.getUuid(), cdn.getLabel(), webAppPrefix, apiUrl, new HashMap<>());
verify(eventFactory).exportCreated(eq(consumer));
verify(eventSink).queueEvent(eq(event));
}
use of org.candlepin.auth.UserPrincipal in project candlepin by candlepin.
the class ConsumerCuratorPermissionsTest method setupOnlyMyConsumersPrincipal.
private User setupOnlyMyConsumersPrincipal() {
Set<Permission> perms = new HashSet<>();
User u = new User("fakeuser", "dontcare");
perms.add(new UsernameConsumersPermission(u, owner));
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 OwnerCuratorPermissionsTest method setUpTestObjects.
@Before
public void setUpTestObjects() {
owner1 = new Owner("Example Corporation");
owner2 = new Owner("Example Corporation 2");
owner3 = new Owner("Example Corporation 3");
ownerCurator.create(owner1);
ownerCurator.create(owner2);
ownerCurator.create(owner3);
// Setup a principal with access to org 1 and 2, but not 3.
Set<Permission> perms = new HashSet<>();
User u = new User("fakeuser", "dontcare");
perms.add(new UsernameConsumersPermission(u, owner1));
perms.add(new OwnerPermission(owner1, Access.ALL));
// just read for org 2
perms.add(new OwnerPermission(owner2, Access.READ_ONLY));
principal = new UserPrincipal(u.getUsername(), perms, false);
setupPrincipal(principal);
}
Aggregations