Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: third_party/twisted_8_1/twisted/words/test/test_jabbersaslmechanisms.py

Issue 12261012: Remove third_party/twisted_8_1 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2001-2007 Twisted Matrix Laboratories.
2 # See LICENSE for details.
3
4 """
5 Tests for L{twisted.words.protocols.jabber.sasl_mechanisms}.
6 """
7
8 from twisted.trial import unittest
9
10 from twisted.words.protocols.jabber import sasl_mechanisms
11
12 class PlainTest(unittest.TestCase):
13 def test_getInitialResponse(self):
14 """
15 Test the initial response.
16 """
17 m = sasl_mechanisms.Plain(None, 'test', 'secret')
18 self.assertEquals(m.getInitialResponse(), '\x00test\x00secret')
19
20 class DigestMD5Test(unittest.TestCase):
21 def setUp(self):
22 self.mechanism = sasl_mechanisms.DigestMD5('xmpp', 'example.org', None,
23 'test', 'secret')
24
25
26 def test_getInitialResponse(self):
27 """
28 Test that no initial response is generated.
29 """
30 self.assertIdentical(self.mechanism.getInitialResponse(), None)
31
32 def test_getResponse(self):
33 """
34 Partially test challenge response.
35
36 Does not actually test the response-value, yet.
37 """
38
39 challenge = 'realm="localhost",nonce="1234",qop="auth",charset=utf-8,alg orithm=md5-sess'
40 directives = self.mechanism._parse(self.mechanism.getResponse(challenge) )
41 self.assertEqual(directives['username'], 'test')
42 self.assertEqual(directives['nonce'], '1234')
43 self.assertEqual(directives['nc'], '00000001')
44 self.assertEqual(directives['qop'], ['auth'])
45 self.assertEqual(directives['charset'], 'utf-8')
46 self.assertEqual(directives['digest-uri'], 'xmpp/example.org')
47 self.assertEqual(directives['realm'], 'localhost')
48
49 def test_getResponseNoRealm(self):
50 """
51 Test that we accept challenges without realm.
52
53 The realm should default to the host part of the JID.
54 """
55
56 challenge = 'nonce="1234",qop="auth",charset=utf-8,algorithm=md5-sess'
57 directives = self.mechanism._parse(self.mechanism.getResponse(challenge) )
58 self.assertEqual(directives['realm'], 'example.org')
59
60 def test__parse(self):
61 """
62 Test challenge decoding.
63
64 Specifically, check for multiple values for the C{qop} and C{cipher}
65 directives.
66 """
67 challenge = 'nonce="1234",qop="auth,auth-conf",charset=utf-8,' \
68 'algorithm=md5-sess,cipher="des,3des"'
69 directives = self.mechanism._parse(challenge)
70 self.assertEqual('1234', directives['nonce'])
71 self.assertEqual('utf-8', directives['charset'])
72 self.assertIn('auth', directives['qop'])
73 self.assertIn('auth-conf', directives['qop'])
74 self.assertIn('des', directives['cipher'])
75 self.assertIn('3des', directives['cipher'])
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698