use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class ReleaseTests method testSetAnUnavailableReleaseValue.
@// update=true // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19999", "RHEL7-51032" }, level = DefTypes.Level.COMPONENT, component = "subscription-manager", testtype = @TestType(testtype = DefTypes.TestTypes.FUNCTIONAL, subtype1 = DefTypes.Subtypes.RELIABILITY, subtype2 = DefTypes.Subtypes.EMPTY), posneg = PosNeg.NEGATIVE, importance = DefTypes.Importance.HIGH, automation = DefTypes.Automation.AUTOMATED, tags = "Tier1")
@Test(description = "attempt to set the subscription-manager release value that is not currently available", groups = { "Tier1Tests", "blockedByBug-818205", "blockedByBug-919700" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSetAnUnavailableReleaseValue() {
// make sure we are newly registered
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (List<String>) null, null, null, null, true, null, null, null, null, null);
// assert feedback from release --list
String unavailableRelease = "Foo_1.0";
SSHCommandResult result = clienttasks.release_(null, null, unavailableRelease, null, null, null, null, null);
Integer expectedExitCode = new Integer(255);
String rhelTag = "rhel-" + clienttasks.redhatReleaseX;
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.10-1")) {
// commit 76273403e6e3f7fa9811ef252a5a7ce4d84f7aa3 // bug 1510024: Handle rhel-alt product tags properly
rhelTag = "rhel-" + clienttasks.redhatReleaseX + "|" + "rhel-alt-" + clienttasks.redhatReleaseX;
}
List<ProductCert> productCertsProvidingRhelTag = clienttasks.getCurrentProductCerts(rhelTag);
productCertsProvidingRhelTag = clienttasks.filterTrumpedDefaultProductCerts(productCertsProvidingRhelTag);
if (productCertsProvidingRhelTag.size() > 1) {
// Bug 1506271 - redhat-release is providing more than 1 variant specific product cert
log.warning("Installed product cert providing rhel tag '" + rhelTag + "': " + productCertsProvidingRhelTag);
// EX_CONFIG // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
expectedExitCode = new Integer(78);
Assert.assertEquals(result.getStdout().trim(), "", "stdout from --set with an unavailable value when more than one product cert with tag '" + rhelTag + "' is installed.");
String expectedStderr = "Error: More than one release product certificate installed.";
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.20.8-1")) {
// commit 286b4fcdc8dba6e75a7b50e5db912a99c8f7ada2 // bug 1464571: 'sub-man release' prints error for more prod. certs.
Assert.assertTrue(result.getStderr().trim().startsWith(expectedStderr), "stderr from release --set with an unavailable value when more than one product cert with tag '" + rhelTag + "' is installed should be '" + expectedStderr + "'.");
} else {
Assert.assertEquals(result.getStderr().trim(), expectedStderr, "stderr from release --set with an unavailable value when more than one product cert with tag '" + rhelTag + "' is installed should be '" + expectedStderr + "'.");
}
} else {
// EX_DATAERR // post commit df95529a5edd0be456b3528b74344be283c4d258 bug 1119688
if (clienttasks.isPackageVersion("subscription-manager", ">=", "1.13.8-1"))
expectedExitCode = new Integer(65);
Assert.assertEquals(result.getStdout().trim(), "", "stdout from release --set with an unavailable value");
Assert.assertEquals(result.getStderr().trim(), String.format("No releases match '%s'. Consult 'release --list' for a full listing.", unavailableRelease), "stderr from release --set with an unavailable value");
}
Assert.assertEquals(result.getExitCode(), expectedExitCode, "exitCode from release --set with an unavailable value");
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class ReleaseTests method testReleaseListExcludes56OnRHEL5System.
@TestDefinition(projectID = {/*Project.RHEL5*/
}, testCaseID = {})
@Test(description = "register to a RHEL subscription and verify that release --list excludes 5.6, 5.5, 5.4, 5.3, 5.2, 5.1, 5.0", groups = { "Tier1Tests", "blockedByBug-785989", /*,"blockedByBug-840509" MOVED TO TEMPORARY WORKAROUND*/
"blockedByBug-919700" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testReleaseListExcludes56OnRHEL5System() throws JSONException, Exception {
if (!clienttasks.redhatReleaseX.equals("5"))
throw new SkipException("This test is only applicable on RHEL5.");
// TEMPORARY WORKAROUND
boolean invokeWorkaroundWhileBugIsOpen = true;
String bugId = "840509";
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("blockedByBug-840509");
}
// END OF WORKAROUND
// make sure we are newly registered with autosubscribe
clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (List<String>) null, null, null, null, true, null, null, null, null, null);
// get the current base RHEL product cert
String providingTag = "rhel-" + clienttasks.redhatReleaseX;
List<ProductCert> rhelProductCerts = clienttasks.getCurrentProductCerts(providingTag);
// TODO: Don't know how to predict which one since I believe Workstation is really born after consuming a child channel of Client rather than a base channel; for now let's just assume the other
if (clienttasks.releasever.equals("5Client") && rhelProductCerts.isEmpty()) {
providingTag += "-workstation";
rhelProductCerts = clienttasks.getCurrentProductCerts(providingTag);
}
Assert.assertEquals(rhelProductCerts.size(), 1, "Only one product cert is installed that provides RHEL tag '" + providingTag + "'");
ProductCert rhelProductCert = rhelProductCerts.get(0);
// assert that it was autosubscribed
InstalledProduct rhelInstalledProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("productId", rhelProductCert.productId, clienttasks.getCurrentlyInstalledProducts());
Assert.assertNotNull(rhelInstalledProduct, "Our base installed RHEL product was autosubscribed during registration.");
// get the actual release listing
List<String> actualReleases = clienttasks.getCurrentlyAvailableReleases(null, null, null, null);
// assert that the list excludes 5.6, 5.5, 5.4, 5.3, 5.2, 5.1, 5.0, but includes the current X.Y release
for (String release : new String[] { "5.6", "5.5", "5.4", "5.3", "5.2", "5.1", "5.0" }) {
Assert.assertTrue(!actualReleases.contains(release), "The subscription-manager releases list should exclude '" + release + "' since '" + clienttasks.command + "' did not exist in RHEL Release '" + release + "'.");
}
// NOT PRACTICAL SINCE CONTENT FROM THIS Y-STREAM MAY NOT BE AVAILABLE UNTIL GA Assert.assertTrue(actualReleases.contains(clienttasks.redhatReleaseXY), "The subscription-manager releases list should include '"+clienttasks.redhatReleaseXY+"' since it is the current RHEL Release under test.");
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class ReposTests method testYumTransactionsAreNoLongerRequiredToTriggerUpdatesToRedhatRepo.
@// update=true, // uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-19973", "RHEL7-51012" }, 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 = "Verify that the redhat.repo file is refreshed with changes to the entitlements (yum transactions are no longer required to update the redhat.repo)", // TODO: review all tests and tasks that issue yum transactions simply to re-populate the redhat.repo
groups = { "Tier1Tests", "blockedByBug-1008016", "blockedByBug-1090206", "blockedByBug-1034429" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumTransactionsAreNoLongerRequiredToTriggerUpdatesToRedhatRepo() {
// register
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);
// shut off auto-healing
clienttasks.autoheal(null, null, true, null, null, null, null);
List<ProductCert> productCerts = clienttasks.getCurrentProductCerts();
// Subscribe to a randomly available pool...
log.info("Subscribe to a randomly available pool...");
List<SubscriptionPool> pools = clienttasks.getCurrentlyAllAvailableSubscriptionPools();
if (pools.size() <= 0)
throw new SkipException("No susbcriptions were available which blocks this test from executing.");
// randomly pick a pool
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size()));
// testing the subscribe case...
clienttasks.subscribe_(null, null, pool.poolId, null, null, null, null, null, null, null, null, null, null);
log.info("Immediately after attaching a subscription, we will now assert that all of the content repos from the currently attached entitlements are currently present in the redhat.repo without having triggered a yum transaction...");
verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos(productCerts);
// testing the unsubscribe case...
clienttasks.unsubscribe_(true, (BigInteger) null, null, null, null, null, null);
log.info("Immediately after removing a subscription, we will now assert that the redhat.repo is empty without having triggered a yum transaction...");
verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos(productCerts);
// testing the autosubscribe case...
clienttasks.subscribe_(true, null, (String) null, null, null, null, null, null, null, null, null, null, null);
log.info("Immediately after autoattaching subscription(s), we will now assert that all of the content repos from the currently attached entitlements are currently present in the redhat.repo without having triggered a yum transaction...");
verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos(productCerts);
// testing the unregister case...
clienttasks.unregister_(null, null, null, null);
log.info("Immediately after unregistering, we will now assert that the redhat.repo is empty without having triggered a yum transaction...");
verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos(productCerts);
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class RegisterTests method testRegisterWithAutosubscribe_DEPRECATED_2.
@Test(description = "subscription-manager-cli: register to a Candlepin server using autosubscribe functionality", groups = { "Tier1Tests", "RegisterWithAutosubscribe_Test", "blockedByBug-602378", "blockedByBug-616137", "blockedByBug-678049", "blockedByBug-737762", "blockedByBug-743082" }, enabled = false)
@Deprecated
public void testRegisterWithAutosubscribe_DEPRECATED_2() throws JSONException, Exception {
log.info("RegisterWithAutosubscribe_Test Strategy:");
log.info(" 1. Change the rhsm.conf configuration for productCertDir to point to a new temporary product cert directory.");
log.info(" 2. Register with autosubscribe and assert that no product binding has occurred.");
log.info(" 3. Using the candlepin REST API, we will find an available pool that provides a product that we have installed.");
log.info(" 4. Copy the installed product to a temporary product cert directory so that we can isolate the expected product that will be autosubscribed.");
log.info(" 5. Reregister with autosubscribe and assert that the temporary product has been bound.");
// get the product certs that are currently installed
List<ProductCert> installedProductCerts = clienttasks.getCurrentProductCerts();
// create a clean temporary productCertDir and change the rhsm.conf to point to it
// incase something was leftover from a prior run
RemoteFileTasks.runCommandAndAssert(client, "rm -rf " + tmpProductCertDir, Integer.valueOf(0));
RemoteFileTasks.runCommandAndAssert(client, "mkdir " + tmpProductCertDir, Integer.valueOf(0));
// store the original productCertDir
this.productCertDir = clienttasks.productCertDir;
clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", tmpProductCertDir);
// Register and assert that no products appear to be installed since we changed the productCertDir to a temporary directory
SSHCommandResult sshCommandResult = clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, Boolean.TRUE, null, null, (String) null, null, null, null, true, false, null, null, null, null);
// [root@jsefler-r63-server ~]# subscription-manager register --username testuser1 --password password --auto --org admin
// The system has been registered with id: 243ea73d-01bb-458d-a7a5-2d61fde69494
// Installed Product Current Status:
// pre-fix for blockedByBug-678049 Assert.assertContainsNoMatch(sshCommandResult.getStdout().trim(), "^Subscribed to Products:", "register with autosubscribe should NOT appear to have subscribed to something when there are no installed products.");
Assert.assertTrue(InstalledProduct.parse(sshCommandResult.getStdout()).isEmpty(), "The Installed Product Current Status should be empty when attempting to register with autosubscribe without any product certs installed.");
Assert.assertEquals(clienttasks.list_(null, null, null, Boolean.TRUE, null, null, null, null, null, null, null, null, null, null).getStdout().trim(), "No installed products to list", "Since we changed the productCertDir configuration to an empty location, we should not appear to have any products installed.");
// subscribe to the first available pool that provides one product (whose product cert was also originally installed)
File tmpProductCertFile = null;
OUTERLOOP: for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
JSONObject jsonPool = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/pools/" + pool.poolId));
JSONArray jsonProvidedProducts = jsonPool.getJSONArray("providedProducts");
if (jsonProvidedProducts.length() == 1) {
// FIXME: I doubt this check is needed anymore
JSONObject jsonProvidedProduct = jsonProvidedProducts.getJSONObject(0);
String productId = jsonProvidedProduct.getString("productId");
// now search for an existing installed product that matches and install it as our new tmpProductCert
for (ProductCert productCert : installedProductCerts) {
if (productCert.productId.equals(productId)) {
tmpProductCertFile = new File(tmpProductCertDir + File.separator + "AutosubscribeProduct_" + productId + ".pem");
client.runCommandAndWait("cp " + productCert.file + " " + tmpProductCertFile);
break OUTERLOOP;
}
}
}
}
if (tmpProductCertFile == null)
throw new SkipException("Could not find an available pool that provides only one product with which to test register with --autosubscribe.");
ProductCert tmpProductCert = clienttasks.getProductCertFromProductCertFile(tmpProductCertFile);
// reregister with autosubscribe and assert that the product is bound
sshCommandResult = clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, Boolean.TRUE, null, null, (String) null, null, null, null, true, false, null, null, null, null);
// assert that the sshCommandResult from register indicates the tmpProductCert was subscribed
/* # subscription-manager register --username=testuser1 --password=password --org=admin --autosubscribe
The system has been registered with id: f95fd9bb-4cc8-428e-b3fd-d656b14bfb89
Installed Product Current Status:
ProductName: Awesome OS for S390X Bits
Status: Subscribed
*/
// assert that our tmp product install appears to have been autosubscribed
InstalledProduct autoSubscribedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("status", "Subscribed", InstalledProduct.parse(clienttasks.list_(null, null, null, Boolean.TRUE, null, null, null, null, null, null, null, null, null, null).getStdout()));
Assert.assertNotNull(autoSubscribedProduct, "We appear to have autosubscribed to our fake product install.");
// pre-fix for blockedByBug-678049 Assert.assertContainsMatch(sshCommandResult.getStdout().trim(), "^Subscribed to Products:", "The stdout from register with autotosubscribe indicates that we have subscribed to something");
// pre-fix for blockedByBug-678049 Assert.assertContainsMatch(sshCommandResult.getStdout().trim(), "^\\s+"+autoSubscribedProduct.productName.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)"), "Expected ProductName '"+autoSubscribedProduct.productName+"' was reported as autosubscribed in the output from register with autotosubscribe.");
// Assert.assertContainsMatch(sshCommandResult.getStdout().trim(), ".* - Subscribed", "The stdout from register with autotosubscribe indicates that we have automatically subscribed at least one of this system's installed products to an available subscription pool.");
List<InstalledProduct> autosubscribedProductStatusList = InstalledProduct.parse(sshCommandResult.getStdout());
Assert.assertEquals(autosubscribedProductStatusList.size(), 1, "Only one product appears installed.");
Assert.assertEquals(autosubscribedProductStatusList.get(0), new InstalledProduct(tmpProductCert.productName, null, null, null, "Subscribed", null, null, null), "As expected, ProductName '" + tmpProductCert.productName + "' was reported as subscribed in the output from register with autotosubscribe.");
}
use of rhsm.data.ProductCert in project rhsm-qe by RedHatQE.
the class RegisterTests method testRegisterWithAutosubscribe_DEPRECATED.
@Test(description = "subscription-manager-cli: register to a Candlepin server using autosubscribe functionality", groups = { "Tier1Tests", "RegisterWithAutosubscribe_Test", "blockedByBug-602378", "blockedByBug-616137", "blockedByBug-678049", "blockedByBug-737762", "blockedByBug-743082" }, // the strategy for this test has been improved in the new implementation of RegisterWithAutosubscribe_Test()
enabled = false)
@Deprecated
public void testRegisterWithAutosubscribe_DEPRECATED() throws JSONException, Exception {
log.info("RegisterWithAutosubscribe_Test Strategy:");
log.info(" For DEV and QA testing purposes, we may not have valid products installed on the client, therefore we will fake an installed product by following this strategy:");
log.info(" 1. Change the rhsm.conf configuration for productCertDir to point to a new temporary product cert directory.");
log.info(" 2. Register with autosubscribe and assert that no product binding has occurred.");
log.info(" 3. Subscribe to a randomly available pool");
log.info(" 4. Copy the downloaded entitlement cert to the temporary product cert directory.");
log.info(" (this will fake rhsm into believing that the same product is installed)");
log.info(" 5. Reregister with autosubscribe and assert that a product has been bound.");
// create a clean temporary productCertDir and change the rhsm.conf to point to it
// incase something was leftover from a prior run
RemoteFileTasks.runCommandAndAssert(client, "rm -rf " + tmpProductCertDir, Integer.valueOf(0));
RemoteFileTasks.runCommandAndAssert(client, "mkdir " + tmpProductCertDir, Integer.valueOf(0));
// store the original productCertDir
this.productCertDir = clienttasks.productCertDir;
clienttasks.updateConfFileParameter(clienttasks.rhsmConfFile, "productCertDir", tmpProductCertDir);
// Register and assert that no products appear to be installed since we changed the productCertDir to a temporary directory
clienttasks.unregister(null, null, null, null);
SSHCommandResult sshCommandResult = clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, Boolean.TRUE, null, null, (String) null, null, null, null, null, false, null, null, null, null);
// [root@jsefler-r63-server ~]# subscription-manager register --username testuser1 --password password --auto --org admin
// The system has been registered with id: 243ea73d-01bb-458d-a7a5-2d61fde69494
// Installed Product Current Status:
// ProductName: Awesome OS for S390 Bits
// Status: Not Subscribed
//
// ProductName: Stackable with Awesome OS for x86_64 Bits
// Status: Subscribed
// pre-fix for blockedByBug-678049 Assert.assertContainsNoMatch(sshCommandResult.getStdout().trim(), "^Subscribed to Products:", "register with autosubscribe should NOT appear to have subscribed to something when there are no installed products.");
Assert.assertTrue(InstalledProduct.parse(sshCommandResult.getStdout()).isEmpty(), "The Installed Product Current Status should be empty when attempting to register with autosubscribe without any product certs installed.");
Assert.assertEquals(clienttasks.list_(null, null, null, Boolean.TRUE, null, null, null, null, null, null, null, null, null, null).getStdout().trim(), "No installed products to list", "Since we changed the productCertDir configuration to an empty location, we should not appear to have any products installed.");
// List <InstalledProduct> currentlyInstalledProducts = InstalledProduct.parse(clienttasks.list_(null, null, null, Boolean.TRUE, null, null, null).getStdout());
// for (String status : new String[]{"Not Subscribed","Subscribed"}) {
// Assert.assertNull(InstalledProduct.findFirstInstanceWithMatchingFieldFromList("status", status, currentlyInstalledProducts),
// "When no product certs are installed, then we should not be able to find a installed product with status '"+status+"'.");
// }
// subscribe to a randomly available pool
/* This is too random
List<SubscriptionPool> pools = clienttasks.getCurrentlyAvailableSubscriptionPools();
SubscriptionPool pool = pools.get(randomGenerator.nextInt(pools.size())); // randomly pick a pool
File entitlementCertFile = clienttasks.subscribeToSubscriptionPoolUsingPoolId(pool);
*/
// subscribe to the first available pool that provides one product
File entitlementCertFile = null;
for (SubscriptionPool pool : clienttasks.getCurrentlyAvailableSubscriptionPools()) {
JSONObject jsonPool = new JSONObject(CandlepinTasks.getResourceUsingRESTfulAPI(sm_clientUsername, sm_clientPassword, sm_serverUrl, "/pools/" + pool.poolId));
JSONArray jsonProvidedProducts = jsonPool.getJSONArray("providedProducts");
if (jsonProvidedProducts.length() == 1) {
entitlementCertFile = clienttasks.subscribeToSubscriptionPool(pool, /*sm_serverAdminUsername*/
sm_clientUsername, /*sm_serverAdminPassword*/
sm_clientPassword, sm_serverUrl);
break;
}
}
if (entitlementCertFile == null)
throw new SkipException("Could not find an available pool that provides only one product with which to test register with --autosubscribe.");
// copy the downloaded entitlement cert to the temporary product cert directory (this will fake rhsm into believing that the same product is installed)
RemoteFileTasks.runCommandAndAssert(client, "cp " + entitlementCertFile.getPath() + " " + tmpProductCertDir, Integer.valueOf(0));
File tmpProductCertFile = new File(tmpProductCertDir + File.separator + entitlementCertFile.getName());
ProductCert fakeProductCert = clienttasks.getProductCertFromProductCertFile(tmpProductCertFile);
// reregister with autosubscribe and assert that the product is bound
clienttasks.unregister(null, null, null, null);
sshCommandResult = clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, Boolean.TRUE, null, null, (String) null, null, null, null, null, false, null, null, null, null);
// assert that the sshCommandResult from register indicates the fakeProductCert was subscribed
/* # subscription-manager register --username=testuser1 --password=password
d67df9c8-f381-4449-9d17-56094ea58092 testuser1
Subscribed to Products:
RHEL for Physical Servers SVC(37060)
Red Hat Enterprise Linux High Availability (for RHEL Entitlement)(4)
*/
/* # subscription-manager register --username=testuser1 --password=password
cadf825a-6695-41e3-b9eb-13d7344159d3 jsefler-onprem03.usersys.redhat.com
Installed Products:
Clustering Bits - Subscribed
Awesome OS Server Bits - Not Installed
*/
/* # subscription-manager register --username=testuser1 --password=password --org=admin --autosubscribe
The system has been registered with id: f95fd9bb-4cc8-428e-b3fd-d656b14bfb89
Installed Product Current Status:
ProductName: Awesome OS for S390X Bits
Status: Subscribed
*/
// assert that our fake product install appears to have been autosubscribed
InstalledProduct autoSubscribedProduct = InstalledProduct.findFirstInstanceWithMatchingFieldFromList("status", "Subscribed", InstalledProduct.parse(clienttasks.list_(null, null, null, Boolean.TRUE, null, null, null, null, null, null, null, null, null, null).getStdout()));
Assert.assertNotNull(autoSubscribedProduct, "We appear to have autosubscribed to our fake product install.");
// pre-fix for blockedByBug-678049 Assert.assertContainsMatch(sshCommandResult.getStdout().trim(), "^Subscribed to Products:", "The stdout from register with autotosubscribe indicates that we have subscribed to something");
// pre-fix for blockedByBug-678049 Assert.assertContainsMatch(sshCommandResult.getStdout().trim(), "^\\s+"+autoSubscribedProduct.productName.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)"), "Expected ProductName '"+autoSubscribedProduct.productName+"' was reported as autosubscribed in the output from register with autotosubscribe.");
// Assert.assertContainsMatch(sshCommandResult.getStdout().trim(), ".* - Subscribed", "The stdout from register with autotosubscribe indicates that we have automatically subscribed at least one of this system's installed products to an available subscription pool.");
List<InstalledProduct> autosubscribedProductStatusList = InstalledProduct.parse(sshCommandResult.getStdout());
Assert.assertEquals(autosubscribedProductStatusList.size(), 1, "Only one product was autosubscribed.");
Assert.assertEquals(autosubscribedProductStatusList.get(0), new InstalledProduct(fakeProductCert.productName, null, null, null, "Subscribed", null, null, null), "As expected, ProductName '" + fakeProductCert.productName + "' was reported as subscribed in the output from register with autotosubscribe.");
// WARNING The following two asserts lead to misleading failures when the entitlementCertFile that we using to fake as a tmpProductCertFile happens to have multiple bundled products inside. This is why we search for an available pool that provides one product early in this test.
// Assert.assertContainsMatch(sshCommandResult.getStdout().trim(), "^\\s+"+autoSubscribedProduct.productName.replaceAll("\\(", "\\\\(").replaceAll("\\)", "\\\\)")+" - Subscribed", "Expected ProductName '"+autoSubscribedProduct.productName+"' was reported as autosubscribed in the output from register with autotosubscribe.");
// Assert.assertNotNull(ProductSubscription.findFirstInstanceWithMatchingFieldFromList("productName", autoSubscribedProduct.productName, clienttasks.getCurrentlyConsumedProductSubscriptions()),"Expected ProductSubscription with ProductName '"+autoSubscribedProduct.productName+"' is consumed after registering with autosubscribe.");
}
Aggregations