def test_unset_using_broken(monkeypatch, capsys): _monkeypatch_broken_keyring(monkeypatch) keyring.unset("abc", "FOO") (out, err) = capsys.readouterr() assert '' == out assert (expected_broken_message % "deleting") == err keyring.reset_keyring_module()
def test_unset_using_mock(monkeypatch): passwords = _monkeypatch_keyring(monkeypatch) keyring.set("abc", "FOO", "bar") assert "bar" == keyring.get("abc", "FOO") keyring.unset("abc", "FOO") assert keyring.get("abc", "FOO") is None assert dict(anaconda=dict()) == passwords keyring.reset_keyring_module()
def _unset_variable(project, env_prefix, varname, local_state): reqs = project.find_requirements(env_var=varname) if len(reqs) > 0: req = reqs[0] if req.encrypted: # import keyring locally because it's an optional dependency # that prints a warning when it's needed but not found. from anaconda_project.internal import keyring keyring.unset(env_prefix, varname) else: local_state.unset_value(['variables', varname])
def _set_encrypted_config_values_as_strings(self, requirement, environ, local_state_file, default_env_spec_name, overrides, values): # import keyring locally because it's an optional dependency # that prints a warning when it's needed but not found. import anaconda_project.internal.keyring as keyring env_prefix = self._get_env_prefix(environ) from_keyring = keyring.get(env_prefix, requirement.env_var) value_string = values.get('value', from_keyring) if value_string is not None: if value_string == '': keyring.unset(env_prefix, requirement.env_var) else: keyring.set(env_prefix, requirement.env_var, value_string)
def check(): keyring.set("abc", "FOO", "bar") assert "bar" == keyring.get("abc", "FOO") keyring.unset("abc", "FOO") assert keyring.get("abc", "FOO") is None