Example #1
0
    def test_fail_destination_link_not_found(self):
        """["MATCH", "bar", "WITH", "MATERIALS", "FROM", "link-null"],
    destination link "link-null" not found, fails. """

        rule = ["MATCH", "bar", "WITH", "MATERIALS", "FROM", "link-null"]
        artifacts = {}
        queue = artifacts.keys()
        with self.assertRaises(RuleVerficationError):
            verify_match_rule(rule, queue, artifacts, self.links)
Example #2
0
    def test_fail_hash_not_eual(self):
        """"["MATCH", "bar", "WITH", "PRODUCTS", "FROM", "link-1"],
    source and destination bar have different hashes, fails. """

        rule = ["MATCH", "bar", "WITH", "PRODUCTS", "FROM", "link-1"]
        artifacts = {
            "bar": {
                "sha256": "aaaaaaaaaa"
            },
        }
        queue = artifacts.keys()
        with self.assertRaises(RuleVerficationError):
            verify_match_rule(rule, queue, artifacts, self.links)
Example #3
0
    def test_fail_path_not_in_destination_products(self):
        """["MATCH", "foo", "WITH", "PRODUCTS", "FROM", "link-1"],
    pattern foo does not match any products in destination, fails. """

        rule = ["MATCH", "foo", "WITH", "PRODUCTS", "FROM", "link-1"]
        artifacts = {
            "foo": {
                "sha256": self.sha256_foo
            },
        }
        queue = artifacts.keys()
        with self.assertRaises(RuleVerficationError):
            verify_match_rule(rule, queue, artifacts, self.links)
Example #4
0
    def test_fail_path_not_in_destination_materials(self):
        """["MATCH", "bar", "WITH", "MATERIALS", "FROM", "link-1"]
    pattern bar does not match any materials in destination, fails. """

        rule = ["MATCH", "bar", "WITH", "MATERIALS", "FROM", "link-1"]
        artifacts = {
            "bar": {
                "sha256": self.sha256_bar
            },
        }
        queue = artifacts.keys()
        with self.assertRaises(RuleVerficationError):
            verify_match_rule(rule, queue, artifacts, self.links)
Example #5
0
    def test_pass_match_product(self):
        """["MATCH", "bar", "WITH", "PRODUCTS", "FROM", "link-1"],
    source artifact bar and destination product bar hashes match, passes. """

        rule = ["MATCH", "bar", "WITH", "PRODUCTS", "FROM", "link-1"]
        artifacts = {
            "foo": {
                "sha256": self.sha256_foo
            },
            "bar": {
                "sha256": self.sha256_bar
            }
        }
        queue = artifacts.keys()
        self.assertListEqual(
            verify_match_rule(rule, queue, artifacts, self.links), ["foo"])
Example #6
0
    def test_pass_match_material(self):
        """["MATCH", "foo", "WITH", "MATERIALS", "FROM", "link-1"],
    source artifact foo and destination material foo hashes match, passes. """

        rule = ["MATCH", "foo", "WITH", "MATERIALS", "FROM", "link-1"]
        artifacts = {
            "foo": {
                "sha256": self.sha256_foo
            },
            "bar": {
                "sha256": self.sha256_bar
            }
        }
        queue = artifacts.keys()
        self.assertListEqual(
            verify_match_rule(rule, queue, artifacts, self.links), ["bar"])
Example #7
0
    def test_pass_match_star_with_products_destination_dir(self):
        """["MATCH", "bar*", "WITH", "PRODUCTS", "IN", "dev", "FROM", "link-1"],
    source artifacts bar* match destination products dev/bar* hashes, passes. """

        rule = [
            "MATCH", "bar*", "WITH", "PRODUCTS", "IN", "dev", "FROM", "link-1"
        ]
        artifacts = {
            "bar": {
                "sha256": self.sha256_bar
            },
            "barfoo": {
                "sha256": self.sha256_barfoo
            },
            "foo": {
                "sha256": self.sha256_foo
            }
        }
        queue = artifacts.keys()
        self.assertListEqual(
            verify_match_rule(rule, queue, artifacts, self.links), ["foo"])
Example #8
0
    def test_pass_match_star_in_with_materials_in_destination_dir(self):
        """["MATCH", "foo*", "WITH", "MATERIALS", "IN", "dist", "FROM", "link-1"],
    source artifacts foo* match destination materials dev/foo* hashes, passes. """

        rule = [
            "MATCH", "foo*", "WITH", "MATERIALS", "IN", "dev", "FROM", "link-1"
        ]
        artifacts = {
            "foo": {
                "sha256": self.sha256_foo
            },
            "foobar": {
                "sha256": self.sha256_foobar
            },
            "bar": {
                "sha256": self.sha256_bar
            }
        }
        queue = artifacts.keys()
        self.assertListEqual(
            verify_match_rule(rule, queue, artifacts, self.links), ["bar"])