Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def testJIDEscapeExistingSequences(self):
jid = JID(local='blah\\foo\\20bar', domain='example.com')
self.assertEqual(jid.local, 'blah\\foo\\5c20bar')
def testJIDInequality(self):
jid1 = JID('user@domain/resource')
jid2 = JID('otheruser@domain/resource')
self.assertFalse(jid1 == jid2, "Same JIDs are not considered equal")
self.assertTrue(jid1 != jid2, "Same JIDs are considered not equal")
def testDomainInvalidIPv6MissingBracket(self):
domain = '[::1'
jid1 = JID(domain=domain)
jid2 = JID('user@%s/resource' % domain)
self.assertEqual(jid1.domain, '[::1]')
self.assertEqual(jid2.domain, '[::1]')
def test1023LengthResource(self):
resource = 'r' * 1023
jid1 = JID(domain='test.com', resource=resource)
jid2 = JID('test.com/%s' % resource)
def testJIDFromFull(self):
"""Test using JID of the form 'user@server/resource/with/slashes'."""
self.check_jid(JID('user@someserver/some/resource'),
'user',
'someserver',
'some/resource',
'user@someserver',
'user@someserver/some/resource',
'user@someserver/some/resource')
def testDomainEmptyLabel(self):
domain = 'aaa..bbb.com'
self.assertRaises(InvalidJID, JID, domain=domain)
self.assertRaises(InvalidJID, JID, 'user@%s/resource' % domain)
def testJIDSetFullWithUser(self):
"""Test setting the full JID with a user portion."""
j = JID('user@domain/resource')
j.full = 'otheruser@otherdomain/otherresource'
self.check_jid(j,
'otheruser',
'otherdomain',
'otherresource',
'otheruser@otherdomain',
'otheruser@otherdomain/otherresource',
'otheruser@otherdomain/otherresource')
def test1023LengthDomain(self):
domain = ('a.' * 509) + 'a.com'
jid1 = JID(domain=domain)
jid2 = JID('user@%s/resource' % domain)
def testJIDBareUser(self):
"""Test setting the bare JID with a user."""
j = JID('user@domain/resource')
j.bare = 'otheruser@otherdomain'
self.check_jid(j,
'otheruser',
'otherdomain',
'resource',
'otheruser@otherdomain',
'otheruser@otherdomain/resource',
'otheruser@otherdomain/resource')
def testDomainIPv6(self):
domain = '[::1]'
jid1 = JID(domain=domain)
jid2 = JID('user@%s/resource' % domain)