def test_extract( monkeypatch: pytest.MonkeyPatch, password_id: PasswordId, password_actual: str, ) -> None: monkeypatch.setattr(password_store, "load", load_patch) assert password_store.extract(password_id) == password_actual
def extract_connection_args(config): connection_args = { "protocol": config.get("protocol"), "verify-cert": config.get("verify-cert", False), } if "auth_basic" in config: auth_info = config["auth_basic"][1] if config["auth_basic"][0] == "auth_login": connection_args.update({ "auth": ( auth_info["username"], password_store.extract(auth_info["password"]), ) }) else: connection_args.update( {"token": password_store.extract(auth_info["token"])}) connect_type, connect_settings = config["connection"] if connect_type == "url_custom": connection_args.update({"url_custom": connect_settings["url_address"]}) return connection_args address = config[ "host_address"] if connect_type == "ip_address" else config["host_name"] if "path-prefix" in connect_settings: address = f"{connect_settings['path-prefix']}{address}" connection_args.update({ "address": address, "port": connect_settings.get("port") }) return connection_args
def __init__(self, config: Mapping[str, Any]) -> None: self._config = config self._credentials = config["credentials"] if self._credentials == "automation": self._username = self._credentials self._secret = (profile_dir / self._username / "automation.secret").read_text( encoding="utf-8" ) else: self._username, automation_secret = self._credentials[1] self._secret = extract(automation_secret) site_config = config["site"] if site_config == "local": self._site_url = "http://localhost:%d/%s" % ( cmk.utils.site.get_apache_port(), omd_site(), ) else: self._site_url = site_config[1]
def test_extract_from_unknown_valuespec() -> None: password_id = ("unknown", "unknown_pw") with pytest.raises(MKGeneralException) as excinfo: # We test for an invalid structure here password_store.extract(password_id) # type: ignore[arg-type] assert "Unknown password type." in str(excinfo.value)
def test_extract_from_unknown_valuespec(): password_id = ("unknown", "unknown_pw") with pytest.raises(MKGeneralException) as excinfo: password_store.extract(password_id) assert "Unknown password type." in str(excinfo.value)
def test_extract(monkeypatch, password_id, password_actual): monkeypatch.setattr(password_store, "load", load_patch) assert password_store.extract(password_id) == password_actual