Search in sources :

Example 26 with ConsumerPrincipal

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

the class ConsumerResourceIntegrationTest method consumerCanDeleteSelf.

@Test
public void consumerCanDeleteSelf() throws GeneralSecurityException, IOException {
    Consumer toSubmit = new Consumer(CONSUMER_NAME, USER_NAME, owner, standardSystemType);
    toSubmit.getFacts().put(METADATA_NAME, METADATA_VALUE);
    Consumer c = consumerCurator.create(toSubmit);
    IdentityCertificate idCert = icsa.generateIdentityCert(c);
    c.setIdCert(idCert);
    setupPrincipal(new ConsumerPrincipal(c, owner));
    consumerResource.deleteConsumer(c.getUuid(), principal);
}
Also used : Consumer(org.candlepin.model.Consumer) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) IdentityCertificate(org.candlepin.model.IdentityCertificate) Test(org.junit.Test)

Example 27 with ConsumerPrincipal

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

the class ConsumerResourceIntegrationTest method consumerShouldSeeOwnEntitlements.

@Test
public void consumerShouldSeeOwnEntitlements() {
    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);
    setupPrincipal(new ConsumerPrincipal(consumer, owner));
    securityInterceptor.enable();
    assertEquals(3, consumerResource.listEntitlements(consumer.getUuid(), null, true, "", new ArrayList<>(), null).size());
}
Also used : 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