def test_unknown_mechansim(self): supportedMechs = ["not_a_mech"] mech = get_sasl_mechanism(supportedMechs, "myuser", "mypass", namespace="qpid.tests.saslmech") self.assertTrue(mech == None, "Mechanism instance should be none")
def test_sasl_mechanism_with_higher_priority_prefered(self): supportedMechs = ["MY-SASL", "MY-SASL2"] mech = get_sasl_mechanism(supportedMechs, "myuser", "mypass", namespace="qpid.tests.saslmech") self.assertTrue(isinstance(mech, MY_SASL), "Mechanism %s is of unexpected type" % mech)
def test_sasl_mechanism_fallback_without_credentials(self): # MY-SASL requires username/password, MY-SASL2 does not supportedMechs = ["MY-SASL", "MY-SASL2"] mech = get_sasl_mechanism(supportedMechs, None, None, namespace="qpid.tests.saslmech") self.assertTrue(isinstance(mech, MY_SASL2), "Mechanism %s is of unexpected type" % mech)
def test_sasl_mechansim_options(self): supportedMechs = ["MY-SASL"] sasl_options = {'hello': 'world'} mech = get_sasl_mechanism(supportedMechs, "myuser", "mypass", namespace="qpid.tests.saslmech", sasl_options=sasl_options) self.assertTrue(isinstance(mech, MY_SASL), "Mechanism %s is of unexpected type" % mech) self.assertEquals(sasl_options, mech.sasl_options)
def test_known_mechansim(self): supportedMechs = ["MY-SASL"] mech = get_sasl_mechanism(supportedMechs, "myuser", "mypass", namespace="qpid.tests.saslmech") self.assertTrue(isinstance(mech, MY_SASL), "Mechanism %s is of unexpected type" % mech) self.assertEquals("MY-SASL", mech.mechanismName()) self.assertTrue(mech.sasl_options is None)