use of org.candlepin.model.Owner in project candlepin by candlepin.
the class RefresherTest method testPoolOnlyExaminedOnceProductAndOwner.
@Test
public void testPoolOnlyExaminedOnceProductAndOwner() {
Owner owner = TestUtil.createOwner();
Product product = mock(Product.class);
ProductData productData = mock(ProductData.class);
when(product.getUuid()).thenReturn("product id");
when(product.toDTO()).thenReturn(productData);
Pool pool = new Pool();
pool.setSourceSubscription(new SourceSubscription("subId", "master"));
pool.setOwner(owner);
Subscription subscription = new Subscription();
subscription.setId("subId");
subscription.setOwner(owner);
List<Pool> pools = new ArrayList<>();
pools.add(pool);
List<Subscription> subscriptions = new ArrayList<>();
subscriptions.add(subscription);
when(subAdapter.getSubscriptions(eq(productData))).thenReturn(subscriptions);
when(subAdapter.getSubscriptions(owner)).thenReturn(subscriptions);
when(subAdapter.getSubscription("subId")).thenReturn(subscription);
when(poolManager.lookupBySubscriptionId(owner, "subId")).thenReturn(pools);
refresher.add(owner);
refresher.add(product);
refresher.run();
verify(poolManager, times(1)).refreshPoolsWithRegeneration(eq(subAdapter), eq(owner), eq(false));
verify(poolManager, times(0)).updatePoolsForMasterPool(any(List.class), any(Pool.class), eq(pool.getQuantity()), eq(false), any(Map.class));
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class EventSinkImplTest method importCreatedShouldEmitSuccessfully.
@Test
public void importCreatedShouldEmitSuccessfully() throws Exception {
Owner owner = new Owner("Import guy");
eventSinkImpl.emitImportCreated(owner);
eventSinkImpl.sendEvents();
verify(mockClientProducer).send(any(ClientMessage.class));
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class EventSinkImplTest method emptyKeyShouldEmitSuccessfully.
@Test
public void emptyKeyShouldEmitSuccessfully() throws Exception {
ActivationKey key = TestUtil.createActivationKey(new Owner("deadbeef"), null);
eventSinkImpl.emitActivationKeyCreated(key);
eventSinkImpl.sendEvents();
verify(mockClientProducer).send(any(ClientMessage.class));
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class BasicAuthViaUserServiceTest method correctPrincipalNoPassword.
@Test
public void correctPrincipalNoPassword() throws Exception {
Owner owner = new Owner("user", "user");
setUserNoPassword("user");
when(userService.validateUser("user", null)).thenReturn(true);
Set<OwnerPermission> permissions = new HashSet<>();
permissions.add(new OwnerPermission(owner, Access.ALL));
when(userService.findByLogin("user")).thenReturn(new User());
UserPrincipal expected = new UserPrincipal("user", new ArrayList<>(permissions), false);
assertEquals(expected, this.auth.getPrincipal(request));
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class BasicAuthViaUserServiceTest method correctPrincipal.
/**
* Valid credentials are given - checks if the correct principal is created.
*
* @throws Exception
*/
@Test
public void correctPrincipal() throws Exception {
Owner owner = new Owner("user", "user");
setUserAndPassword("user", "redhat");
when(userService.validateUser("user", "redhat")).thenReturn(true);
// TODO: test will fail, need to mock the permissions setup
Set<OwnerPermission> permissions = new HashSet<>();
permissions.add(new OwnerPermission(owner, Access.ALL));
when(userService.findByLogin("user")).thenReturn(new User());
UserPrincipal expected = new UserPrincipal("user", new ArrayList<>(permissions), false);
assertEquals(expected, this.auth.getPrincipal(request));
}
Aggregations