~landscape/zope3/newer-from-ztk

« back to all changes in this revision

Viewing changes to src/twisted/words/test/test_jabbersasl.py

  • Committer: Thomas Hervé
  • Date: 2009-07-08 13:52:04 UTC
  • Revision ID: thomas@canonical.com-20090708135204-df5eesrthifpylf8
Remove twisted copy

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (c) 2001-2006 Twisted Matrix Laboratories.
2
 
# See LICENSE for details.
3
 
 
4
 
from twisted.internet import defer
5
 
from twisted.trial import unittest
6
 
from twisted.words.protocols.jabber import sasl, xmlstream
7
 
from twisted.words.xish import domish
8
 
 
9
 
class SASLInitiatingInitializerTest(unittest.TestCase):
10
 
 
11
 
    def testOnFailure(self):
12
 
        """
13
 
        Test that the SASL error condition is correctly extracted.
14
 
        """
15
 
        self.authenticator = xmlstream.Authenticator()
16
 
        self.xmlstream = xmlstream.XmlStream(self.authenticator)
17
 
        init = sasl.SASLInitiatingInitializer(self.xmlstream)
18
 
        failure = domish.Element(('urn:ietf:params:xml:ns:xmpp-sasl',
19
 
                                  'failure'))
20
 
        failure.addElement('not-authorized')
21
 
        init._deferred = defer.Deferred()
22
 
        init.onFailure(failure)
23
 
        self.assertFailure(init._deferred, sasl.SASLAuthError)
24
 
        init._deferred.addCallback(lambda e:
25
 
                                   self.assertEquals('not-authorized',
26
 
                                                     e.condition))
27
 
        return init._deferred