Search in sources :

Example 1 with YumRepo

use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.

the class SubscriptionManagerTasks method getYumRepolist.

/**
 * @param options [all|enabled|disabled] [--option=...]
 * @return array of repo labels returned from a call to yum repolist [options]
 */
public ArrayList<String> getYumRepolist(String options) {
    if (options == null)
        options = "";
    ArrayList<String> repoList = new ArrayList<String>();
    sshCommandRunner.runCommandAndWaitWithoutLogging("killall -9 yum");
    // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
    sshCommandRunner.runCommandAndWait("yum repolist " + options + " --disableplugin=rhnplugin");
    // TEMPORARY WORKAROUND FOR BUG
    if (this.redhatReleaseX.equals("5")) {
        boolean invokeWorkaroundWhileBugIsOpen = true;
        // Bug 697087 - yum repolist is not producing a list when one of the repo baseurl causes a forbidden 403
        String bugId = "697087";
        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) {
            // avoid "yum repolist" and assemble the list of repos directly from the redhat repo file
            List<YumRepo> yumRepoList = getCurrentlySubscribedYumRepos();
            for (YumRepo yumRepo : yumRepoList) {
                if (options.startsWith("all"))
                    repoList.add(yumRepo.id);
                else if (options.startsWith("enabled") && yumRepo.enabled.equals(Boolean.TRUE))
                    repoList.add(yumRepo.id);
                else if (options.startsWith("disabled") && yumRepo.enabled.equals(Boolean.FALSE))
                    repoList.add(yumRepo.id);
                else if (options.equals("") && yumRepo.enabled.equals(Boolean.TRUE))
                    repoList.add(yumRepo.id);
            }
            // --disableplugin=rhnplugin helps avoid: up2date_client.up2dateErrors.AbuseError
            sshCommandRunner.runCommandAndWait("yum repolist " + options + " --disableplugin=rhnplugin");
            return repoList;
        }
    }
    // repolist: 9,497
    return getYumRepolistFromSSHCommandResult(new SSHCommandResult(sshCommandRunner.getExitCode(), sshCommandRunner.getStdout(), sshCommandRunner.getStderr()));
}
Also used : SSHCommandResult(com.redhat.qe.tools.SSHCommandResult) ArrayList(java.util.ArrayList) YumRepo(rhsm.data.YumRepo) BugzillaAPIException(com.redhat.qe.auto.bugzilla.BugzillaAPIException)

Example 2 with YumRepo

use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.

the class SubscriptionManagerCLITestScript method verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos.

protected void verifyCurrentEntitlementCertsAreReflectedInCurrentlySubscribedYumRepos(List<ProductCert> currentProductCerts) {
    if (currentProductCerts == null)
        currentProductCerts = clienttasks.getCurrentProductCerts();
    List<YumRepo> yumRepos = clienttasks.getCurrentlySubscribedYumRepos();
    List<EntitlementCert> entitlementCerts = clienttasks.getCurrentEntitlementCerts();
    int numYumReposProvided = 0;
    for (EntitlementCert entitlementCert : entitlementCerts) {
        for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
            if (contentNamespace.type.equals("yum")) {
                if (clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts)) {
                    numYumReposProvided++;
                    Assert.assertNotNull(YumRepo.findFirstInstanceWithMatchingFieldFromList("id", contentNamespace.label, yumRepos), "The '" + clienttasks.redhatRepoFile + "' has an entry for contentNamespace label '" + contentNamespace.label + "'.");
                }
            } else {
                // contentNamespace types that are not "yum" should not be included in the redhat.repo file (e.g. "file" and "kickstart")
                Assert.assertNull(YumRepo.findFirstInstanceWithMatchingFieldFromList("id", contentNamespace.label, yumRepos), "The '" + clienttasks.redhatRepoFile + "' should NOT have an entry for contentNamespace label '" + contentNamespace.label + "' because it's type '" + contentNamespace.type + "' is not equal to 'yum'.");
            }
        }
    }
    if (entitlementCerts.isEmpty()) {
        Assert.assertTrue(yumRepos.isEmpty(), "When there are no entitlement contentNamespaces, then '" + clienttasks.redhatRepoFile + "' should have no yumRepo entries.");
    } else if (numYumReposProvided == 0) {
        Assert.assertTrue(yumRepos.isEmpty(), "When none of the currently installed product certs provideTags matching the currently entitled content namespace requiredTags, then '" + clienttasks.redhatRepoFile + "' should have no yumRepo entries.");
    }
}
Also used : ContentNamespace(rhsm.data.ContentNamespace) EntitlementCert(rhsm.data.EntitlementCert) YumRepo(rhsm.data.YumRepo)

Example 3 with YumRepo

use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.

the class ContentTests method testGpgCheckValuesInYumRepos.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20082", "RHEL7-51098" }, 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 = "subscription-manager content flag : gpgcheck value in redhat.repo should be disabled when gpg_url is empty or null", groups = { "Tier1Tests", "blockedByBug-741293", "blockedByBug-805690", "blockedByBug-962520" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testGpgCheckValuesInYumRepos() throws JSONException, Exception {
    // [root@jsefler-r63-server ~]# cat /etc/yum.repos.d/redhat.repo
    // #
    // # Certificate-Based Repositories
    // # Managed by (rhsm) subscription-manager
    // #
    // # If this file is empty and this system is subscribed consider
    // # a "yum repolist" to refresh available repos
    // #
    // 
    // [content-label]
    // name = content
    // baseurl = https://cdn.redhat.com/foo/path
    // enabled = 1
    // gpgcheck = 1
    // gpgkey = https://cdn.redhat.com/foo/path/gpg/
    // sslverify = 1
    // sslcacert = /etc/rhsm/ca/redhat-uep.pem
    // sslclientkey = /etc/pki/entitlement/5488047145460852736-key.pem
    // sslclientcert = /etc/pki/entitlement/5488047145460852736.pem
    // metadata_expire = 0
    // 1.3.6.1.4.1.2312.9.2 (Content Namespace)
    // 1.3.6.1.4.1.2312.9.2.<content_hash> (Red Hat Enterprise Linux (core server))
    // 1.3.6.1.4.1.2312.9.2.<content_hash>.1 (Yum repo type))
    // 1.3.6.1.4.1.2312.9.2.<content_hash>.1.1 (Name) : Red Hat Enterprise Linux (core server)
    // 1.3.6.1.4.1.2312.9.2.<content_hash>.1.2 (Label) : rhel-server
    // 1.3.6.1.4.1.2312.9.2.<content_hash>.1.5 (Vendor ID): %Red_Hat_Id% or %Red_Hat_Label%
    // 1.3.6.1.4.1.2312.9.2.<content_hash>.1.6 (Download URL): content/rhel-server/$releasever/$basearch
    // 1.3.6.1.4.1.2312.9.2.<content_hash>.1.7 (GPG Key URL): file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
    // 1.3.6.1.4.1.2312.9.2.<content_hash>.1.8 (Enabled): 1
    // 1.3.6.1.4.1.2312.9.2.<content_hash>.1.9 (Metadata Expire Seconds): 604800
    // 1.3.6.1.4.1.2312.9.2.<content_hash>.1.10 (Required Tags): TAG1,TAG2,TAG3
    List<ProductCert> currentProductCerts = clienttasks.getCurrentProductCerts();
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    if (clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively().size() <= 0)
        throw new SkipException("No available subscriptions were found.  Therefore we cannot perform this test.");
    List<EntitlementCert> entitlementCerts = clienttasks.getCurrentEntitlementCerts();
    // or maybe we should skip when nothing is consumed
    Assert.assertTrue(!entitlementCerts.isEmpty(), "After subscribing to all available subscription pools, there must be some entitlements.");
    ArrayList<String> repolist = clienttasks.getYumRepolist("enabled");
    List<YumRepo> yumRepos = clienttasks.getCurrentlySubscribedYumRepos();
    for (EntitlementCert entitlementCert : entitlementCerts) {
        for (ContentNamespace contentNamespace : entitlementCert.contentNamespaces) {
            if (!contentNamespace.type.equalsIgnoreCase("yum"))
                continue;
            if (contentNamespace.enabled) {
                if (!clienttasks.areAllRequiredTagsInContentNamespaceProvidedByProductCerts(contentNamespace, currentProductCerts))
                    continue;
                YumRepo yumRepo = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", /*label*/
                contentNamespace.label, yumRepos);
                Assert.assertNotNull(yumRepo, "Found the yum repo within '" + clienttasks.redhatRepoFile + "' corresponding to the entitled content namespace label '" + contentNamespace.label + "'.");
                // case 1: contentNamespace.gpgKeyUrl==null
                if (contentNamespace.gpgKeyUrl == null) {
                    Assert.assertFalse(yumRepo.gpgcheck, "gpgcheck is False for Yum repo '" + yumRepo.id + "' when corresponding entitlement contentNamespace has a null gpgKeyUrl: contentNamespace: " + contentNamespace);
                    Assert.assertNull(yumRepo.gpgkey, "gpgkey is not set for Yum repo '" + yumRepo.id + "' when corresponding entitlement contentNamespace has a null gpgKeyUrl: contentNamespace: " + contentNamespace);
                // case 2: contentNamespace.gpgKeyUrl==""
                } else if (contentNamespace.gpgKeyUrl.equals("")) {
                    Assert.assertFalse(yumRepo.gpgcheck, "gpgcheck is False for Yum repo '" + yumRepo.id + "' when corresponding entitlement contentNamespace has an empty gpgKeyUrl: contentNamespace: " + contentNamespace);
                    Assert.assertNull(yumRepo.gpgkey, "gpgkey is not set for Yum repo '" + yumRepo.id + "' when corresponding entitlement contentNamespace has an empty gpgKeyUrl: contentNamespace: " + contentNamespace);
                // case 3: contentNamespace.gpgKeyUrl.startsWith("http")
                } else if (contentNamespace.gpgKeyUrl.startsWith("http:") || contentNamespace.gpgKeyUrl.startsWith("https:")) {
                    Assert.assertTrue(yumRepo.gpgcheck, "gpgcheck is True for Yum repo '" + yumRepo.id + "' when corresponding entitlement contentNamespace has a non-null/empty gpgKeyUrl: contentNamespace: " + contentNamespace);
                    Assert.assertEquals(yumRepo.gpgkey, contentNamespace.gpgKeyUrl, "gpgkey is set for Yum repo '" + yumRepo.id + "' when corresponding entitlement contentNamespace has a non-null/empty gpgKeyUrl: contentNamespace: " + contentNamespace);
                // case 4: contentNamespace.gpgKeyUrl.startsWith("file:")
                } else if (contentNamespace.gpgKeyUrl.startsWith("file:")) {
                    Assert.assertTrue(yumRepo.gpgcheck, "gpgcheck is True for Yum repo '" + yumRepo.id + "' when corresponding entitlement contentNamespace has a non-null/empty gpgKeyUrl: contentNamespace: " + contentNamespace);
                    Assert.assertEquals(yumRepo.gpgkey, contentNamespace.gpgKeyUrl, "gpgkey is set for Yum repo '" + yumRepo.id + "' when corresponding entitlement contentNamespace has a non-null/empty gpgKeyUrl: contentNamespace: " + contentNamespace);
                // case 5: contentNamespace.gpgKeyUrl is a relative path
                } else {
                    Assert.assertTrue(yumRepo.gpgcheck, "gpgcheck is True for Yum repo '" + yumRepo.id + "' when corresponding entitlement contentNamespace has a non-null/empty gpgKeyUrl: contentNamespace: " + contentNamespace);
                    Assert.assertEquals(yumRepo.gpgkey, clienttasks.baseurl + contentNamespace.gpgKeyUrl, "gpgkey is set for Yum repo '" + yumRepo.id + "' when corresponding entitlement contentNamespace has a non-null/empty gpgKeyUrl: contentNamespace: " + contentNamespace);
                }
            }
        }
    }
    if (yumRepos.isEmpty())
        throw new SkipException("Since no Red Hat repos were found in '" + clienttasks.redhatRepoFile + "', there are no gpgcheck values to verify.");
}
Also used : ContentNamespace(rhsm.data.ContentNamespace) EntitlementCert(rhsm.data.EntitlementCert) ProductCert(rhsm.data.ProductCert) SkipException(org.testng.SkipException) YumRepo(rhsm.data.YumRepo) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 4 with YumRepo

use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.

the class ContentTests method testYumRepoUiRepoIdVars.

@// update=true	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-20086", "RHEL7-51097" }, 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 yum vars used in a baseurl are listed in a yum repo parameter called ui_repoid_vars", groups = { "Tier1Tests", "blockedByBug-906554" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testYumRepoUiRepoIdVars() throws JSONException, Exception {
    // register
    clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, null, null, null, (String) null, null, null, null, true, false, null, null, null, null);
    // subscribe to available subscriptions
    clienttasks.subscribeToTheCurrentlyAvailableSubscriptionPoolsCollectively();
    // process each of the yum repos granted and assert the yum vars contained in the baseurl are listed in the ui_repoid_vars
    boolean UiRepoIdVarsTested = false;
    for (YumRepo yumRepo : clienttasks.getCurrentlySubscribedYumRepos()) {
        log.info("Asserting Yum Repo: " + yumRepo);
        // baseurl = https://cdn.redhat.com/content/dist/rhel/server/5/$releasever/$basearch/jbeap/5/os
        Pattern p = Pattern.compile("\\$\\w+");
        Matcher matcher = p.matcher(yumRepo.baseurl);
        // first, check if the baseurl has any yum vars
        if (!matcher.find()) {
            // assert that this yumRepo has no ui_repoid_vars configuration
            Assert.assertNull(yumRepo.ui_repoid_vars, "When baseurl '" + yumRepo.baseurl + "' of yumRepo '" + yumRepo.id + "' contains no yum vars, then configuration ui_repoid_vars is not required.");
            continue;
        }
        // now make sure all of the yum vars in the baseurl are present in the ui_repoid_vars configuration
        matcher.reset();
        List<String> actualUiRepoidVars = Arrays.asList(yumRepo.ui_repoid_vars.trim().split("\\s+"));
        while (matcher.find()) {
            UiRepoIdVarsTested = true;
            String yumVar = matcher.group();
            // assert that the configured ui_repoid_vars contains this yum var
            Assert.assertTrue(actualUiRepoidVars.contains(yumVar.replaceFirst("^\\$", "")), "The ui_repoid_vars configuration in repo id '" + yumRepo.id + "' contains yum var '" + yumVar + "' used in its baseurl '" + yumRepo.baseurl + "'.");
        }
    // TODO on RHEL7 we should learn how the yum vars get propagated to the ui when calling yum repolist  (dgregor probably knows)
    // [root@jsefler-7 ~]# yum repolist
    // Loaded plugins: langpacks, product-id, security, subscription-manager
    // This system is receiving updates from Red Hat Subscription Management.
    // repo id                                                                                           repo name                                                                               status
    // always-enabled-content/6.92Server                                                                 always-enabled-content                                                                  0
    // awesomeos/6.92Server/x86_64                                                                       awesomeos                                                                               0
    // repolist: 0
    // Notice the repoid labels are appended with /$releasever and /$releasever/$basearch
    }
    if (!UiRepoIdVarsTested)
        throw new SkipException("Could not find any YumRepos containing yum vars to assert this test.");
}
Also used : Pattern(java.util.regex.Pattern) Matcher(java.util.regex.Matcher) YumRepo(rhsm.data.YumRepo) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test) ImplementsNitrateTest(com.redhat.qe.auto.tcms.ImplementsNitrateTest)

Example 5 with YumRepo

use of rhsm.data.YumRepo in project rhsm-qe by RedHatQE.

the class DockerTests method testSubscriptionManagementEntitlementsInContainerMode.

@// update=true,	// uncomment to make TestDefinition changes update Polarion testcases through the polarize testcase importer
TestDefinition(projectID = { Project.RHEL6, Project.RedHatEnterpriseLinux7 }, testCaseID = { "RHEL6-26769", "RHEL7-51757" }, 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 when in container mode, redhat.repo is populated from the entitlements in /etc/rhsm/entitlement-host", groups = { "Tier3Tests", "VerifySubscriptionManagementEntitlementsInContainerMode_Test" }, enabled = true)
public // @ImplementsNitrateTest(caseId=)
void testSubscriptionManagementEntitlementsInContainerMode() {
    // start by registering the host with autosubscribe to gain some entitlements...
    log.info("Start fresh by registering the host with autosubscribe and getting the host's yum repolist...");
    consumerId = clienttasks.getCurrentConsumerId(clienttasks.register(sm_clientUsername, sm_clientPassword, sm_clientOrg, null, null, null, null, true, null, null, (String) null, null, null, null, true, false, null, null, null, null));
    // remember the yum repolist and the subscribed YumRepo data on the host
    List<YumRepo> subscribedYumReposOnHost = clienttasks.getCurrentlySubscribedYumRepos();
    if (subscribedYumReposOnHost.isEmpty())
        throw new SkipException("Skipping this test when no redhat.repo content is granted.  (Expected autosubscribe to grant some entitlements.)");
    List<String> yumRepolistOnHost = clienttasks.getYumRepolist("all");
    if (yumRepolistOnHost.isEmpty())
        throw new SkipException("Skipping this test when yum repolist all is empty.  (Should always pass since the prior assert for some granted entitlements passed.)");
    // put the system into container mode
    setupContainerMode();
    // verify that no content is available when /etc/pki/entitlement-host is empty
    String entitlementCertDir = clienttasks.getConfFileParameter(clienttasks.rhsmConfFile, "rhsm", "entitlementCertDir");
    client.runCommandAndWait("ls -l " + entitlementCertDir);
    client.runCommandAndWait("ls -l " + entitlementHostDir);
    List<String> yumRepolistOnContainer = clienttasks.getYumRepolist("all");
    Assert.assertTrue(yumRepolistOnContainer.size() < yumRepolistOnHost.size(), "When in container mode (with *no* entitlements in '" + entitlementHostDir + "'), the number of yum repolists available should have dimmished (by the number of redhat.repo repos on the host)");
    List<YumRepo> subscribedYumReposOnContainer = clienttasks.getCurrentlySubscribedYumRepos();
    Assert.assertTrue(subscribedYumReposOnContainer.isEmpty(), "When in container mode (with *no* entitlements in '" + entitlementHostDir + "'), there should be no redhat.repo content available.");
    // put the host's entitlements into /etc/pki/entitlement-host
    client.runCommandAndWait("cp " + entitlementCertDir + "/* " + entitlementHostDir);
    client.runCommandAndWait("ls -l " + entitlementHostDir);
    // clean the consumer  TODO: FIXME - cleaning the host consumer will orphan all of his entitlements.  This should be properly deleted in an AfterGroup
    log.info("Deleting the consumer cert (containers don't depend on a consumer)...");
    clienttasks.removeAllCerts(true, true, false);
    // verify that the host entitlements are now accessible when in container mode
    yumRepolistOnContainer = clienttasks.getYumRepolist("all");
    Assert.assertTrue(yumRepolistOnContainer.containsAll(yumRepolistOnHost) && yumRepolistOnHost.containsAll(yumRepolistOnContainer), "When in container mode, the entitlements in '" + entitlementHostDir + "' are reflected in yum repolist all. (yum repolist all in the container matches yum repolist all from the host)");
    subscribedYumReposOnContainer = clienttasks.getCurrentlySubscribedYumRepos();
    // Note: the subscribedYumReposOnContainer should only differ from the subscribedYumReposOnHost by the value of the entitlement cert dir path:
    // sslclientcert = /etc/pki/entitlement-host/2166701319103111701.pem
    // sslclientkey = /etc/pki/entitlement-host/2166701319103111701-key.pem
    // sslcacert = /etc/rhsm-host/ca/redhat-uep.pem
    Assert.assertEquals(subscribedYumReposOnContainer.size(), subscribedYumReposOnHost.size(), "When in container mode, the redhat.repo content in available reflects the same list of redhat.repo content available on the host.  (Size check only.)");
    for (YumRepo subscribedYumRepoOnHost : subscribedYumReposOnHost) {
        YumRepo subscribedYumRepoOnContainer = YumRepo.findFirstInstanceWithMatchingFieldFromList("id", subscribedYumRepoOnHost.id, subscribedYumReposOnContainer);
        Assert.assertEquals(subscribedYumRepoOnContainer.name, subscribedYumRepoOnHost.name, "YumRepo [" + subscribedYumRepoOnHost.id + "] data 'name' compares between host and container entitlements.");
        Assert.assertEquals(subscribedYumRepoOnContainer.baseurl, subscribedYumRepoOnHost.baseurl, "YumRepo [" + subscribedYumRepoOnHost.id + "] data 'baseurl' compares between host and container entitlements.");
        if (subscribedYumRepoOnContainer.gpgkey != null)
            Assert.assertEquals(subscribedYumRepoOnContainer.gpgkey, subscribedYumRepoOnHost.gpgkey, "YumRepo [" + subscribedYumRepoOnHost.id + "] data 'gpgkey' compares between host and container entitlements.");
        if (subscribedYumRepoOnContainer.gpgcheck != null)
            Assert.assertEquals(subscribedYumRepoOnContainer.gpgcheck, subscribedYumRepoOnHost.gpgcheck, "YumRepo [" + subscribedYumRepoOnHost.id + "] data 'gpgcheck' compares between host and container entitlements.");
        if (subscribedYumRepoOnContainer.enabled != null)
            Assert.assertEquals(subscribedYumRepoOnContainer.enabled, subscribedYumRepoOnHost.enabled, "YumRepo [" + subscribedYumRepoOnHost.id + "] data 'enabled' compares between host and container entitlements.");
        if (subscribedYumRepoOnContainer.metadata_expire != null)
            Assert.assertEquals(subscribedYumRepoOnContainer.metadata_expire, subscribedYumRepoOnHost.metadata_expire, "YumRepo [" + subscribedYumRepoOnHost.id + "] data 'metadata_expire' compares between host and container entitlements.");
        // TODO could continue adding more asserts for field equality like these ^
        Assert.assertTrue(subscribedYumRepoOnContainer.sslcacert.replaceFirst(rhsmHostDir, "").equals(subscribedYumRepoOnHost.sslcacert.replaceFirst("/etc/rhsm", "")), "YumRepo [" + subscribedYumRepoOnHost.id + "] data 'sslcacert' between host '" + subscribedYumRepoOnHost.sslcacert + "' and container '" + subscribedYumRepoOnContainer.sslcacert + "' entitlements differ only by directory path.");
        /* FIXME: the following asserts can fail unfairly when there are multiple entitlements that provide content for the same repo, subscribedYumRepoOnHost.id, since any one of them can land in the YumRepo (happens in the TESTDATA)
			Assert.assertTrue(subscribedYumRepoOnContainer.sslclientcert.replaceFirst(entitlementHostDir, "").equals(subscribedYumRepoOnHost.sslclientcert.replaceFirst(entitlementCertDir, "")),"YumRepo ["+subscribedYumRepoOnHost.id+"] data 'sslclientcert' between host '"+subscribedYumRepoOnHost.sslclientcert+"' and container '"+subscribedYumRepoOnContainer.sslclientcert+"' entitlements differ only by directory path.");
			Assert.assertTrue(subscribedYumRepoOnContainer.sslclientkey.replaceFirst(entitlementHostDir, "").equals(subscribedYumRepoOnHost.sslclientkey.replaceFirst(entitlementCertDir, "")),"YumRepo ["+subscribedYumRepoOnHost.id+"] data 'sslclientkey' between host '"+subscribedYumRepoOnHost.sslclientkey+"' and container '"+subscribedYumRepoOnContainer.sslclientkey+"' entitlements differ only by directory path.");
			*/
        // FIXED below we just ignore the serial
        Assert.assertTrue(subscribedYumRepoOnContainer.sslclientcert.replaceFirst("-host/\\d+\\.pem$", "").equals(subscribedYumRepoOnHost.sslclientcert.replaceFirst("/\\d+\\.pem$", "")), "YumRepo [" + subscribedYumRepoOnHost.id + "] data 'sslclientcert' between host '" + subscribedYumRepoOnHost.sslclientcert + "' and container '" + subscribedYumRepoOnContainer.sslclientcert + "' entitlements differ by directory path suffix '-host' (ignoring serial since this repo could be provided by multiple entitlements).");
        Assert.assertTrue(subscribedYumRepoOnContainer.sslclientkey.replaceFirst("-host/\\d+-key\\.pem$", "").equals(subscribedYumRepoOnHost.sslclientkey.replaceFirst("/\\d+-key\\.pem$", "")), "YumRepo [" + subscribedYumRepoOnHost.id + "] data 'sslclientkey' between host '" + subscribedYumRepoOnHost.sslclientkey + "' and container '" + subscribedYumRepoOnContainer.sslclientkey + "' entitlements differ by directory path suffix '-host' (ignoring serial since this repo could be provided by multiple entitlements).");
    }
}
Also used : YumRepo(rhsm.data.YumRepo) SkipException(org.testng.SkipException) TestDefinition(com.github.redhatqe.polarize.metadata.TestDefinition) Test(org.testng.annotations.Test)

Aggregations

YumRepo (rhsm.data.YumRepo)29 TestDefinition (com.github.redhatqe.polarize.metadata.TestDefinition)23 Test (org.testng.annotations.Test)23 SkipException (org.testng.SkipException)17 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)12 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 Repo (rhsm.data.Repo)8 ImplementsNitrateTest (com.redhat.qe.auto.tcms.ImplementsNitrateTest)4 Map (java.util.Map)4 BigInteger (java.math.BigInteger)3 ContentNamespace (rhsm.data.ContentNamespace)3 EntitlementCert (rhsm.data.EntitlementCert)3 ProductSubscription (rhsm.data.ProductSubscription)3 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)2 ProductCert (rhsm.data.ProductCert)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1