use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class PinsetterJobListenerTest method bug863518ToBeExecuted.
@Test
public void bug863518ToBeExecuted() {
Principal principal = mock(Principal.class);
JobDataMap map = new JobDataMap();
JobDetail detail = mock(JobDetail.class);
map.put(PinsetterJobListener.PRINCIPAL_KEY, principal);
when(ctx.getMergedJobDataMap()).thenReturn(map);
when(detail.getKey()).thenReturn(jobKey("foo"));
when(ctx.getJobDetail()).thenReturn(detail);
when(jcurator.find(any(String.class))).thenThrow(new RuntimeException());
try {
listener.jobToBeExecuted(ctx);
} catch (RuntimeException re) {
// do nothing, we're really trying to verify end is called
}
verify(unitOfWork, atLeastOnce()).end();
}
use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class TestPrincipalProvider method get.
@Override
public Principal get() {
TestPrincipalProviderSetter principalSingleton = TestPrincipalProviderSetter.get();
Principal principal = principalSingleton.getPrincipal();
if (principal == null) {
List<Permission> permissions = new ArrayList<>();
permissions.add(new OwnerPermission(new Owner(OWNER_NAME), Access.ALL));
principal = new UserPrincipal("Default User", permissions, true);
}
return principal;
}
use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class ConsumerResourceCreationTest method orgRequiredWithActivationKeys.
@Test(expected = BadRequestException.class)
public void orgRequiredWithActivationKeys() {
Principal p = new NoAuthPrincipal();
List<String> keys = mockActivationKeys();
ConsumerDTO consumer = TestUtil.createConsumerDTO("sys.example.com", null, null, systemDto);
resource.create(consumer, p, null, null, createKeysString(keys), true);
}
use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class ConsumerResourceCreationTest method oauthRegistrationSupported.
@Test
public void oauthRegistrationSupported() {
// Should be able to register successfully with as a trusted user principal:
Principal p = new TrustedUserPrincipal("anyuser");
ConsumerDTO consumer = TestUtil.createConsumerDTO("sys.example.com", null, null, systemDto);
resource.create(consumer, p, null, owner.getKey(), null, true);
}
use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class ConsumerResourceCreationTest method registerWithKeys.
@Test
public void registerWithKeys() {
// No auth should be required for registering with keys:
Principal p = new NoAuthPrincipal();
List<String> keys = mockActivationKeys();
ConsumerDTO consumer = TestUtil.createConsumerDTO("sys.example.com", null, null, systemDto);
resource.create(consumer, p, null, owner.getKey(), createKeysString(keys), true);
for (String keyName : keys) {
verify(activationKeyCurator).lookupForOwner(keyName, owner);
}
}
Aggregations