def test_prefix_callable(self):
        """vault_prefix can also be a callable that is called on each entry."""
        fake_environ = {"ABC_PW": "foo"}

        def extract(env):
            assert env == fake_environ
            return "ABC"

        vault = VaultEnvSecrets(vault_prefix=extract)

        @environ.config
        class Cfg(object):
            pw = vault.secret()

        cfg = environ.to_config(Cfg, fake_environ)

        assert _SecretStr("foo") == cfg.pw
Beispiel #2
0
def vault():
    return VaultEnvSecrets(vault_prefix="SECRET")