def test_set_omemo_user(self): account = '*****@*****.**' fulljid = '[email protected]/profanity' ProfOmemoUser().account is None ProfOmemoUser().fulljid is None ProfOmemoUser.set_user(account, fulljid) ProfOmemoUser().account == account ProfOmemoUser().fulljid == fulljid
def test_omemo_state_returns_singleton(self, mockdb): mockdb.return_value = get_test_db_connection() account = '*****@*****.**' fulljid = '[email protected]/profanity' ProfOmemoUser.set_user(account, fulljid) state = ProfOmemoState() new_state = ProfOmemoState() assert state == new_state
def test_encrypt_stanza(self, mockdb): pytest.skip('Work in Progress') mockdb.return_value = get_test_db_connection() current_user = '******' ProfOmemoUser.set_user(current_user, current_user + '/profanity') recipient = '*****@*****.**' omemo_state = ProfOmemoState() omemo_state.set_devices(recipient, [4711, 995746]) raw_stanza = ('<message id="msg0x001" to="{0}" type="chat">' '<body>Hollo</body>' '<active xmlns="http://jabber.org/protocol/chatstates"/>' '</message>').format(recipient) encrypted = xmpp.encrypt_stanza(raw_stanza)
def prof_init(version, status, account_name, fulljid): log.info('prof_init() called') synopsis = [ '/omemo', '/omemo on|off', '/omemo start|end [jid]', '/omemo set' '/omemo status', '/omemo account', '/omemo fulljid', '/omemo fingerprints', '/omemo show_devices', '/omemo reset_devicelist' ] description = 'Plugin to enable OMEMO encryption' args = [ ['on|off', 'Enable/Disable the Profanity OMEMO Plugin'], ['start|end <jid>', ('Start an OMEMO based conversation with <jid> ' 'window or current window.')], ['set', 'Set Settings like Message Prefix'], ['status', 'Display the current Profanity OMEMO Plugin status.'], ['fingerprints <jid>', 'Display the known fingerprints for <jid>'], ['account', 'Show current account name'], ['reset_devicelist <jid>', 'Manually reset a contacts devicelist.'], ['fulljid', 'Show current <full-jid>'] ] examples = [] # ensure the plugin is not registered if python-omemo is not available prof.register_command('/omemo', 1, 3, synopsis, description, args, examples, _parse_args) prof.completer_add('/omemo', ['on', 'off', 'status', 'start', 'end', 'set' 'account', 'fulljid', 'show_devices', 'reset_devicelist', 'fingerprints']) prof.completer_add('/omemo set', ['message_prefix']) # set user and init omemo only if account_name and fulljid provided if account_name is not None and fulljid is not None: ProfOmemoUser.set_user(account_name, fulljid) _init_omemo() else: log.warning('No User logged in on plugin.prof_init()')
def test_encrypt_stanza(self, mockdb): pytest.skip('Work in Progress') mockdb.return_value = get_test_db_connection() current_user = '******' ProfOmemoUser.set_user(current_user, current_user + '/profanity') recipient = '*****@*****.**' omemo_state = ProfOmemoState() omemo_state.set_devices(recipient, [4711, 995746]) raw_stanza = ('<message id="msg0x001" to="{0}" type="chat">' '<body>Hollo</body>' '<active xmlns="http://jabber.org/protocol/chatstates"/>' '</message>' ).format(recipient) encrypted = xmpp.encrypt_stanza(raw_stanza)
def test_unpack_devicelist_request_result_for_own_devices(self, mockdb): mockdb.return_value = get_test_db_connection() test_stanza = ( '<iq id="0x011" to="[email protected]/profanity" type="result">' '<pubsub xmlns="http://jabber.org/protocol/pubsub">' '<items node="{0}">' '<item id="1">' '<list xmlns="{1}">' '<device id="1426586702"/>' '</list>' '</item>' '</items>' '</pubsub>' '</iq>').format(NS_DEVICE_LIST, NS_OMEMO) current_user = '******' ProfOmemoUser.set_user(current_user, current_user + '/profanity') msg_dict = xmpp.unpack_devicelist_info(test_stanza) expected_msg_dict = {'from': current_user, 'devices': [1426586702]} assert msg_dict == expected_msg_dict
def test_unpack_devicelist_request_result_for_own_devices(self, mockdb): mockdb.return_value = get_test_db_connection() test_stanza = ('<iq id="0x011" to="[email protected]/profanity" type="result">' '<pubsub xmlns="http://jabber.org/protocol/pubsub">' '<items node="{0}">' '<item id="1">' '<list xmlns="{1}">' '<device id="1426586702"/>' '</list>' '</item>' '</items>' '</pubsub>' '</iq>' ).format(NS_DEVICE_LIST, NS_OMEMO) current_user = '******' ProfOmemoUser.set_user(current_user, current_user + '/profanity') msg_dict = xmpp.unpack_devicelist_info(test_stanza) expected_msg_dict = {'from': current_user, 'devices': [1426586702]} assert msg_dict == expected_msg_dict
def setup_method(self, test_method): account = '*****@*****.**' fulljid = '[email protected]/profanity' ProfOmemoUser.set_user(account, fulljid)
def prof_on_connect(account_name, fulljid): log.debug('prof_on_connect() called') ProfOmemoUser.set_user(account_name, fulljid) _init_omemo()