use of org.candlepin.dto.rules.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceTest method testValidateShareConsumerRequiresRecipientFact.
@Test
public void testValidateShareConsumerRequiresRecipientFact() {
ConsumerType share = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.SHARE));
ConsumerTypeDTO shareDto = this.translator.translate(share, ConsumerTypeDTO.class);
OwnerDTO ownerDto = new OwnerDTO().setDisplayName("Test Owner");
ConsumerDTO c = createConsumerDTO("test-consumer", "test-user", ownerDto, shareDto);
ConsumerResource consumerResource = new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, null, null, mockEntitlementCurator, null, mockEntitlementCertServiceAdapter, i18n, null, null, null, null, null, mockPoolManager, null, mockOwnerCurator, null, null, null, null, null, null, new CandlepinCommonTestConfig(), null, null, null, consumerBindUtil, null, null, factValidator, null, consumerEnricher, migrationProvider, translator);
UserPrincipal uap = mock(UserPrincipal.class);
when(uap.canAccess(any(Object.class), any(SubResource.class), any(Access.class))).thenReturn(Boolean.TRUE);
Owner o = mock(Owner.class);
when(mockOwnerCurator.lookupByKey(any(String.class))).thenReturn(o);
c.setFact("foo", "bar");
thrown.expect(BadRequestException.class);
thrown.expectMessage("must specify a recipient org");
consumerResource.create(c, uap, "test-user", "test-owner", null, false);
}
use of org.candlepin.dto.rules.v1.ConsumerDTO in project candlepin by candlepin.
the class OwnerResourceTest method consumerCannotListConsumersFromAnotherOwner.
@Test
public void consumerCannotListConsumersFromAnotherOwner() {
Consumer c = createConsumer(owner);
Owner owner2 = ownerCurator.create(new Owner("Owner2"));
Consumer c2 = createConsumer(owner2);
List<String> uuids = new ArrayList<>();
uuids.add(c.getUuid());
uuids.add(c2.getUuid());
setupPrincipal(owner, Access.ALL);
securityInterceptor.enable();
CandlepinQuery<ConsumerDTO> result = ownerResource.listConsumers(owner.getKey(), null, null, uuids, null, null, null, null, null, null);
assertNotNull(result);
List<ConsumerDTO> consumers = result.list();
assertEquals(1, consumers.size());
}
use of org.candlepin.dto.rules.v1.ConsumerDTO in project candlepin by candlepin.
the class OwnerResourceTest method consumerCanListMultipleConsumers.
@Test
public void consumerCanListMultipleConsumers() {
Consumer c = createConsumer(owner);
Consumer c2 = createConsumer(owner);
List<String> uuids = new ArrayList<>();
uuids.add(c.getUuid());
uuids.add(c2.getUuid());
setupPrincipal(owner, Access.ALL);
securityInterceptor.enable();
CandlepinQuery<ConsumerDTO> result = ownerResource.listConsumers(owner.getKey(), null, null, uuids, null, null, null, null, null, null);
assertNotNull(result);
List<ConsumerDTO> consumers = result.list();
assertEquals(2, consumers.size());
}
use of org.candlepin.dto.rules.v1.ConsumerDTO in project candlepin by candlepin.
the class OwnerResourceTest method consumerCanListConsumersByIdWhenOtherParametersPresent.
@Test
public void consumerCanListConsumersByIdWhenOtherParametersPresent() {
Consumer c = createConsumer(owner);
List<String> uuids = new ArrayList<>();
uuids.add(c.getUuid());
setupPrincipal(owner, Access.ALL);
securityInterceptor.enable();
Set<String> types = new HashSet<>();
types.add("type");
consumerTypeCurator.create(new ConsumerType("type"));
CandlepinQuery<ConsumerDTO> result = ownerResource.listConsumers(owner.getKey(), "username", types, uuids, null, null, null, null, null, new PageRequest());
assertNotNull(result);
List<ConsumerDTO> consumers = result.list();
assertEquals(0, consumers.size());
}
use of org.candlepin.dto.rules.v1.ConsumerDTO in project candlepin by candlepin.
the class EntitlementImporterTest method init.
@Before
public void init() {
this.owner = new Owner();
this.translator = new StandardTranslator(mockConsumerTypeCurator, mockEnvironmentCurator, ownerCurator);
i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
this.importer = new EntitlementImporter(certSerialCurator, cdnCurator, i18n, mockProductCurator, ec, translator);
ConsumerType ctype = TestUtil.createConsumerType();
ctype.setId("test-ctype");
consumer = TestUtil.createConsumer(ctype, owner);
consumerDTO = this.translator.translate(consumer, ConsumerDTO.class);
consumerDTO.setUrlWeb("");
consumerDTO.setUrlApi("");
when(this.mockConsumerTypeCurator.getConsumerType(eq(consumer))).thenReturn(ctype);
when(this.mockConsumerTypeCurator.find(eq(ctype.getId()))).thenReturn(ctype);
cert = createEntitlementCertificate("my-test-key", "my-cert");
cert.setId("test-id");
reader = mock(Reader.class);
meta = new Meta();
meta.setCdnLabel("test-cdn");
testCdn = new Cdn("test-cdn", "Test CDN", "https://test.url.com");
when(cdnCurator.lookupByLabel("test-cdn")).thenReturn(testCdn);
}
Aggregations