def validate_pack_unique_files(self, packs): for pack in packs: pack_unique_files_validator = PackUniqueFilesValidator(pack) pack_errors = pack_unique_files_validator.validate_pack_unique_files() if pack_errors: print_error(pack_errors) self._is_valid = False
def validate_pack_unique_files(self, pack_path: str, pack_error_ignore_list: dict, should_version_raise=False) -> bool: """ Runs validations on the following pack files: * .secret-ignore: Validates that the file exist and that the file's secrets can be parsed as a list delimited by '\n' * .pack-ignore: Validates that the file exists and that all regexes in it can be compiled * README.md file: Validates that the file exists * pack_metadata.json: Validates that the file exists and that it has a valid structure Args: should_version_raise: Whether we should check if the version of the metadata was raised pack_error_ignore_list: A dictionary of all pack ignored errors pack_path: A path to a pack """ print(f'\nValidating {pack_path} unique pack files') pack_unique_files_validator = PackUniqueFilesValidator(pack=os.path.basename(pack_path), pack_path=pack_path, ignored_errors=pack_error_ignore_list, print_as_warnings=self.print_ignored_errors, should_version_raise=should_version_raise) pack_errors = pack_unique_files_validator.validate_pack_unique_files() if pack_errors: click.secho(pack_errors, fg="bright_red") return False return True
def validate_pack_unique_files(self, packs: set) -> None: """ Runs validations on the following pack files: * .secret-ignore: Validates that the file exist and that the file's secrets can be parsed as a list delimited by '\n' * .pack-ignore: Validates that the file exists and that all regexes in it can be compiled * README.md file: Validates that the file exists * pack_metadata.json: Validates that the file exists and that it has a valid structure Args: packs: A set of pack paths i.e {Packs/<pack-name1>, Packs/<pack-name2>} """ for pack in packs: print(f'Validating {pack} unique pack files') pack_unique_files_validator = PackUniqueFilesValidator(pack) pack_errors = pack_unique_files_validator.validate_pack_unique_files( ) if pack_errors: print_error(pack_errors) self._is_valid = False
def test_validate_pack_metadata(self, mocker): mocker.patch.object(BaseValidator, 'check_file_flags', return_value='') assert not self.validator.validate_pack_unique_files() fake_validator = PackUniqueFilesValidator('fake') assert fake_validator.validate_pack_unique_files()
def test_validate_pack_metadata(self): assert not self.validator.validate_pack_unique_files() fake_validator = PackUniqueFilesValidator('fake') assert fake_validator.validate_pack_unique_files()