use of rhsm.data.CertStatistics in project rhsm-qe by RedHatQE.
the class SubscriptionManagerTasks method getCertStatisticsFromCertFile.
public CertStatistics getCertStatisticsFromCertFile(File certPemFile) {
sshCommandRunner.runCommandAndWait(/*WithoutLogging*/
"rct stat-cert " + certPemFile.getPath());
String rawStatistics = sshCommandRunner.getStdout();
CertStatistics certStatistics = CertStatistics.parse(rawStatistics);
return certStatistics;
}
use of rhsm.data.CertStatistics in project rhsm-qe by RedHatQE.
the class CertificateTests method testEntitlementCertStatisticsForZeroContentSetEntitlement.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36642", "RHEL7-51453" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "assert the statistic values reported by the rct stat-cert tool for a zero-content set entitlement", groups = { "Tier2Tests", "blockedByBug-966137" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testEntitlementCertStatisticsForZeroContentSetEntitlement() {
File zeroContentSetEntitlementCertFile = new File("/tmp/zeroContentSetEntitlementCert.pem");
client.runCommandAndWait("echo \"" + zeroContentSetEntitlementCert.trim() + "\" > " + zeroContentSetEntitlementCertFile);
EntitlementCert entitlementCert = clienttasks.getEntitlementCertFromEntitlementCertFile(zeroContentSetEntitlementCertFile);
// [root@jsefler-5 tmp]# rct cat-cert /tmp/8a85f9843ad21fe4013ae6a01d0b5d3c.pem
//
// +-------------------------------------------+
// Entitlement Certificate
// +-------------------------------------------+
//
// Certificate:
// Path: /tmp/8a85f9843ad21fe4013ae6a01d0b5d3c.pem
// Version: 3.0
// Serial: 8429484359950764937
// Start Date: 2012-11-09 05:00:00+00:00
// End Date: 2013-11-09 04:59:59+00:00
// Pool ID: Not Available
//
// Subject:
// CN: 8a85f9843e139e8c013e1e24d82f1ed0
//
// Issuer:
// C: US
// CN: Red Hat Candlepin Authority
// O: Red Hat, Inc.
// OU: Red Hat Network
// ST: North Carolina
// emailAddress: ca-support@redhat.com
Assert.assertEquals(entitlementCert.id, "8a85f9843e139e8c013e1e24d82f1ed0", "rct cat-cert reports this id.");
Assert.assertEquals(entitlementCert.issuer, "Red Hat Candlepin Authority", "rct cat-cert reports this issuer.");
Assert.assertEquals(entitlementCert.contentNamespaces.size(), 0, "rct cat-cert reports this number of Content sets.");
CertStatistics certStatistics = clienttasks.getCertStatisticsFromCertFile(zeroContentSetEntitlementCertFile);
// [root@jsefler-5 tmp]# rct stat-cert /tmp/8a85f9843ad21fe4013ae6a01d0b5d3c.pem
// Type: Entitlement Certificate
// Version: 3.0
// DER size: 1891b
// Subject Key ID size: 20b
// Content sets: 0
Assert.assertEquals(certStatistics.type, "Entitlement Certificate", "rct stat-cert reports this Type.");
Assert.assertEquals(certStatistics.version, entitlementCert.version, "rct stat-cert reports this Version.");
Assert.assertEquals(certStatistics.derSize, "1891b", "rct stat-cert reports this DER size.");
// TODO assert something better than not null
Assert.assertEquals(certStatistics.subjectKeyIdSize, "20b", "rct stat-cert reports this Subject Key ID size.");
Assert.assertEquals(certStatistics.contentSets, Integer.valueOf(0), "rct stat-cert reports this number of Content sets.");
}
use of rhsm.data.CertStatistics in project rhsm-qe by RedHatQE.
the class CertificateTests method testProductCertStatistics.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36644", "RHEL7-51455" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "assert the statistic values reported by the rct stat-cert tool for currently installed product certs", groups = { "Tier2Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testProductCertStatistics() {
// get all the product certs on the system
List<ProductCert> productCerts = new ArrayList();
List<ProductCert> installedProductCerts = clienttasks.getCurrentProductCerts();
List<ProductCert> migrationProductCerts = clienttasks.getProductCerts("/usr/share/rhsm/product/RHEL-" + clienttasks.redhatReleaseX);
productCerts.addAll(installedProductCerts);
productCerts.addAll(migrationProductCerts);
// loop through all of the current product certs
if (productCerts.isEmpty())
throw new SkipException("There are currently no installed product certs to assert statistics.");
for (ProductCert productCert : productCerts) {
CertStatistics certStatistics = clienttasks.getCertStatisticsFromCertFile(productCert.file);
// skip the generated TESTDATA productCerts
if (productCert.file.toString().endsWith("_.pem"))
continue;
// [root@jsefler-6 ~]# rct stat-cert /etc/pki/product/69.pem
// Type: Product Certificate
// Version: 1.0
// DER size: 1553b
String expectedDerSize = client.runCommandAndWait("openssl x509 -in " + productCert.file.getPath() + " -outform der -out /tmp/cert.der && du -b /tmp/cert.der | cut -f 1").getStdout().trim();
expectedDerSize += "b";
Assert.assertEquals(certStatistics.type, "Product Certificate", "rct stat-cert reports this Type.");
Assert.assertEquals(certStatistics.version, productCert.version, "rct stat-cert reports this Version.");
Assert.assertEquals(certStatistics.derSize, expectedDerSize, "rct stat-cert reports this DER size.");
Assert.assertNull(certStatistics.subjectKeyIdSize, "rct stat-cert does NOT report a Subject Key ID size.");
Assert.assertNull(certStatistics.contentSets, "rct stat-cert does NOT report a number of Content sets.");
}
}
use of rhsm.data.CertStatistics in project rhsm-qe by RedHatQE.
the class CertificateTests method testConsumerCertStatistics.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36639", "RHEL7-51451" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier2")
@Test(description = "assert the statistic values reported by the rct stat-cert tool for the current consumer cert", groups = { "Tier2Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testConsumerCertStatistics() {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, false, null, null, null, null, null);
ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
Assert.assertEquals(consumerCert.version, "1.0", "The rct cat-cert tool reports this consumer cert to be a V1 Certificate: " + consumerCert);
CertStatistics certStatistics = clienttasks.getCertStatisticsFromCertFile(consumerCert.file);
// [root@jsefler-6 ~]# rct stat-cert /etc/pki/consumer/cert.pem
// Type: Identity Certificate
// Version: 1.0
// DER size: 925b
// Subject Key ID size: 20b
String expectedDerSize = client.runCommandAndWait("openssl x509 -in " + consumerCert.file.getPath() + " -outform der -out /tmp/cert.der && du -b /tmp/cert.der | cut -f 1").getStdout().trim();
expectedDerSize += "b";
Assert.assertEquals(certStatistics.type, "Identity Certificate", "rct stat-cert reports this Type.");
Assert.assertEquals(certStatistics.version, consumerCert.version, "rct stat-cert reports this Version.");
Assert.assertEquals(certStatistics.derSize, expectedDerSize, "rct stat-cert reports this DER size.");
// TODO assert something better than not null
Assert.assertNotNull(certStatistics.subjectKeyIdSize, "rct stat-cert reports this Subject Key ID size.");
Assert.assertNull(certStatistics.contentSets, "rct stat-cert does NOT report a number of Content sets.");
}
use of rhsm.data.CertStatistics in project rhsm-qe by RedHatQE.
the class CertificateTests method testEntitlementCertStatistics.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20035", "RHEL7-33079" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.POSITIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "assert the statistic values reported by the rct stat-cert tool for currently subscribed entitlements", groups = { "Tier1Tests" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testEntitlementCertStatistics() {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, false, null, null, null, null, null);
// get some entitlements!
clienttasks.subscribeToTheCurrentlyAllAvailableSubscriptionPoolsCollectively();
List<EntitlementCert> entitlementCerts = clienttasks.getCurrentEntitlementCerts();
// loop through all of the current entitlement certs
if (entitlementCerts.isEmpty())
throw new SkipException("There are currently no entitlement certs to assert statistics.");
for (EntitlementCert entitlementCert : entitlementCerts) {
CertStatistics certStatistics = clienttasks.getCertStatisticsFromCertFile(entitlementCert.file);
// [root@jsefler-6 ~]# rct stat-cert /etc/pki/entitlement/5254857399115244164.pem
// Type: Entitlement Certificate
// Version: 3.0
// DER size: 947b
// Subject Key ID size: 20b
// Content sets: 3
String expectedDerSize = client.runCommandAndWait("openssl x509 -in " + entitlementCert.file.getPath() + " -outform der -out /tmp/cert.der && du -b /tmp/cert.der | cut -f 1").getStdout().trim();
expectedDerSize += "b";
Assert.assertEquals(certStatistics.type, "Entitlement Certificate", "rct stat-cert reports this Type.");
Assert.assertEquals(certStatistics.version, entitlementCert.version, "rct stat-cert reports this Version.");
Assert.assertEquals(certStatistics.derSize, expectedDerSize, "rct stat-cert reports this DER size.");
// TODO assert something better than not null
Assert.assertNotNull(certStatistics.subjectKeyIdSize, "rct stat-cert reports this Subject Key ID size.");
Assert.assertEquals(certStatistics.contentSets, Integer.valueOf(entitlementCert.contentNamespaces.size()), "rct stat-cert reports this number of Content sets.");
}
}
Aggregations