コード例 #1
0
 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)
コード例 #2
0
    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 == ""
コード例 #3
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
    def test_oubtound_pickle_fail(self):
        outbound = OutboundGroupSession()
        pickle = outbound.pickle("Test")

        with pytest.raises(OlmGroupSessionError):
            OutboundGroupSession.from_pickle(pickle)
コード例 #4
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
 def test_session_id(self):
     session = OutboundGroupSession()
     assert isinstance(session.id, str)
コード例 #5
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
 def test_id(self):
     outbound = OutboundGroupSession()
     inbound = InboundGroupSession(outbound.session_key)
     assert outbound.id == inbound.id
コード例 #6
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
 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"))
コード例 #7
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
 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"))
コード例 #8
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
 def test_session_create(self):
     OutboundGroupSession()
コード例 #9
0
 def test_first_index(self):
     outbound = OutboundGroupSession()
     inbound = InboundGroupSession(outbound.session_key)
     index = inbound.first_known_index
     assert isinstance(index, int)
コード例 #10
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
 def test_inbound_pickle(self):
     outbound = OutboundGroupSession()
     inbound = InboundGroupSession(outbound.session_key)
     pickle = inbound.pickle()
     InboundGroupSession.from_pickle(pickle)
コード例 #11
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
    def test_invalid_decrypt(self):
        outbound = OutboundGroupSession()
        inbound = InboundGroupSession(outbound.session_key)

        with pytest.raises(ValueError):
            inbound.decrypt("")
コード例 #12
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
 def test_inbound_create(self):
     outbound = OutboundGroupSession()
     InboundGroupSession(outbound.session_key)
コード例 #13
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
    def test_invalid_unpickle(self):
        with pytest.raises(ValueError):
            OutboundGroupSession.from_pickle(b"")

        with pytest.raises(ValueError):
            InboundGroupSession.from_pickle(b"")
コード例 #14
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
    def test_outbound_pickle(self):
        session = OutboundGroupSession()
        pickle = session.pickle()

        assert (session.id == OutboundGroupSession.from_pickle(pickle).id)
コード例 #15
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
 def test_session_index(self):
     session = OutboundGroupSession()
     assert isinstance(session.message_index, int)
     assert session.message_index == 0
コード例 #16
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
 def test_outbound_clear(self):
     session = OutboundGroupSession()
     del session
コード例 #17
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
 def test_inbound_clear(self):
     outbound = OutboundGroupSession()
     inbound = InboundGroupSession(outbound.session_key)
     del inbound
コード例 #18
0
ファイル: group_session_test.py プロジェクト: Zil0/python-olm
 def test_inbound_export(self):
     outbound = OutboundGroupSession()
     inbound = InboundGroupSession(outbound.session_key)
     imported = InboundGroupSession.import_session(
         inbound.export_session(inbound.first_known_index))
     assert "Test" == imported.decrypt(outbound.encrypt("Test"))