def test_single_jar_with_two_unique_class(self): classes_dir = self._create_fake_class("MyClass.class", "classes", "com/salesforce", FAKE_CONT1) classes_dir = self._create_fake_class("MyClass2.class", "classes", "com/salesforce", FAKE_CONT2) jar_file = self._create_jar("myjar.jar", classes_dir) self._run("jar tf %s" % jar_file) index_file_path = self._write_index_file([jar_file]) verify_conflict.run(index_file_path, ALLOWLIST_PATH)
def test_two_jars_with_duplicate_class_allowlisted__different_content( self): classes_dir1 = self._create_fake_class("MyClass.class", "classes1", "com/salesforce", FAKE_CONT1) classes_dir2 = self._create_fake_class("MyClass.class", "classes2", "com/salesforce", FAKE_CONT2) jar_file1 = self._create_jar("myjar20.jar", classes_dir1) jar_file2 = self._create_jar("myjar21.jar", classes_dir2) index_file_path = self._write_index_file([jar_file1, jar_file2]) verify_conflict.run(index_file_path, ALLOWLIST_PATH)
def test_two_jars_with_duplicate_class__different_content(self): classes_dir1 = self._create_fake_class("MyClass.class", "classes1", "com/salesforce", FAKE_CONT1) classes_dir2 = self._create_fake_class("MyClass.class", "classes2", "com/salesforce", FAKE_CONT2) jar_file1 = self._create_jar("myjar1.jar", classes_dir1) jar_file2 = self._create_jar("myjar2.jar", classes_dir2) index_file_path = self._write_index_file([jar_file1, jar_file2]) with self.assertRaises(Exception) as ctx: verify_conflict.run(index_file_path, ALLOWLIST_PATH) self.assertIn("Found duplicate classes", str(ctx.exception))
def test_two_jars_with_duplicate_class__same_content(self): classes_dir1 = self._create_fake_class("MyClass.class", "classes1", "com/salesforce", FAKE_CONT1) # make the jar more interesting: add another class self._create_fake_class("MyClass2.class", "classes1", "com/salesforce", FAKE_CONT2) classes_dir2 = self._create_fake_class("MyClass.class", "classes2", "com/salesforce", FAKE_CONT1) jar_file1 = self._create_jar("myjar1.jar", classes_dir1) jar_file2 = self._create_jar("myjar2.jar", classes_dir2) index_file_path = self._write_index_file([jar_file1, jar_file2]) verify_conflict.run(index_file_path, ALLOWLIST_PATH)