use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class CertificateTests method testYumUpdateWithDisabledRepoWillNotDeleteJBossProductId.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20034", "RHEL7-55176" }, 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 = "When updating a RHEL package on a system with JBoss, verify that the JBoss productId is not deleted when calling yum update with --disablerepo=jb-eap-6-for-rhel-6-server-rpms", groups = { "Tier1Tests", "VerifyYumUpdateWithDisabledRepoWillNotDeleteJBossProductId_Test", "blockedByBug-1159163", "blockedByBug-1512948" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumUpdateWithDisabledRepoWillNotDeleteJBossProductId() throws JSONException, Exception {
// fixed in https://bugzilla.redhat.com/show_bug.cgi?id=1159163#c12 subscription-manager commit 68d210bb9145e7ea65aea979fde694436e3e0373 subscription-manager-1.14.6-1
clienttasks.unregister(null, null, null, null);
restoreOriginalRhsmProductCertDirAndProductIdJsonFile();
// hard data for this test...
String rhelPackage = "zsh";
// Required Tags: rhel-6-server Arches: x86_64, x86
String rhelRepo = "rhel-6-server-rpms";
rhelRepo = String.format("rhel-%s-server-rpms", clienttasks.redhatReleaseX);
// Red Hat Enterprise Linux Server // Tags: rhel-6,rhel-6-server Arch: x86_64
String rhelProductId = "69";
// rpm -q jline-eap6.noarch --requires => rpmlib
String jbossPackage = "jline-eap6";
// Required Tags: rhel-6-server Arches: x86_64, x86
String jbossRepo = "jb-eap-6-for-rhel-6-server-rpms";
jbossRepo = String.format("jb-eap-6-for-rhel-%s-server-rpms", clienttasks.redhatReleaseX);
// JBoss Enterprise Application Platform
String jbossProductId = "183";
if (clienttasks.arch.equals("ppc64")) {
// Required Tags: rhel-6-ibm-power Arches: ppc64
rhelRepo = "rhel-6-for-power-rpms";
rhelRepo = String.format("rhel-%s-for-power-rpms", clienttasks.redhatReleaseX);
// Red Hat Enterprise Linux for Power, big endian // Tags: rhel-6,rhel-6-ibm-power Arch: ppc64
rhelProductId = "74";
// Required Tags: rhel-6-ibm-power Arches: ppc64
jbossRepo = "jb-eap-6-for-rhel-6-for-power-rpms";
jbossRepo = String.format("jb-eap-6-for-rhel-%s-for-power-rpms", clienttasks.redhatReleaseX);
// JBoss Enterprise Application Platform
jbossProductId = "183";
}
// need to disable the beaker repos (actually all repos that contain a productid in the metadata would be best) to prevent the yum product-id plugin from considering it for an update to the installed RHEL product cert
if (clienttasks.isPackageInstalled(rhelPackage))
clienttasks.yumRemovePackage(rhelPackage, "--disablerepo=beaker-*");
// need to disable the beaker repos (actually all repos that contain a productid in the metadata would be best) to prevent the yum product-id plugin from considering it for an update to the installed RHEL product cert
if (clienttasks.isPackageInstalled(jbossPackage))
clienttasks.yumRemovePackage(jbossPackage, "--disablerepo=beaker-*");
// determine the currently installed product certs
List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
ProductCert rhelProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductId, currentProductCerts);
if (rhelProductCert == null)
throw new SkipException("JBoss Enterprise Application Platform is not offered on this variant '" + clienttasks.variant + "' of RHEL.");
ProductCert jbossProductCert = ProductCert.findFirstInstanceWithMatchingFieldFromList("productId", jbossProductId, currentProductCerts);
Assert.assertNull(jbossProductCert, "Do not expect the JBoss product to be installed at the beginning of this test.");
// configure a temporary productCertDir and backup the productid json database file
log.info("Configuring a temporary product cert directory...");
// remember the original so it can be restored later
if (rhsmProductCertDir == null) {
rhsmProductCertDir = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "rhsm", "productCertDir");
Assert.assertNotNull(rhsmProductCertDir);
}
RemoteFileTasks.runCommandAndAssert(client, "mkdir -p " + tmpProductCertDir, Integer.valueOf(0));
RemoteFileTasks.runCommandAndAssert(client, "rm -f " + tmpProductCertDir + "/*.pem", Integer.valueOf(0));
// due to /etc/pki/product-default/ certs, this assert will fail when /etc/pki/product/ is empty RemoteFileTasks.runCommandAndAssert(client,"cp "+rhsmProductCertDir+"/*.pem "+tmpProductCertDir, Integer.valueOf(0));
RemoteFileTasks.runCommandAndWait(client, "cp " + rhsmProductCertDir + "/*.pem " + tmpProductCertDir, TestRecords.action());
clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", tmpProductCertDir);
// remember the original so it can be restored later
if (productIdJsonFile == null) {
productIdJsonFile = client.runCommandAndWait("cat " + clienttasks.productIdJsonFile).getStdout().replaceAll("\\s*\n\\s*", "");
Assert.assertTrue(productIdJsonFile != null && !productIdJsonFile.isEmpty());
}
// register with autosubscribe for rhel content
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, null, null, null, null, null, null);
List<InstalledProduct> currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
InstalledProduct rhelInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductId, currentlyInstalledProducts);
Assert.assertNotNull(rhelInstalledProduct, "Expecting the installed RHEL Server product '" + rhelProductId + "' to be installed.");
if (!rhelInstalledProduct.status.equals("Subscribed") && CandlepinType.standalone.equals(sm_serverType))
throw new SkipException("This test is designed for execution against a non-standalone candlepin server where available RHEL subscriptions are expected.");
Assert.assertEquals(rhelInstalledProduct.status, "Subscribed", "Expecting the RHEL Server product to have been auto-subscribed during registration.");
// subscribe to JBoss Enterprise Application Platform - Example SKU MW0167254 Red Hat JBoss Enterprise Application Platform with Management, 16 Core Standard, L3 Support Partner)
String jbossPoolId = null;
List<SubscriptionPool> jbossSubscriptionPools = clienttasks.getCurrentlyAvailableSubscriptionPools(jbossProductId, sm_serverUrl);
if (jbossSubscriptionPools.isEmpty() && !CandlepinType.standalone.equals(sm_serverType))
Assert.fail("Expected to find an available subscription pool for Red Hat JBoss Enterprise Application Platform.");
if (jbossSubscriptionPools.isEmpty())
throw new SkipException("Cannot run this test when there is no available subscription for Red Hat JBoss Enterprise Application Platform.");
// too many asserts... clienttasks.subscribeToSubscriptionPool(jbossSubscriptionPools.get(0));
clienttasks.subscribe_(null, null, jbossSubscriptionPools.get(0).poolId, null, null, null, null, null, null, null, null, null, null);
// enable the jb-eap-6-for-rhel-6-server-rpms repo
// Note: This is necessary. If only enabled during yum install --enablerepo=jb-eap-6-for-rhel-6-server-rpms then the jboss product id will install, but it will also be deleted during the yum install of a rhel package.
clienttasks.repos(null, null, null, jbossRepo, null, null, null, null, null);
// yum install jline-eap6 from repo jb-eap-6-for-rhel-6-server-rpms
// clienttasks.yumInstallPackageFromRepo(jbossPackage, jbossRepo, null);
clienttasks.yumInstallPackage(jbossPackage);
// assert that the jboss product id 183 has been newly installed
currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
InstalledProduct jbossInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", jbossProductId, currentlyInstalledProducts);
Assert.assertNotNull(jbossInstalledProduct, "After installing jboss package '" + jbossPackage + "' from enabled jboss repo '" + jbossRepo + "', the jboss product id '" + jbossProductId + "' is installed.");
// now for the real test... install a rhel package with yum --disablerepo and then verify that the jboss product cert remains installed...
// clienttasks.repos(null, null, null, rhelRepo, null, null, null, null); // is already enabled by default
clienttasks.yumInstallPackage(rhelPackage, "--disablerepo=" + jbossRepo);
// verify that the jboss product cert remains installed - Bug 1159163 - RHSM product certificate gets deleted by product-id plugin on running 'yum update --disablerepo
currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
jbossInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", jbossProductId, currentlyInstalledProducts);
Assert.assertNotNull(jbossInstalledProduct, "After installing rhel package '" + rhelPackage + "' while disabling the jboss repo '" + jbossRepo + "' in-line, the jboss product id '" + jbossProductId + "' remains installed.");
// remove the only installed jboss package while disabling the rhel repo and verify the jboss product id has been removed, but the rhel product id remains
// TEMPORARY WORKAROUND
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1222627 - deletion of JBOSS product certificate is neglected by product-id plugin on running 'yum remove JBOSS-PKG --disablerepo=RHEL-REPO'
String bugId = "1222627";
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
log.warning("While bug '" + bugId + "' is open, we will exclude the --disablerepo=" + rhelRepo + " option from the yum removal of the jboss package.");
// THIS PASSES THE FOLLOWING Assert.assertNull(jbossInstalledProduct,...
clienttasks.yumRemovePackage(jbossPackage);
} else
// END OF WORKAROUND
// THIS FAILS THE FOLLOWING Assert.assertNull(jbossInstalledProduct,... due to Bug 1222627
clienttasks.yumRemovePackage(jbossPackage, "--disablerepo=" + rhelRepo);
// verify that the jboss product cert is removed
currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
jbossInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", jbossProductId, currentlyInstalledProducts);
Assert.assertNull(jbossInstalledProduct, "After removing jboss package '" + jbossPackage + "' while disabling rhel repo '" + rhelRepo + "', the jboss product id '" + jbossProductId + "' is removed (because it is the final remaining package installed from jboss repo '" + jbossRepo + "').");
// verify that the rhel product cert remains installed
rhelInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductId, currentlyInstalledProducts);
Assert.assertNotNull(rhelInstalledProduct, "After removing jboss package '" + jbossPackage + "' while disabling rhel repo '" + rhelRepo + "', the rhel product id '" + rhelProductId + "' remains installed (because there are many other rhel packages from rhel repo '" + rhelRepo + "' still installed).");
// remove the rhel package
clienttasks.yumRemovePackage(rhelPackage);
// verify that the jboss product cert remains uninstalled
currentlyInstalledProducts = clienttasks.getCurrentlyInstalledProducts();
jbossInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", jbossProductId, currentlyInstalledProducts);
Assert.assertNull(jbossInstalledProduct, "After removing rhel package '" + rhelPackage + "', the jboss product id '" + jbossProductId + "' from enabled repo '" + jbossRepo + "' remains uninstalled.");
// verify that the rhel product cert remains installed
rhelInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductId, currentlyInstalledProducts);
Assert.assertNotNull(rhelInstalledProduct, "After removing rhel package '" + rhelPackage + "' the rhel product id '" + rhelProductId + "' remains installed (because there are many other rhel packages from rhel repo '" + rhelRepo + "' still installed).");
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class CertificateTests method testBaseRHELProductCertArchAndTags.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20037", "RHEL7-51046" }, // TODO should be a list of ["redhat-release-server","redhat-release-client","redhat-release-workstation","redhat-release-computenode"]
level = DefTypes.Level.COMPONENT, // TODO should be a list of ["redhat-release-server","redhat-release-client","redhat-release-workstation","redhat-release-computenode"]
component = "redhat-release-server", 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 = "Verify that the installed base RHEL product cert provides the expected tags", groups = { "Tier1Tests", "blockedByBug-1259820", "blockedByBug-1259839" }, dependsOnMethods = { "testBaseRHELProductCertIsInstalled" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testBaseRHELProductCertArchAndTags() {
ProductCert productCert = clienttasks.getCurrentRhelProductCert();
List<String> providedTags = Arrays.asList(productCert.productNamespace.providedTags.split("\\s*,\\s*"));
List<String> expectedTags = Arrays.asList("FIXME");
// assert the product cert arch matches the system
String system_arch = clienttasks.arch;
if (Arrays.asList("i386", "i486", "i586", "i686").contains(clienttasks.arch)) {
// Note: x86 is a general arch to cover all 32-bit intel microprocessors
system_arch = "i386";
}
Assert.assertEquals(productCert.productNamespace.arch, system_arch, "Current RHEL product cert arch.");
// http://git.app.eng.bos.redhat.com/git/rcm/rcm-metadata.git/tree/product_ids
switch(Integer.valueOf(productCert.productId)) {
case // Red Hat Enterprise Linux Desktop
68:
expectedTags = Arrays.asList("rhel-#,rhel-#-client".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux Server
69:
expectedTags = Arrays.asList("rhel-#,rhel-#-server".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux Workstation
71:
expectedTags = Arrays.asList("rhel-#,rhel-#-workstation".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux for IBM z Systems
72:
expectedTags = Arrays.asList("rhel-#,rhel-#-ibm-system-z".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux for IBM POWER
74:
expectedTags = Arrays.asList("rhel-#,rhel-#-ibm-power".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux for Scientific Computing
76:
expectedTags = Arrays.asList("rhel-#,rhel-#-computenode".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux for IBM POWER LE
279:
expectedTags = Arrays.asList("rhel-#,rhel-#-ibm-power-le".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux Server for ARM
294:
expectedTags = Arrays.asList("rhel-#,rhel-#-arm".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux for ARM 64
419:
expectedTags = Arrays.asList("rhel-#,rhel-alt-#,rhel-alt-#-armv8-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
// ADD WORKAROUND FOR Bug 1518886 - RHEL-ALT-7.5 product certs should also provide tag "rhel-7"
// UPDATE: BUG 1518886 was CLOSED WONTFIX in favor of the fix from Bug 1510024 which now recognizes rhel-alt-# as a RHEL product
expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-armv8-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux for Power 9
420:
expectedTags = Arrays.asList("rhel-#,rhel-alt-#,rhel-alt-#-power9".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
// ADD WORKAROUND FOR Bug 1518886 - RHEL-ALT-7.5 product certs should also provide tag "rhel-7"
// UPDATE: BUG 1518886 was CLOSED WONTFIX in favor of the fix from Bug 1510024 which now recognizes rhel-alt-# as a RHEL product
expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-power9".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux for IBM System z (Structure A)
434:
expectedTags = Arrays.asList("rhel-#,rhel-alt-#,rhel-alt-#-system-z-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
// ADD WORKAROUND FOR Bug 1518886 - RHEL-ALT-7.5 product certs should also provide tag "rhel-7"
// UPDATE: BUG 1518886 was CLOSED WONTFIX in favor of the fix from Bug 1510024 which now recognizes rhel-alt-# as a RHEL product
expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-system-z-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux for ARM 64 Beta
363:
expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-armv8-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux for Power 9 Beta
362:
expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-power9".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux for IBM System z (Structure A) Beta
433:
expectedTags = Arrays.asList("rhel-alt-#,rhel-alt-#-system-z-a".replaceAll("#", clienttasks.redhatReleaseX).split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux 6 Server HTB
135:
expectedTags = Arrays.asList("rhel-6-server-htb,rhel-6-server".split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux 6 Workstation HTB
155:
expectedTags = Arrays.asList("rhel-6-workstation-htb,rhel-6-workstation".split("\\s*,\\s*"));
break;
case // Red Hat Enterprise Linux 7 Server High Touch Beta
230:
expectedTags = Arrays.asList("rhel-7-htb,rhel-7-server".split("\\s*,\\s*"));
// TEMPORARY WORKAROUND
if (!providedTags.containsAll(expectedTags)) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1538957 - product-default .pem files do not contain expected data
String bugId = "1538957";
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
throw new SkipException("Skipping this test when product '" + productCert.productName + "' is installed while blocking bug '" + bugId + "' is open.");
}
}
// END OF WORKAROUND
break;
case // Red Hat Enterprise Linux 7 Workstation High Touch Beta
231:
expectedTags = Arrays.asList("rhel-7-htb,rhel-7-workstation".split("\\s*,\\s*"));
// TEMPORARY WORKAROUND
if (!providedTags.containsAll(expectedTags)) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1538957 - product-default .pem files do not contain expected data
String bugId = "1538957";
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
throw new SkipException("Skipping this test when product '" + productCert.productName + "' is installed while blocking bug '" + bugId + "' is open.");
}
}
// END OF WORKAROUND
break;
default:
Assert.fail("Unknown productCert id '" + productCert.productId + "'");
break;
}
// assert the product cert provides all the expected tags
for (String expectedTag : expectedTags) {
Assert.assertTrue(providedTags.contains(expectedTag), "Actuals RHEL Product Cert tags " + providedTags + " contain expected tag '" + expectedTag + "' for RHEL '" + clienttasks.redhatReleaseX + "' product id '" + productCert.productNamespace.id + "'");
}
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class CertificateTests method testConsumerCertsAreNotAccessibleByNonRootUserUsingRct.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-36641", "RHEL7-51452" }, 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 rct cat-cert tool does not traceback when run as non-root user.", groups = { "Tier2Tests", "blockedByBug-1315901", "VerifyConsumerCertsAreNotAccessibleByNonRootUserUsingRct_Test", "blockedByBug-1503851" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testConsumerCertsAreNotAccessibleByNonRootUserUsingRct() {
if (clienttasks.isPackageVersion("python-rhsm", "<", "1.17.6-1")) {
// python-rhsm RHEL7.3 branch commit d21c8252b4bdcf2b57f316ecc604487a3ef6e2c2 1315901: Exception handling for PEM cert read
throw new SkipException("This test is not fixed in this version of python-rhsm. It was first fixed in python-rhsm-1.17.6-1");
}
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, null, null, null, null, null);
ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
// create a non root user
// as a precaution
deleteNonRootUser();
RemoteFileTasks.runCommandAndAssert(client, "useradd " + nonRootUser, 0);
// Before fix to Bug 1315901 - Stacktrace displayed when running rct against an inaccessible file
// [root@jsefler-6 ~]# su non-root-user --command "rct cat-cert /etc/pki/consumer/cert.pem"
// Traceback (most recent call last):
// File "/usr/bin/rct", line 49, in <module>
// sys.exit(abs(main() or 0))
// File "/usr/bin/rct", line 44, in main
// return RctCLI().main()
// File "/usr/share/rhsm/subscription_manager/cli.py", line 160, in main
// return cmd.main()
// File "/usr/share/rhsm/rct/commands.py", line 39, in main
// return_code = self._do_command()
// File "/usr/share/rhsm/rct/cert_commands.py", line 74, in _do_command
// cert = self._create_cert()
// File "/usr/share/rhsm/rct/cert_commands.py", line 43, in _create_cert
// return certificate.create_from_file(cert_file)
// File "/usr/lib64/python2.6/site-packages/rhsm/certificate.py", line 59, in create_from_file
// return _CertFactory().create_from_file(path)
// File "/usr/lib64/python2.6/site-packages/rhsm/certificate2.py", line 65, in create_from_file
// pem = open(path, 'r').read()
// IOError: [Errno 13] Permission denied: '/etc/pki/consumer/cert.pem'
// After fix to Bug 1315901 - Stacktrace displayed when running rct against an inaccessible file
// [root@jsefler-rhel7 ~]# su non-root-user --command 'rct cat-cert /etc/pki/consumer/cert.pem'
// Permission denied
String expectedStdout = "Permission denied";
Integer expectedExitCode = Integer.valueOf(1);
// Unable to read certificate file '/etc/pki/consumer/cert.pem': Error loading certificate: [Errno 13] Permission denied: '/etc/pki/consumer/cert.pem'
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.1-1")) {
// post commit f192653c46808239c2f193478c1dfeb55a6ee35c //Bug 1472715: Python module rhsm should never call exit()
expectedStdout = String.format("Unable to read certificate file '%s': Error loading certificate: [Errno 13] Permission denied: '%s'", consumerCert.file.getPath(), consumerCert.file.getPath());
expectedExitCode = Integer.valueOf(0);
}
// attempt to run command "rct cat-cert /etc/pki/consumer/cert.pem" as non-root-user
String command = "rct cat-cert " + consumerCert.file.getPath();
SSHCommandResult result = client.runCommandAndWait("su " + nonRootUser + " --command '" + command + "'");
// assert expected results
Assert.assertEquals(result.getExitCode(), expectedExitCode, "ExitCode from command '" + command + "' run as a non-root user.");
Assert.assertEquals(result.getStdout().trim(), expectedStdout, "Stdout from command '" + command + "' run as a non-root user.");
Assert.assertTrue(!result.getStderr().toLowerCase().contains("Traceback".toLowerCase()), "Stderr from command '" + command + "' run as a non-root user does not contain a traceback.");
// TEMPORARY WORKAROUND
if (clienttasks.redhatReleaseX.equals("6")) {
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1562412 - a DEBUG logging statement surfaces to stderr when trying to rct cat-cert a protected file as a non-root-user
String bugId = "1562412";
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
log.warning("While bug '" + bugId + "' is open, we will skip the empty stderr assertion on RHEL6");
return;
}
}
// END OF WORKAROUND
Assert.assertEquals(result.getStderr().trim(), "", "Stderr from command '" + command + "' run as a non-root user.");
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class ComplianceTests method configureProductCertDirForAllProductsSubscribableByOneCommonServiceLevel.
@BeforeGroups(groups = { "setup" }, value = "configureProductCertDirForAllProductsSubscribableByOneCommonServiceLevel")
public void configureProductCertDirForAllProductsSubscribableByOneCommonServiceLevel() {
clienttasks.unregister(null, null, null, null);
// TEMPORARY WORKAROUND FOR BUG: Bug 1183175 - changing to a different rhsm.productcertdir configuration throws OSError: [Errno 17] File exists
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "1183175";
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
throw new SkipException("Cannot configure a different productCertDir while bug '" + bugId + "' is open.");
}
// END OF WORKAROUND
clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", productCertDirForAllProductsSubscribableByOneCommonServiceLevel);
SSHCommandResult r = client.runCommandAndWait("ls -1 " + productCertDirForAllProductsSubscribableByOneCommonServiceLevel + " | wc -l");
if (Integer.valueOf(r.getStdout().trim()) == 0)
throw new SkipException("Could not find any installed product certs that are autosubscribable via one common service level.");
Assert.assertTrue(Integer.valueOf(r.getStdout().trim()) > 0, "The " + clienttasks.rhsmConfFile + " file is currently configured with a productCertDir that contains all autosubscribable products via one common service level.");
configureProductCertDirForAllProductsSubscribableByOneCommonServiceLevelCompleted = true;
}
use of com.redhat.qe.auto.bugzilla.BugzillaAPIException in project rhsm-qe by RedHatQE.
the class ConfigTests method testSubscriptionManagerShouldAutomaticallyEnableYumPluginsWhenAutoEnableIsOn.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-47939", "RHEL7-99807" }, linkedWorkItems = { // role= DefTypes.Role.VERIFIES),
@LinkedItem(// RHEL7-95149 - RHSM-REQ : subscription-manager should automatically enable yum plugins
workitemId = "RHEL7-95149", project = Project.RedHatEnterpriseLinux7, role = DefTypes.Role.VERIFIES) }, 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 = "Tier3")
@Test(description = "Verify that the yum plugins for /etc/yum/pluginconf.d/product-id.conf and /etc/yum/pluginconf.d/subscription-manager.conf are automatically enabled by various subscription-manager module commands when rhsm.auto_enable_yum_plugins is configured on.", groups = { "Tier3Tests", "blockedByBug-1319927", "testSubscriptionManagerShouldAutomaticallyEnableYumPluginsWhenAutoEnableIsOn" }, dataProvider = "getVariousModuleCommandsData", priority = 100, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSubscriptionManagerShouldAutomaticallyEnableYumPluginsWhenAutoEnableIsOn(Object blockedByBug, String moduleCommand, Boolean moduleCommandRequiresRegistration) throws IOException {
resetDefaultConfigurationsForYumPluginsAndRhsmAutoEnableYumPlugins();
// decide to register with a random auto-attach option
if (moduleCommandRequiresRegistration) {
clienttasks.unregister(null, null, null, null);
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, getRandomBoolean(), null, null, (String) null, null, null, null, null, false, null, null, null, null);
}
// randomly disable one or both /etc/yum/pluginconf.d/product-id.conf and /etc/yum/pluginconf.d/subscription-manager.conf
if (getRandomBoolean()) {
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled", "0");
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled", String.valueOf(getRandInt() % 2));
} else {
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled", "false");
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled", "true");
// TEMPORARY WORKAROUND
boolean invokeWorkaroundWhileBugIsOpen = true;
// Bug 1489917 - disabling yum plugins using "false" (rather than "0") causes traceback: invalid literal for int() with base 10: 'false'
String bugId = "1489917";
try {
if (invokeWorkaroundWhileBugIsOpen && BzChecker.getInstance().isBugOpen(bugId)) {
log.fine("Invoking workaround for " + BzChecker.getInstance().getBugState(bugId).toString() + " Bugzilla " + bugId + ". (https://bugzilla.redhat.com/show_bug.cgi?id=" + bugId + ")");
SubscriptionManagerCLITestScript.addInvokedWorkaround(bugId);
} else {
invokeWorkaroundWhileBugIsOpen = false;
}
} catch (BugzillaAPIException be) {
/* ignore exception */
} catch (RuntimeException re) {
/* ignore exception */
}
if (invokeWorkaroundWhileBugIsOpen) {
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled", "0");
clienttasks.updateConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled", "1");
}
// END OF WORKAROUND
}
String yumPluginConfFileForProductIdEnabledString = clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled");
String yumPluginConfFileForSubscriptionManagerEnabledString = clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled");
Boolean yumPluginConfFileForProductIdEnabled = Boolean.valueOf(yumPluginConfFileForProductIdEnabledString);
Boolean yumPluginConfFileForSubscriptionManagerEnabled = Boolean.valueOf(yumPluginConfFileForSubscriptionManagerEnabledString);
if (yumPluginConfFileForProductIdEnabledString.equals("1")) {
yumPluginConfFileForProductIdEnabled = true;
} else if (yumPluginConfFileForProductIdEnabledString.equals("0")) {
yumPluginConfFileForProductIdEnabled = false;
}
if (yumPluginConfFileForSubscriptionManagerEnabledString.equals("1")) {
yumPluginConfFileForSubscriptionManagerEnabled = true;
} else if (yumPluginConfFileForSubscriptionManagerEnabledString.equals("0")) {
yumPluginConfFileForSubscriptionManagerEnabled = false;
}
// run a subscription-manager moduleCommand
SSHCommandResult results = client.runCommandAndWait(moduleCommand);
// assert the results contain the expected WARNING message
String expectedWarningMsg = "WARNING" + "\n\n" + "The yum plugins: PLUGINS were automatically enabled for the benefit of Red Hat Subscription Management. If not desired, use \"subscription-manager config --rhsm.auto_enable_yum_plugins=0\" to block this behavior.";
if (!yumPluginConfFileForSubscriptionManagerEnabled)
expectedWarningMsg = expectedWarningMsg.replaceFirst("PLUGINS", clienttasks.yumPluginConfFileForSubscriptionManager + ", PLUGINS");
if (!yumPluginConfFileForProductIdEnabled)
expectedWarningMsg = expectedWarningMsg.replaceFirst("PLUGINS", clienttasks.yumPluginConfFileForProductId + ", PLUGINS");
// strip out my regex substring
expectedWarningMsg = expectedWarningMsg.replaceFirst(", PLUGINS", "");
Assert.assertTrue(results.getStdout().contains(expectedWarningMsg), "The stdout from running '" + moduleCommand + "' contains the expected warning message '" + expectedWarningMsg + "' when at least one yum plugin is disabled and rhsm.auto_enable_yum_plugins is configured on.");
// assert that both plugins were enabled
String enabledValue;
enabledValue = clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForProductId, "enabled");
Assert.assertTrue(enabledValue.toLowerCase().matches("1|true"), "Expecting yum config file '" + clienttasks.yumPluginConfFileForProductId + "' to be enabled after running '" + moduleCommand + "' with rhsm.auto_enable_yum_plugins configured on. Actual enabled=" + enabledValue);
enabledValue = clienttasks.getConfFileParameter(clienttasks.yumPluginConfFileForSubscriptionManager, "enabled");
Assert.assertTrue(enabledValue.toLowerCase().matches("1|true"), "Expecting yum config file '" + clienttasks.yumPluginConfFileForSubscriptionManager + "' to be enabled after running '" + moduleCommand + "' with rhsm.auto_enable_yum_plugins configured on. Actual enabled=" + enabledValue);
// run the subscription-manager module again
results = client.runCommandAndWait(moduleCommand);
// assert that the results do NOT contain the WARNING message
// WARNING
expectedWarningMsg = expectedWarningMsg.replaceFirst("\n\n.*", "");
Assert.assertTrue(!results.getStdout().contains(expectedWarningMsg), "The stdout from a second run of '" + moduleCommand + "' NO LONGER contains message '" + expectedWarningMsg + "' because rhsm.auto_enable_yum_plugins is configured on.");
}
Aggregations