def test_get_agent_data_without_tls(self, monkeypatch: MonkeyPatch, fetcher: TCPFetcher) -> None: mock_sock = _MockSock(b"<<<section:sep(0)>>>\nbody\n") monkeypatch.setattr(fetcher, "_opt_socket", mock_sock) agent_data, protocol = fetcher._get_agent_data() assert agent_data == mock_sock.data[2:] assert protocol == TransportProtocol.PLAIN
def test_get_agent_data_with_tls(self, monkeypatch: MonkeyPatch, fetcher: TCPFetcher) -> None: mock_data = b"<<<section:sep(0)>>>\nbody\n" mock_sock = _MockSock(b"16%b%b%b" % ( bytes(Version.V1), bytes(HeaderV1(CompressionType.ZLIB)), compress(mock_data), )) monkeypatch.setattr(fetcher, "_opt_socket", mock_sock) monkeypatch.setattr(fetcher, "_wrap_tls", lambda: mock_sock) agent_data, protocol = fetcher._get_agent_data() assert agent_data == mock_data[2:] assert protocol == TransportProtocol.PLAIN