def test_invalid_unicode_decrypt(self): outbound = OutboundGroupSession() inbound = InboundGroupSession(outbound.session_key) text = outbound.encrypt(b"\xed") plaintext, _ = inbound.decrypt(text) print(plaintext) assert plaintext == u"�" plaintext, _ = inbound.decrypt(text, "ignore") assert plaintext == ""
def test_decrypt_twice(self): outbound = OutboundGroupSession() inbound = InboundGroupSession(outbound.session_key) outbound.encrypt("Test 1") message, index = inbound.decrypt(outbound.encrypt("Test 2")) assert isinstance(index, int) assert ("Test 2", 1) == (message, index)
def test_decrypt_failure(self): outbound = OutboundGroupSession() inbound = InboundGroupSession(outbound.session_key) eve_outbound = OutboundGroupSession() with pytest.raises(OlmGroupSessionError): inbound.decrypt(eve_outbound.encrypt("Test"))
def test_decrypt(self, benchmark): benchmark.weave(InboundGroupSession.decrypt, lazy=True) outbound = OutboundGroupSession() inbound = InboundGroupSession(outbound.session_key) assert "Test" == inbound.decrypt(outbound.encrypt("Test"))
def test_invalid_decrypt(self): outbound = OutboundGroupSession() inbound = InboundGroupSession(outbound.session_key) with pytest.raises(ValueError): inbound.decrypt("")