def __init__(self, config, vault_config, vault_creds, config_format=None, load_certs=False): """ Args: config{str} -- [File path to configuration or a string containing the configuration] (default: {'config.yaml'}) vault_config {str} -- [File path to configuration or a string containing the configuration] (default: {'vault.yaml'}) vault_creds {str} -- [File path to configuration or a string containing the configuration](default: {'vault.yaml'}) load_certs {bool} -- Automatically load certificate and key files during configuration (default: {False}) config_format {str} -- Specifies the parser to use when reading the configuration, only needed if reading a string. See the ac_parser option in python-anyconfig for available formats. Common ones are `json` and `yaml`. """ config_client = VaultAnyConfig(vault_config, ac_parser=config_format) config_client.auto_auth(vault_creds, ac_parser=config_format) if os.path.isfile(config): self.config = config_client.load(config, process_secret_files=load_certs) else: self.config = config_client.loads(config, process_secret_files=load_certs, ac_parser=config_format) # Elastic Search elastic_config = self.config["elastic"] self.connect_elastic(elastic_config) self.ES_INDEX = elastic_config["index"]
def main(): """ Main entrypoint """ args = parse_args(sys.argv[1:]) client = VaultAnyConfig(vault_config_in=args.vault_config) client.auto_auth(args.vault_creds) config = client.load(args.in_file, process_secret_files=args.secret_files_write, ac_parser=args.file_type) client.dump(config, args.out_file, process_secret_files=args.secret_files_write, ac_parser=args.file_type)
def test_auth_with_already_authenticated_and_passthrough( mock_is_authenticated): """ Tests that the auto_auth will simply be bypassed when using an instance with passthrough set and the client is already authenticated """ mock_is_authenticated.return_value = True client = VaultAnyConfig() assert client.auto_auth("config.json")
def test_auth_with_passthrough(): """ Tests that the auto_auth will simply be bypassed when using an instance with passthrough """ client = VaultAnyConfig() assert client.auto_auth("config.json")