import base64 import pytest import struct from winrm.encryption import Encryption from winrm.exceptions import WinRMError def test_init_with_invalid_protocol(): with pytest.raises(WinRMError) as excinfo: Encryption(None, 'invalid_protocol') assert "Encryption for protocol 'invalid_protocol' not supported in pywinrm" in str(excinfo.value) def test_encrypt_message(): test_session = SessionTest() test_message = b"unencrypted message" test_endpoint = b"endpoint" encryption = Encryption(test_session, 'ntlm') actual = encryption.prepare_encrypted_request(test_session, test_endpoint, test_message) expected_encrypted_message = b"dW5lbmNyeXB0ZWQgbWVzc2FnZQ==" expected_signature = b"1234" signature_length = struct.pack("