Package org.candlepin.model

Examples of org.candlepin.model.Consumer


        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);
        key1.addProduct(prod2);
        key1.setAutoAttach(true);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        Set<ConsumerInstalledProduct> cips = new HashSet<ConsumerInstalledProduct>();
        ConsumerInstalledProduct cip = new ConsumerInstalledProduct(prod1.getId(), prod1.getName());
        cips.add(cip);
        consumer.setInstalledProducts(cips);

        AutobindData ad = new AutobindData(consumer).forProducts(prodIds);
        consumerBindUtil.handleActivationKeys(consumer, keys);
        verify(entitler).bindByProducts(eq(ad));
    }
View Full Code Here


        List<ActivationKey> keys = new ArrayList<ActivationKey>();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);
        key1.setServiceLevel("I don't exist");

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        doThrow(new BadRequestException("exception")).when(serviceLevelValidator)
            .validate(eq(owner), eq(key1.getServiceLevel()));
        consumerBindUtil.handleActivationKeys(consumer, keys);
    }
View Full Code Here

        List<ActivationKey> keys = mockActivationKeys();
        ActivationKey key1 = new ActivationKey("key1", owner);
        keys.add(key1);
        key1.setServiceLevel("I don't exist");

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        doThrow(new BadRequestException("exception")).when(serviceLevelValidator)
            .validate(eq(owner), eq(key1.getServiceLevel()));
        consumerBindUtil.handleActivationKeys(consumer, keys);
    }
View Full Code Here

        Product prod1 = TestUtil.createProduct();
        Pool ghost = TestUtil.createPool(owner, prod1, 5);
        ghost.setId("ghost-pool");
        key1.addPool(ghost, 10L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(ghost.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        consumerBindUtil.handleActivationKeys(consumer, keys);
    }
View Full Code Here

        Product prod3 = TestUtil.createProduct();
        Pool pool3 = TestUtil.createPool(owner, prod3, 5);
        pool3.setId("pool3");
        key1.addPool(pool3, 5L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(pool1.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        when(entitler.bindByPool(eq(pool2.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        consumerBindUtil.handleActivationKeys(consumer, keys);
View Full Code Here

        Product prod3 = TestUtil.createProduct();
        Pool pool3 = TestUtil.createPool(owner, prod3, 5);
        pool3.setId("pool3");
        key2.addPool(pool3, 5L);

        Consumer consumer = new Consumer("sys.example.com", null, null, system);
        when(entitler.bindByPool(eq(pool1.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        when(entitler.bindByPool(eq(pool2.getId()), eq(consumer), eq(10)))
            .thenThrow(new ForbiddenException("fail"));
        consumerBindUtil.handleActivationKeys(consumer, keys);
View Full Code Here

        ResourceMethod rmethod = mock(ResourceMethod.class);
        when(rmethod.getMethod()).thenReturn(method);
        Class clazz = FakeResource.class;
        when(rmethod.getResourceClass()).thenReturn(clazz);

        Consumer c = createConsumer(createOwner());
        methodInjector.setArguments(new Object[] {c.getUuid()});
        when(consumerCurator.getConsumer(eq(c.getUuid()))).thenReturn(c);
        when(consumerCurator.findByUuid(eq(c.getUuid()))).thenReturn(c);

        // create mock certs to trigger SSLAuth provider
        X509Certificate[] certs = new X509Certificate[1];
        X509Certificate cert = mock(X509Certificate.class);
        certs[0] = cert;
        req.setAttribute("javax.servlet.request.X509Certificate", certs);

        java.security.Principal p = mock(java.security.Principal.class);
        when(p.getName()).thenReturn("CN=" + c.getUuid() + ", C=US, L=Raleigh");
        when(cert.getSubjectDN()).thenReturn(p);

        interceptor.preProcess(req, rmethod);

        Principal p1 = ResteasyProviderFactory.getContextData(Principal.class);
View Full Code Here

        ResourceMethod rmethod = mock(ResourceMethod.class);
        when(rmethod.getMethod()).thenReturn(method);
        Class clazz = FakeResource.class;
        when(rmethod.getResourceClass()).thenReturn(clazz);

        Consumer c = createConsumer(createOwner());
        Consumer c2 = createConsumer(createOwner());
        methodInjector.setArguments(new Object[] {c2.getUuid()});
        when(consumerCurator.getConsumer(eq(c.getUuid()))).thenReturn(c);
        when(consumerCurator.findByUuid(eq(c2.getUuid()))).thenReturn(c2);

        // create mock certs to trigger SSLAuth provider
        X509Certificate[] certs = new X509Certificate[1];
        X509Certificate cert = mock(X509Certificate.class);
        certs[0] = cert;
View Full Code Here

    }


    @Test
    public void preEntitlementShouldNotAllowOverConsumptionOfEntitlements() {
        Consumer c = TestUtil.createConsumer();
        c.getType().setManifest(true);

        Product prod = TestUtil.createProduct();
        Pool p = TestUtil.createPool(prod);
        p.setQuantity(5L);
View Full Code Here

        assertEquals("rulefailed.no.entitlements.available", error.getResourceKey());
    }

    @Test
    public void preEntitlementNoDerivedProductCapabilityProducesErrorOnBind() {
        Consumer c = TestUtil.createConsumer();
        c.setCapabilities(new HashSet<ConsumerCapability>());
        c.getType().setManifest(true);

        Product prod = TestUtil.createProduct();
        Pool p = TestUtil.createPool(prod);
        p.setDerivedProductId("sub-prod-id");
View Full Code Here

TOP

Related Classes of org.candlepin.model.Consumer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.