Search in sources :

Example 11 with ProductCertificate

use of org.candlepin.model.ProductCertificate in project candlepin by candlepin.

the class ProductResource method getProductCertificate.

@ApiOperation(notes = "Retreives a Certificate for a Product", value = "getProductCertificate")
@ApiResponses({ @ApiResponse(code = 404, message = "") })
@GET
@Path("/{product_uuid}/certificate")
@Produces(MediaType.APPLICATION_JSON)
@SecurityHole
public ProductCertificateDTO getProductCertificate(@PathParam("product_uuid") String productUuid) {
    // TODO:
    // Should this be enabled globally? This will create a cert if it hasn't yet been created.
    Product product = this.fetchProduct(productUuid);
    ProductCertificate productCertificate = this.productCertCurator.getCertForProduct(product);
    return this.translator.translate(productCertificate, ProductCertificateDTO.class);
}
Also used : ProductCertificate(org.candlepin.model.ProductCertificate) Product(org.candlepin.model.Product) Path(javax.ws.rs.Path) SecurityHole(org.candlepin.common.auth.SecurityHole) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 12 with ProductCertificate

use of org.candlepin.model.ProductCertificate in project candlepin by candlepin.

the class ProductResourceTest method getProductCertificate.

@Test
public void getProductCertificate() {
    Owner owner = this.createOwner("Example-Corporation");
    Product entity = this.createProduct(owner);
    // ensure we check SecurityHole
    securityInterceptor.enable();
    ProductCertificate cert = new ProductCertificate();
    cert.setCert("some text");
    cert.setKey("some key");
    cert.setProduct(entity);
    productCertificateCurator.create(cert);
    ProductCertificateDTO cert1 = productResource.getProductCertificate(entity.getUuid());
    ProductCertificateDTO expected = this.modelTranslator.translate(cert, ProductCertificateDTO.class);
    assertEquals(cert1, expected);
}
Also used : Owner(org.candlepin.model.Owner) ProductCertificate(org.candlepin.model.ProductCertificate) Product(org.candlepin.model.Product) ProductCertificateDTO(org.candlepin.dto.api.v1.ProductCertificateDTO) Test(org.junit.Test)

Aggregations

ProductCertificate (org.candlepin.model.ProductCertificate)12 Product (org.candlepin.model.Product)9 Owner (org.candlepin.model.Owner)8 Test (org.junit.Test)8 ApiOperation (io.swagger.annotations.ApiOperation)2 ApiResponses (io.swagger.annotations.ApiResponses)2 File (java.io.File)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 SecurityHole (org.candlepin.common.auth.SecurityHole)2 ProductCertificateDTO (org.candlepin.dto.api.v1.ProductCertificateDTO)2 Entitlement (org.candlepin.model.Entitlement)2 Pool (org.candlepin.model.Pool)2 Transactional (com.google.inject.persist.Transactional)1 FileInputStream (java.io.FileInputStream)1 FileWriter (java.io.FileWriter)1 InputStream (java.io.InputStream)1 Key (java.security.Key)1 KeyPair (java.security.KeyPair)1