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)
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)
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)
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)
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"])
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"])
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"])
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"])