Beispiel #1
0
 def test_hashable(self):
     """
     Test JID hashability.
     """
     j1 = jid.JID("user@host/resource")
     j2 = jid.JID("user@host/resource")
     self.assertEqual(hash(j1), hash(j2))
Beispiel #2
0
 def test_inequality(self):
     """
     Test JID inequality.
     """
     j1 = jid.JID("user1@host/resource")
     j2 = jid.JID("user2@host/resource")
     self.assertNotEqual(j1, j2)
Beispiel #3
0
 def test_equality(self):
     """
     Test JID equality.
     """
     j1 = jid.JID("user@host/resource")
     j2 = jid.JID("user@host/resource")
     self.assertNotIdentical(j1, j2)
     self.assertEqual(j1, j2)
 def test_sendHeaderInitiating(self):
     """
     Test addressing when initiating a stream.
     """
     xs = self.xmlstream
     xs.thisEntity = jid.JID('thisHost')
     xs.otherEntity = jid.JID('otherHost')
     xs.initiating = True
     xs.sendHeader()
     splitHeader = xs.transport.value()[0:-1].split(' ')
     self.assertIn("to='otherhost'", splitHeader)
     self.assertIn("from='thishost'", splitHeader)
Beispiel #5
0
 def test_userhostJID(self):
     """
     Test getting a JID object of the bare JID.
     """
     j1 = jid.JID("user@host/resource")
     j2 = jid.internJID("user@host")
     self.assertIdentical(j2, j1.userhostJID())
Beispiel #6
0
 def test_attributes(self):
     """
     Test that the attributes correspond with the JID parts.
     """
     j = jid.JID("user@host/resource")
     self.assertEquals(j.user, "user")
     self.assertEquals(j.host, "host")
     self.assertEquals(j.resource, "resource")
    def test_notAcceptableWithoutUser(self):
        """
        Test using an unacceptable SASL authentication mechanism with no JID.
        """
        self.authenticator.jid = jid.JID('example.com')
        self.authenticator.password = '******'

        self.assertRaises(sasl.SASLNoAcceptableMechanism, self._setMechanism,
                          'SOMETHING_UNACCEPTABLE')
    def test_plain(self):
        """
        Test setting PLAIN as the authentication mechanism.
        """
        self.authenticator.jid = jid.JID('*****@*****.**')
        self.authenticator.password = '******'
        name = "PLAIN"

        self.assertEqual(name, self._setMechanism(name))
    def test_digest(self):
        """
        Test setting DIGEST-MD5 as the authentication mechanism.
        """
        self.authenticator.jid = jid.JID('*****@*****.**')
        self.authenticator.password = '******'
        name = "DIGEST-MD5"

        self.assertEqual(name, self._setMechanism(name))
    def test_anonymous(self):
        """
        Test setting ANONYMOUS as the authentication mechanism.
        """
        self.authenticator.jid = jid.JID('example.com')
        self.authenticator.password = None
        name = "ANONYMOUS"

        self.assertEqual(name, self._setMechanism(name))
Beispiel #11
0
 def test_userhost(self):
     """
     Test the extraction of the bare JID.
     """
     j = jid.JID("user@host/resource")
     self.assertEquals("user@host", j.userhost())
Beispiel #12
0
 def test_userhostJIDNoResource(self):
     """
     Test getting a JID object of the bare JID when there was no resource.
     """
     j = jid.JID("user@host")
     self.assertIdentical(j, j.userhostJID())
Beispiel #13
0
 def test_repr(self):
     """
     Test representation of JID objects.
     """
     j = jid.JID(tuple=('user', 'host', 'resource'))
     self.assertEquals("JID(u'user@host/resource')", repr(j))
Beispiel #14
0
 def test_fullHost(self):
     """
     Test giving a string representation of the JID with only a host part.
     """
     j = jid.JID(tuple=(None, 'host', None))
     self.assertEqual('host', j.full())
Beispiel #15
0
 def test_fullHostResource(self):
     """
     Test giving a string representation of the JID with host, resource.
     """
     j = jid.JID(tuple=(None, 'host', 'resource'))
     self.assertEqual('host/resource', j.full())
Beispiel #16
0
 def test_unicode(self):
     """
     Test unicode representation of JIDs.
     """
     j = jid.JID(tuple=('user', 'host', 'resource'))
     self.assertEquals("user@host/resource", unicode(j))
Beispiel #17
0
 def test_inequalityWithNonJIDs(self):
     """
     Test JID equality.
     """
     j = jid.JID("user@host/resource")
     self.assertNotEqual(j, 'user@host/resource')
Beispiel #18
0
 def test_userhostOnlyHost(self):
     """
     Test the extraction of the bare JID of the full form host/resource.
     """
     j = jid.JID("host/resource")
     self.assertEquals("host", j.userhost())
Beispiel #19
0
 def test_equalityWithNonJIDs(self):
     """
     Test JID equality.
     """
     j = jid.JID("user@host/resource")
     self.assertFalse(j == 'user@host/resource')
Beispiel #20
0
 def test_fullUserHost(self):
     """
     Test giving a string representation of the JID with user, host.
     """
     j = jid.JID(tuple=('user', 'host', None))
     self.assertEqual('user@host', j.full())
Beispiel #21
0
 def test_fullAll(self):
     """
     Test giving a string representation of the JID.
     """
     j = jid.JID(tuple=('user', 'host', 'resource'))
     self.assertEqual('user@host/resource', j.full())