From cef7b5cf0526f4abf1a8e8adac756dbe2f3cd955 Mon Sep 17 00:00:00 2001 From: Nicoco K Date: Thu, 18 Feb 2021 20:05:25 +0100 Subject: Add registration to components --- tests/test_stream_xep_0077.py | 112 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 tests/test_stream_xep_0077.py (limited to 'tests') diff --git a/tests/test_stream_xep_0077.py b/tests/test_stream_xep_0077.py new file mode 100644 index 00000000..c47c4de5 --- /dev/null +++ b/tests/test_stream_xep_0077.py @@ -0,0 +1,112 @@ +""" +This only covers the component registration side of the XEP-0077 plugin +""" + +import unittest + +from slixmpp import ComponentXMPP, Iq +from slixmpp.xmlstream import register_stanza_plugin +from slixmpp.test import SlixTest +from slixmpp.plugins.xep_0077 import Register + + +class TestRegistration(SlixTest): + def setUp(self): + self.stream_start( + mode="component", plugins=["xep_0077"], jid="shakespeare.lit", server="lit" + ) + + def testRegistrationForm(self): + self.stream_start( + mode="component", plugins=["xep_0077"], jid="shakespeare.lit", server="lit" + ) + self.recv( + """ + + + + """, + ) + self.send( + f""" + + + {self.xmpp["xep_0077"].form_instructions} + + + + + """, + use_values=False # Fails inconsistently without this + ) + + def testRegistrationSuccessAndModif(self): + self.recv( + """ + + + bill + Calliope + + + """ + ) + self.send("") + user_store = self.xmpp["xep_0077"]._user_store + self.assertEqual(user_store["bill@server"]["username"], "bill") + self.assertEqual(user_store["bill@server"]["password"], "Calliope") + + self.recv( + """ + + + + """, + ) + self.send( + f""" + + + {self.xmpp["xep_0077"].form_instructions} + bill + Calliope + + + + """, + use_values=False # Fails inconsistently without this + ) + + def testRegistrationAndRemove(self): + self.recv( + """ + + + bill + Calliope + + + """ + ) + self.send("") + pseudo_iq = self.xmpp.Iq() + pseudo_iq["from"] = "bill@shakespeare.lit/globe" + user = self.xmpp["xep_0077"].api["user_get"](None, None, None, pseudo_iq) + self.assertEqual(user["username"], "bill") + self.assertEqual(user["password"], "Calliope") + self.recv( + """ + + + + + + """ + ) + self.send("") + user_store = self.xmpp["xep_0077"]._user_store + self.assertIs(user_store.get("bill@shakespeare.lit"), None) + + + +suite = unittest.TestLoader().loadTestsFromTestCase(TestRegistration) -- cgit v1.2.3