def _detect_transport_protocol(self, raw_protocol: bytes, empty_msg: str) -> TransportProtocol: try: protocol = TransportProtocol(raw_protocol) self._logger.debug(f"Detected transport protocol: {protocol} ({raw_protocol!r})") return protocol except ValueError: if raw_protocol: raise MKFetcherError(f"Unknown transport protocol: {raw_protocol!r}") raise MKFetcherError(empty_msg)
def test_decrypt_plaintext_is_noop(self, file_cache: DefaultAgentFileCache) -> None: settings = {"use_regular": "allow"} output = b"<<<section:sep(0)>>>\nbody\n" fetcher = TCPFetcher( file_cache, family=socket.AF_INET, address=("1.2.3.4", 0), host_name=HostName("irrelevant_for_this_test"), timeout=0.0, encryption_settings=settings, use_only_cache=False, ) assert fetcher._decrypt(TransportProtocol(output[:2]), AgentRawData(output[2:])) == output