Exemple #1
0
    def test_inclusion_dependency_only(self):
        """Unit test for yum with test dependencies in Inclusion & NotSelected Classifications"""
        self.runtime.set_legacy_test_type('HappyPath')
        package_manager = self.container.get('package_manager')
        self.assertIsNotNone(package_manager)
        self.runtime.stop()

        argument_composer = ArgumentComposer()
        argument_composer.classifications_to_include = [
            Constants.PackageClassification.UNCLASSIFIED
        ]
        argument_composer.patches_to_include = [
            "ssh", "selinux-policy-targeted.noarch"
        ]
        argument_composer.patches_to_exclude = ["ssh*", "test"]
        self.runtime = RuntimeCompositor(
            argument_composer.get_composed_arguments(), True, Constants.YUM)
        self.container = self.runtime.container

        package_filter = self.container.get('package_filter')
        self.assertIsNotNone(package_filter)

        # test for get_available_updates
        available_updates, package_versions = package_manager.get_available_updates(
            package_filter)
        self.assertIsNotNone(available_updates)
        self.assertIsNotNone(package_versions)
        self.assertEqual(len(available_updates), 1)
        self.assertEqual(len(package_versions), 1)
        self.assertEqual(available_updates[0],
                         "selinux-policy-targeted.noarch")
        self.assertEqual(package_versions[0], "3.13.1-102.el7_3.16")
Exemple #2
0
    def test_inclusion_notexist(self):
        """Unit test for yum with Inclusion which does not exist & NotSelected Classifications"""
        self.runtime.set_legacy_test_type('HappyPath')
        package_manager = self.container.get('package_manager')
        self.assertIsNotNone(package_manager)
        self.runtime.stop()

        argument_composer = ArgumentComposer()
        argument_composer.classifications_to_include = [
            Constants.PackageClassification.UNCLASSIFIED
        ]
        argument_composer.patches_to_include = ["ssh"]
        argument_composer.patches_to_exclude = ["ssh*", "test"]
        self.runtime = RuntimeCompositor(
            argument_composer.get_composed_arguments(), True, Constants.YUM)
        self.container = self.runtime.container

        package_filter = self.container.get('package_filter')
        self.assertIsNotNone(package_filter)

        # test for get_available_updates
        available_updates, package_versions = package_manager.get_available_updates(
            package_filter)
        self.assertIsNotNone(available_updates)
        self.assertIsNotNone(package_versions)
        self.assertEqual(len(available_updates), 0)
        self.assertEqual(len(package_versions), 0)
Exemple #3
0
    def test_exclusions_with_python_arch(self):
        argument_composer = ArgumentComposer()
        argument_composer.classifications_to_include = []
        argument_composer.patches_to_include = []
        argument_composer.patches_to_exclude = [
            "python", "ssh.i686", "all*", "added"
        ]
        runtime = RuntimeCompositor(argument_composer.get_composed_arguments(),
                                    True)

        self.assertEqual(runtime.package_filter.is_exclusion_list_present(),
                         True)
        self.assertEqual(
            runtime.package_filter.check_for_exclusion("python.x86_64"), True)
        self.assertEqual(
            runtime.package_filter.check_for_exclusion("python.i686"), True)
        self.assertEqual(
            runtime.package_filter.check_for_exclusion("python.test"), False)
        self.assertEqual(runtime.package_filter.check_for_exclusion("python."),
                         False)
        self.assertEqual(
            runtime.package_filter.check_for_exclusion("ssh.i686"), True)
        self.assertEqual(runtime.package_filter.check_for_exclusion("all"),
                         True)
        self.assertEqual(runtime.package_filter.check_for_exclusion("added"),
                         True)
        self.assertEqual(
            runtime.package_filter.check_for_exclusion("added.v4"), False)
        self.assertEqual(runtime.package_filter.check_for_exclusion("random"),
                         False)
        runtime.stop()
Exemple #4
0
    def test_inclusion_only(self):
        """Unit test for yum package manager with inclusion only and NotSelected Classifications"""
        self.runtime.set_legacy_test_type('HappyPath')
        package_manager = self.container.get('package_manager')
        self.assertIsNotNone(package_manager)
        self.runtime.stop()

        argument_composer = ArgumentComposer()
        argument_composer.classifications_to_include = [
            Constants.PackageClassification.UNCLASSIFIED
        ]
        argument_composer.patches_to_include = ["ssh", "tar*"]
        argument_composer.patches_to_exclude = ["ssh*", "test"]
        self.runtime = RuntimeCompositor(
            argument_composer.get_composed_arguments(), True, Constants.YUM)
        self.container = self.runtime.container

        package_filter = self.container.get('package_filter')
        self.assertIsNotNone(package_filter)

        # test for get_available_updates
        available_updates, package_versions = package_manager.get_available_updates(
            package_filter)
        self.assertIsNotNone(available_updates)
        self.assertIsNotNone(package_versions)
        self.assertEqual(len(available_updates), 1)
        self.assertEqual(len(package_versions), 1)
        self.assertEqual(available_updates[0], "tar.x86_64")
        self.assertEqual(package_versions[0], "2:1.26-34.el7")
Exemple #5
0
    def test_inclusion_type_critical(self):
        """Unit test for yum package manager with inclusion and Classification = Critical"""
        self.runtime.set_legacy_test_type('HappyPath')
        package_manager = self.container.get('package_manager')
        self.assertIsNotNone(package_manager)
        self.runtime.stop()

        argument_composer = ArgumentComposer()
        argument_composer.classifications_to_include = [
            Constants.PackageClassification.CRITICAL
        ]
        argument_composer.patches_to_exclude = ["ssh*", "test"]
        argument_composer.patches_to_include = ["ssh", "tar*"]
        self.runtime = RuntimeCompositor(
            argument_composer.get_composed_arguments(), True, Constants.YUM)
        self.container = self.runtime.container

        package_filter = self.container.get('package_filter')
        self.assertIsNotNone(package_filter)

        # test for get_available_updates
        available_updates, package_versions = package_manager.get_available_updates(
            package_filter)
        self.assertIsNotNone(available_updates)
        self.assertIsNotNone(package_versions)
        self.assertEqual(len(available_updates), 2)
        self.assertEqual(len(package_versions), 2)
        self.assertEqual(available_updates[0], "libgcc.i686")
        self.assertEqual(available_updates[1], "tar.x86_64")
        self.assertEqual(package_versions[0], "4.8.5-28.el7")
        self.assertEqual(package_versions[1], "2:1.26-34.el7")
Exemple #6
0
    def test_exclusions(self):
        argument_composer = ArgumentComposer()
        argument_composer.classifications_to_include = []
        argument_composer.patches_to_include = []
        argument_composer.patches_to_exclude = ["ssh*", "test"]
        runtime = RuntimeCompositor(argument_composer.get_composed_arguments(),
                                    True)

        self.assertEqual(runtime.package_filter.is_exclusion_list_present(),
                         True)

        self.assertEqual(runtime.package_filter.check_for_exclusion("ssh"),
                         True)
        self.assertEqual(
            runtime.package_filter.check_for_exclusion("ssh-client"), True)
        self.assertEqual(
            runtime.package_filter.check_for_exclusion("custom-ssh"), False)
        self.assertEqual(runtime.package_filter.check_for_exclusion("test"),
                         True)
        self.assertEqual(runtime.package_filter.check_for_exclusion("kernel"),
                         False)

        self.assertEqual(
            runtime.package_filter.check_for_exclusion(["kernel", "firefox"]),
            False)
        self.assertEqual(
            runtime.package_filter.check_for_exclusion(
                ["firefox", "ssh-client"]), True)
        runtime.stop()
Exemple #7
0
    def test_invalid_classifications(self):
        argument_composer = ArgumentComposer()
        argument_composer.classifications_to_include = ['Security', "Other"]
        argument_composer.patches_to_include = []
        argument_composer.patches_to_exclude = []
        runtime = RuntimeCompositor(argument_composer.get_composed_arguments(),
                                    True)

        self.assertEqual(
            runtime.package_filter.is_invalid_classification_combination(),
            True)
        runtime.stop()
    def test_with_none_for_classifications(self):
        argument_composer = ArgumentComposer()
        argument_composer.classifications_to_include = None
        argument_composer.patches_to_include = []
        argument_composer.patches_to_exclude = []
        runtime = RuntimeCompositor(argument_composer.get_composed_arguments(),
                                    True)

        self.assertEqual(
            runtime.package_filter.is_invalid_classification_combination(),
            False)
        runtime.stop()
Exemple #9
0
    def test_included_classifications(self):
        argument_composer = ArgumentComposer()
        argument_composer.classifications_to_include = ['Critical', 'Security']
        argument_composer.patches_to_include = []
        argument_composer.patches_to_exclude = []
        runtime = RuntimeCompositor(argument_composer.get_composed_arguments(),
                                    True)

        self.assertEqual(
            runtime.package_filter.is_msft_critsec_classification_only(), True)
        self.assertEqual(
            runtime.package_filter.is_msft_other_classification_only(), False)
        runtime.stop()
    def test_included_classifications_short_term_accomodations(self):
        # this test should be removed once the accommodations in execution config are removed
        argument_composer = ArgumentComposer()
        argument_composer.classifications_to_include = ['Security', 'Other']
        argument_composer.patches_to_include = []
        argument_composer.patches_to_exclude = []
        runtime = RuntimeCompositor(argument_composer.get_composed_arguments(),
                                    True)

        self.assertEqual(
            runtime.package_filter.is_invalid_classification_combination(),
            False)  # this will fail after accommodations are removed.
        self.assertEqual(
            runtime.package_filter.is_msft_all_classification_included(),
            True)  # this will fail after accommodations are removed.
        self.assertEqual(
            runtime.package_filter.is_msft_critsec_classification_only(),
            False)
        self.assertEqual(
            runtime.package_filter.is_msft_other_classification_only(), False)
        runtime.stop()
Exemple #11
0
    def test_inclusion_type_other(self):
        """Unit test for yum package manager with inclusion and Classification = Other"""
        self.runtime.set_legacy_test_type('HappyPath')
        package_manager = self.container.get('package_manager')
        self.assertIsNotNone(package_manager)
        self.runtime.stop()

        argument_composer = ArgumentComposer()
        argument_composer.classifications_to_include = [
            Constants.PackageClassification.OTHER
        ]
        argument_composer.patches_to_include = ["ssh", "tcpdump"]
        argument_composer.patches_to_exclude = ["ssh*", "test"]
        self.runtime = RuntimeCompositor(
            argument_composer.get_composed_arguments(), True, Constants.YUM)
        self.container = self.runtime.container

        package_filter = self.container.get('package_filter')
        self.assertIsNotNone(package_filter)

        # test for get_available_updates
        available_updates, package_versions = package_manager.get_available_updates(
            package_filter)
        self.assertIsNotNone(available_updates)
        self.assertIsNotNone(package_versions)
        self.assertEqual(len(available_updates), 4)
        self.assertEqual(len(package_versions), 4)
        self.assertEqual(available_updates[0], "selinux-policy.noarch")
        self.assertEqual(package_versions[0], "3.13.1-102.el7_3.16")
        self.assertEqual(available_updates[1],
                         "selinux-policy-targeted.noarch")
        self.assertEqual(package_versions[1], "3.13.1-102.el7_3.16")
        self.assertEqual(available_updates[2], "tar.x86_64")
        self.assertEqual(package_versions[2], "2:1.26-34.el7")
        self.assertEqual(available_updates[3], "tcpdump.x86_64")
        self.assertEqual(package_versions[3], "14:4.9.2-3.el7")