You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2015/07/27 21:52:45 UTC
qpid-proton git commit: PROTON-923: New tests to test the events
emitted associated with SASL
Repository: qpid-proton
Updated Branches:
refs/heads/master 343d742f5 -> 236ee166e
PROTON-923: New tests to test the events emitted associated with SASL
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/236ee166
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/236ee166
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/236ee166
Branch: refs/heads/master
Commit: 236ee166e6a6770f48099fd4d5f38a64331cee40
Parents: 343d742
Author: Andrew Stitcher <as...@apache.org>
Authored: Mon Jul 27 15:51:09 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Mon Jul 27 15:51:09 2015 -0400
----------------------------------------------------------------------
tests/python/proton_tests/sasl.py | 115 +++++++++++++++++++++++++++++++--
1 file changed, 109 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/236ee166/tests/python/proton_tests/sasl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/sasl.py b/tests/python/proton_tests/sasl.py
index 9c8c38c..d24c11a 100644
--- a/tests/python/proton_tests/sasl.py
+++ b/tests/python/proton_tests/sasl.py
@@ -20,6 +20,7 @@ from __future__ import absolute_import
import sys, os
from . import common
+from . import engine
from proton import *
from .common import pump, Skipped
@@ -38,9 +39,10 @@ def _testSaslMech(self, mech, clientUser='user@proton', authUser='user@proton',
pump(self.t1, self.t2, 1024)
- if encrypted:
+ if encrypted is not None:
assert self.t2.encrypted == encrypted
assert self.t1.encrypted == encrypted
+
assert self.t2.authenticated == authenticated
assert self.t1.authenticated == authenticated
if authenticated:
@@ -293,7 +295,7 @@ class SaslTest(Test):
assert self.s1.outcome != SASL.OK
assert self.s2.outcome != SASL.OK
-class CyrusSASLTest(Test):
+class SASLMechTest(Test):
def setup(self):
self.t1 = Transport()
self.s1 = SASL(self.t1)
@@ -307,19 +309,19 @@ class CyrusSASLTest(Test):
self.c2 = Connection()
- def testMechANON(self):
+ def testANON(self):
self.t1.bind(self.c1)
self.t2.bind(self.c2)
_testSaslMech(self, 'ANONYMOUS', authUser='anonymous')
- def testMechCRAMMD5(self):
+ def testCRAMMD5(self):
common.ensureCanTestExtendedSASL()
self.t1.bind(self.c1)
self.t2.bind(self.c2)
_testSaslMech(self, 'CRAM-MD5')
- def testMechDIGESTMD5(self):
+ def testDIGESTMD5(self):
common.ensureCanTestExtendedSASL()
self.t1.bind(self.c1)
@@ -329,7 +331,7 @@ class CyrusSASLTest(Test):
# SCRAM not supported before Cyrus SASL 2.1.26
# so not universal and hance need a test for support
# to keep it in tests.
-# def testMechSCRAMSHA1(self):
+# def testSCRAMSHA1(self):
# common.ensureCanTestExtendedSASL()
#
# self.t1.bind(self.c1)
@@ -438,3 +440,104 @@ class SSLSASLTest(Test):
ssl2 = _sslConnection(self.server_domain, self.t2, self.c2)
_testSaslMech(self, mech, clientUser=None, authUser=None, encrypted=None, authenticated=False)
+
+class SASLEventTest(engine.CollectorTest):
+ def setup(self):
+ engine.CollectorTest.setup(self)
+ self.t1 = Transport()
+ self.s1 = SASL(self.t1)
+ self.t2 = Transport(Transport.SERVER)
+ self.s2 = SASL(self.t2)
+
+ self.c1 = Connection()
+ self.c1.user = 'user@proton'
+ self.c1.password = 'password'
+ self.c1.hostname = 'localhost'
+
+ self.c2 = Connection()
+
+ self.collector = Collector()
+
+ def testNormalAuthenticationClient(self):
+ self.c1.collect(self.collector)
+ self.t1.bind(self.c1)
+ self.t2.bind(self.c2)
+ _testSaslMech(self, 'DIGEST-MD5')
+ self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND,
+ Event.CONNECTION_LOCAL_OPEN, Event.TRANSPORT,
+ Event.CONNECTION_REMOTE_OPEN)
+
+ def testNormalAuthenticationServer(self):
+ self.c2.collect(self.collector)
+ self.t1.bind(self.c1)
+ self.t2.bind(self.c2)
+ _testSaslMech(self, 'DIGEST-MD5')
+ self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND,
+ Event.CONNECTION_LOCAL_OPEN, Event.TRANSPORT,
+ Event.CONNECTION_REMOTE_OPEN)
+
+ def testFailedAuthenticationClient(self):
+ clientUser = "usr@proton"
+ self.c1.user = clientUser
+ self.c1.collect(self.collector)
+ self.t1.bind(self.c1)
+ self.t2.bind(self.c2)
+ _testSaslMech(self, 'DIGEST-MD5', clientUser=clientUser, authenticated=False)
+ self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND,
+ Event.CONNECTION_LOCAL_OPEN, Event.TRANSPORT,
+ Event.TRANSPORT_TAIL_CLOSED,
+ Event.TRANSPORT_ERROR, Event.TRANSPORT_HEAD_CLOSED, Event.TRANSPORT_CLOSED)
+
+ def testFailedAuthenticationServer(self):
+ clientUser = "usr@proton"
+ self.c1.user = clientUser
+ self.c2.collect(self.collector)
+ self.t1.bind(self.c1)
+ self.t2.bind(self.c2)
+ _testSaslMech(self, 'DIGEST-MD5', clientUser=clientUser, authenticated=False)
+ self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND,
+ Event.CONNECTION_LOCAL_OPEN, Event.TRANSPORT,
+ Event.TRANSPORT_TAIL_CLOSED,
+ Event.TRANSPORT_ERROR, Event.TRANSPORT_HEAD_CLOSED, Event.TRANSPORT_CLOSED)
+
+ def testNoMechClient(self):
+ self.c1.collect(self.collector)
+ self.s2.allowed_mechs('IMPOSSIBLE')
+ self.t1.bind(self.c1)
+ self.t2.bind(self.c2)
+ _testSaslMech(self, 'DIGEST-MD5', authenticated=False)
+ self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND,
+ Event.CONNECTION_LOCAL_OPEN, Event.TRANSPORT,
+ Event.TRANSPORT_TAIL_CLOSED,
+ Event.TRANSPORT_ERROR, Event.TRANSPORT_HEAD_CLOSED, Event.TRANSPORT_CLOSED)
+
+ def testNoMechServer(self):
+ self.c2.collect(self.collector)
+ self.s2.allowed_mechs('IMPOSSIBLE')
+ self.t1.bind(self.c1)
+ self.t2.bind(self.c2)
+ _testSaslMech(self, 'DIGEST-MD5', authenticated=False)
+ self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND,
+ Event.CONNECTION_LOCAL_OPEN, Event.TRANSPORT,
+ Event.TRANSPORT_TAIL_CLOSED,
+ Event.TRANSPORT_ERROR, Event.TRANSPORT_HEAD_CLOSED, Event.TRANSPORT_CLOSED)
+
+ def testDisallowedMechClient(self):
+ self.c1.collect(self.collector)
+ self.t1.bind(self.c1)
+ self.t2.bind(self.c2)
+ _testSaslMech(self, 'IMPOSSIBLE', authenticated=False)
+ self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND,
+ Event.CONNECTION_LOCAL_OPEN, Event.TRANSPORT,
+ Event.TRANSPORT_TAIL_CLOSED,
+ Event.TRANSPORT_ERROR, Event.TRANSPORT_HEAD_CLOSED, Event.TRANSPORT_CLOSED)
+
+ def testDisallowedMechServer(self):
+ self.c2.collect(self.collector)
+ self.t1.bind(self.c1)
+ self.t2.bind(self.c2)
+ _testSaslMech(self, 'IMPOSSIBLE', authenticated=False)
+ self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND,
+ Event.CONNECTION_LOCAL_OPEN, Event.TRANSPORT,
+ Event.TRANSPORT_TAIL_CLOSED,
+ Event.TRANSPORT_ERROR, Event.TRANSPORT_HEAD_CLOSED, Event.TRANSPORT_CLOSED)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org