Search in sources :

Example 21 with ConsumerPrincipal

use of org.candlepin.auth.ConsumerPrincipal 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);
}
Also used : ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) Principal(org.candlepin.auth.Principal) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) Test(org.junit.Test)

Example 22 with ConsumerPrincipal

use of org.candlepin.auth.ConsumerPrincipal 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);
}
Also used : ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) Principal(org.candlepin.auth.Principal) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) Test(org.junit.Test)

Example 23 with ConsumerPrincipal

use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.

the class ConsumerCheckInFilterTest method testUpdatesCheckinWithAnnotation.

@Test
public void testUpdatesCheckinWithAnnotation() throws Exception {
    Date lastCheckin = this.consumer.getLastCheckin();
    Thread.sleep(1000);
    Method method = FakeResource.class.getMethod("checkinMethod", String.class);
    mockResourceMethod(method);
    interceptor.filter(getContext());
    ConsumerPrincipal p = (ConsumerPrincipal) ResteasyProviderFactory.getContextData(Principal.class);
    this.consumerCurator.refresh(this.consumer);
    Date updatedLastCheckin = p.getConsumer().getLastCheckin();
    assertNotEquals(lastCheckin, updatedLastCheckin);
}
Also used : ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) Method(java.lang.reflect.Method) Date(java.util.Date) Principal(org.candlepin.auth.Principal) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) Test(org.junit.Test)

Example 24 with ConsumerPrincipal

use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.

the class ConsumerResourceIntegrationTest method canNotDeleteConsumerOtherThanSelf.

@Test(expected = NotFoundException.class)
public void canNotDeleteConsumerOtherThanSelf() {
    Consumer evilConsumer = TestUtil.createConsumer(standardSystemType, owner);
    consumerCurator.create(evilConsumer);
    setupPrincipal(new ConsumerPrincipal(evilConsumer, owner));
    securityInterceptor.enable();
    consumerResource.deleteConsumer(consumer.getUuid(), principal);
}
Also used : Consumer(org.candlepin.model.Consumer) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) Test(org.junit.Test)

Example 25 with ConsumerPrincipal

use of org.candlepin.auth.ConsumerPrincipal in project candlepin by candlepin.

the class ConsumerResourceIntegrationTest method testCannotGetAnotherConsumersCerts.

@Test(expected = NotFoundException.class)
public void testCannotGetAnotherConsumersCerts() {
    consumerResource.bind(consumer.getUuid(), pool.getId().toString(), null, 1, null, null, false, null, null);
    consumerResource.bind(consumer.getUuid(), pool.getId().toString(), null, 1, null, null, false, null, null);
    consumerResource.bind(consumer.getUuid(), pool.getId().toString(), null, 1, null, null, false, null, null);
    Consumer evilConsumer = TestUtil.createConsumer(standardSystemType, owner);
    consumerCurator.create(evilConsumer);
    setupPrincipal(new ConsumerPrincipal(evilConsumer, owner));
    securityInterceptor.enable();
    consumerResource.getEntitlementCertificates(consumer.getUuid(), null);
}
Also used : Consumer(org.candlepin.model.Consumer) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) Test(org.junit.Test)

Aggregations

ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)27 Test (org.junit.Test)25 Consumer (org.candlepin.model.Consumer)11 Principal (org.candlepin.auth.Principal)9 UpstreamConsumer (org.candlepin.model.UpstreamConsumer)7 Date (java.util.Date)4 Method (java.lang.reflect.Method)3 UserPrincipal (org.candlepin.auth.UserPrincipal)3 PoolDTO (org.candlepin.dto.api.v1.PoolDTO)3 Pool (org.candlepin.model.Pool)3 JobStatus (org.candlepin.pinsetter.core.model.JobStatus)3 Product (org.candlepin.model.Product)2 ResourceInfo (javax.ws.rs.container.ResourceInfo)1 OwnerDTO (org.candlepin.dto.api.v1.OwnerDTO)1 IdentityCertificate (org.candlepin.model.IdentityCertificate)1 Owner (org.candlepin.model.Owner)1 Before (org.junit.Before)1