use of rhsm.data.ConsumerCert in project rhsm-qe by RedHatQE.
the class BugzillaTests method testFunctionalityAccessAfterUnregister.
/**
* @author skallesh
* @throws Exception
* @throws JSONException
*/
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21952", "RHEL7-51814" }, 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 Functionality Access After Unregister", groups = { "Tier3Tests", "VerifyFunctionalityAccessAfterUnregister" }, enabled = true)
@ImplementsNitrateTest(caseId = 50215)
public void testFunctionalityAccessAfterUnregister() throws JSONException, Exception {
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg);
String availList = clienttasks.listAllAvailableSubscriptionPools().getStdout();
Assert.assertNotNull(availList);
clienttasks.unregister(null, null, null, null);
SSHCommandResult listResult = clienttasks.list_(true, true, null, null, null, null, null, null, null, null, null, null, null, null);
String expected = "This system is not yet registered. Try 'subscription-manager register --help' for more information.";
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1")) {
// post
// commit
// df95529a5edd0be456b3528b74344be283c4d258
Assert.assertEquals(listResult.getStderr().trim(), expected, "stderr");
} else {
Assert.assertEquals(listResult.getStdout().trim(), expected, "stdout");
}
ConsumerCert consumercert = clienttasks.getCurrentConsumerCert();
Assert.assertNull(consumercert);
}
use of rhsm.data.ConsumerCert in project rhsm-qe by RedHatQE.
the class EventTests method testEnititlementDeleted.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21844", "RHEL7-51665" }, 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 = "subscription-manager: events: Entitlement Deleted is sent over an RSS atom feed.", groups = { "Tier3Tests", "EnititlementDeleted_Test" }, dependsOnGroups = { "PoolModifiedAndEntitlementModified_Test" }, enabled = true, alwaysRun = true)
public // @ImplementsTCMS(id="")
void testEnititlementDeleted() throws Exception {
if (sm_serverAdminUsername.equals("") || sm_serverAdminPassword.equals(""))
throw new SkipException("This test requires the candlepin server admin username and password credentials.");
// get the owner and consumer feeds before we test the firing of a new event
ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
String ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerCert.consumerid);
SyndFeed oldFeed = CandlepinTasks.getSyndFeed(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
SyndFeed oldOwnerFeed = CandlepinTasks.getSyndFeedForOwner(ownerKey, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
SyndFeed oldConsumerFeed = CandlepinTasks.getSyndFeedForConsumer(/*ownerKey,*/
consumerCert.consumerid, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
// fire an unsubscribe event
clienttasks.unsubscribeFromAllOfTheCurrentlyConsumedProductSubscriptions();
String[] newEventTitles = new String[] { "ENTITLEMENT DELETED" };
// COMPLIANCE CREATED events were added to support gutterball
newEventTitles = new String[] { "COMPLIANCE CREATED", "COMPLIANCE CREATED", "ENTITLEMENT DELETED" };
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "0.9.37-1")) {
// commit bb1d2e6184a6cd9b80ff9c9d3045e9d780116226 // Only send Compliance event when compliance changes
newEventTitles = new String[] { "COMPLIANCE CREATED", "ENTITLEMENT DELETED" };
}
// TODO FIXME 7/21/2016 assertTheNewConsumerFeedIgnoringEventTitles() call below started failing because the actual newEventTitles occur in reverse order from expected
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.0.16-1")) {
// probably candlepin commit 6beae873733174df24178a552b116fcb8c8876ef Dont trigger async compliance during batch revoke
// attempting to reversing the order
// if this does not help, then we might try to alter the assertTheNew*() methods to IgnoreOrder of just call the assertTheNew**Contains() methods ..
// switched the expected order; after discussions with vritant and crog who said the order of the expected new event titles may not be a guaranteed and apparently that's okay
newEventTitles = new String[] { "ENTITLEMENT DELETED", "COMPLIANCE CREATED" };
}
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.1.1-1")) {
// commit 1ad3fd6f338d9bbcedc8eba8361d4bc6c807f84d 1474443 compliance.created events now use UUID for 'consumerId' field
newEventTitles = new String[] { "ENTITLEMENT DELETED" };
}
// TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=721136 - jsefler 07/14/2011
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "721136";
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) {
newEventTitles = new String[] { clienttasks.hostname + " returned the subscription for " + testPool.subscriptionName };
}
// END OF WORKAROUND
// assert the consumer feed...
// assertTheNewConsumerFeed(ownerKey, consumerCert.consumerid, oldConsumerFeed, newEventTitles);
assertTheNewConsumerFeedIgnoringEventTitles(ownerKey, consumerCert.consumerid, oldConsumerFeed, newEventTitles, new HashSet<String>() {
{
add("COMPLIANCE CREATED");
}
});
// adjust the expected events when the candlepin server is standalone and the pool has a non-zero virt_limit
String virt_limit = CandlepinTasks.getPoolProductAttributeValue(sm_clientUsername, sm_clientPassword, sm_serverUrl, testPool.poolId, "virt_limit");
if (// DO NOT INTERFERE WITH THE "switched the expected order" FROM ABOVE
SubscriptionManagerTasks.isVersion(servertasks.statusVersion, "<", "2.0.16-1"))
if (servertasks.statusStandalone && virt_limit != null && !virt_limit.equals("0")) {
newEventTitles = new String[] { "COMPLIANCE CREATED", "ENTITLEMENT DELETED" };
}
// assert the owner feed...
// assertTheNewOwnerFeed(ownerKey, oldOwnerFeed, newEventTitles);
assertTheNewOwnerFeedIgnoringEventTitles(ownerKey, oldOwnerFeed, newEventTitles, new HashSet<String>() {
{
add("COMPLIANCE CREATED");
}
});
// assert the feed...
// assertTheNewFeed(oldFeed, newEventTitles);
assertTheNewFeedIgnoringEventTitles(oldFeed, newEventTitles, new HashSet<String>() {
{
add("COMPLIANCE CREATED");
}
});
}
use of rhsm.data.ConsumerCert in project rhsm-qe by RedHatQE.
the class EventTests method testConsumerCreated.
// Test methods ***********************************************************************
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21840", "RHEL7-51661" }, 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 = "subscription-manager: events: Consumer Created is sent over an RSS atom feed.", groups = { "Tier3Tests", "ConsumerCreated_Test" }, dependsOnGroups = {}, enabled = true)
public // @ImplementsTCMS(id="")
void testConsumerCreated() throws Exception {
if (sm_serverAdminUsername.equals("") || sm_serverAdminPassword.equals(""))
throw new SkipException("This test requires the candlepin server admin username and password credentials.");
// start fresh by unregistering
clienttasks.unregister(null, null, null, null);
// get the owner and consumer feeds before we test the firing of a new event
String ownerKey = sm_clientOrg;
SyndFeed oldFeed = CandlepinTasks.getSyndFeed(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
SyndFeed oldOwnerFeed = CandlepinTasks.getSyndFeedForOwner(ownerKey, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
// fire a register event
clienttasks.register(sm_clientUsername, sm_clientPassword, ownerKey, null, null, null, null, null, null, null, (String) null, null, null, null, null, null, null, null, null, null);
String[] newEventTitles = new String[] { "CONSUMER CREATED" };
// COMPLIANCE CREATED events were added to support gutterball
newEventTitles = new String[] { "COMPLIANCE CREATED", "COMPLIANCE CREATED", "CONSUMER CREATED" };
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "0.9.37-1")) {
// commit bb1d2e6184a6cd9b80ff9c9d3045e9d780116226 // Only send Compliance event when compliance changes
newEventTitles = new String[] { "COMPLIANCE CREATED", "CONSUMER CREATED" };
}
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "2.1.1-1")) {
// commit 1ad3fd6f338d9bbcedc8eba8361d4bc6c807f84d 1474443 compliance.created events now use UUID for 'consumerId' field
newEventTitles = new String[] { "CONSUMER CREATED" };
}
// TEMPORARY WORKAROUND FOR BUG: https://bugzilla.redhat.com/show_bug.cgi?id=721136 - jsefler 07/14/2011
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "721136";
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) {
newEventTitles = new String[] { sm_clientUsername + " created new consumer " + clienttasks.hostname };
}
// END OF WORKAROUND
ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
// assert the consumer feed...
// assertTheNewConsumerFeed(ownerKey, consumerCert.consumerid, null, newEventTitles);
assertTheNewConsumerFeedIgnoringEventTitles(ownerKey, consumerCert.consumerid, null, newEventTitles, new HashSet<String>() {
{
add("COMPLIANCE CREATED");
}
});
// assert the owner feed...
// assertTheNewOwnerFeed(ownerKey, oldOwnerFeed, newEventTitles);
assertTheNewOwnerFeedIgnoringEventTitles(ownerKey, oldOwnerFeed, newEventTitles, new HashSet<String>() {
{
add("COMPLIANCE CREATED");
}
});
// assert the feed...
// assertTheNewFeed(oldFeed, newEventTitles);
assertTheNewFeedIgnoringEventTitles(oldFeed, newEventTitles, new HashSet<String>() {
{
add("COMPLIANCE CREATED");
}
});
}
use of rhsm.data.ConsumerCert in project rhsm-qe by RedHatQE.
the class EventTests method testConsumerDeleted.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-21846", "RHEL7-51667" }, 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 = "subscription-manager: events: Consumer Deleted is sent over an RSS atom feed.", groups = { "Tier3Tests", "ConsumerDeleted_Test" }, dependsOnGroups = { "ConsumerModified_Test", "NegativeConsumerUserPassword_Test" }, enabled = true)
public // @ImplementsTCMS(id="")
void testConsumerDeleted() throws Exception {
// get the owner and consumer feeds before we test the firing of a new event
ConsumerCert consumerCert = clienttasks.getCurrentConsumerCert();
String ownerKey = CandlepinTasks.getOwnerKeyOfConsumerId(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl, consumerCert.consumerid);
SyndFeed oldFeed = CandlepinTasks.getSyndFeed(sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
SyndFeed oldOwnerFeed = CandlepinTasks.getSyndFeedForOwner(ownerKey, sm_serverAdminUsername, sm_serverAdminPassword, sm_serverUrl);
// fire an unregister event
clienttasks.unregister(null, null, null, null);
String[] newEventTitles = new String[] { "CONSUMER DELETED" };
// COMPLIANCE CREATED events were added to support gutterball
newEventTitles = new String[] { "COMPLIANCE CREATED", "CONSUMER DELETED" };
if (SubscriptionManagerTasks.isVersion(servertasks.statusVersion, ">=", "0.9.37-1")) {
// commit bb1d2e6184a6cd9b80ff9c9d3045e9d780116226 // Only send Compliance event when compliance changes
newEventTitles = new String[] { "CONSUMER DELETED" };
}
// assert the owner feed...
assertTheNewOwnerFeed(ownerKey, oldOwnerFeed, newEventTitles);
// assertTheNewOwnerFeedIgnoringEventTitles(ownerKey, oldOwnerFeed, newEventTitles, new HashSet<String>(){{add("COMPLIANCE CREATED");}});
// assert the feed...
assertTheNewFeed(oldFeed, newEventTitles);
// assertTheNewFeedIgnoringEventTitles(oldFeed, newEventTitles, new HashSet<String>(){{add("COMPLIANCE CREATED");}});
}
use of rhsm.data.ConsumerCert 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.");
}
Aggregations