def test_multiple_auth(): authenticator = amps_kerberos_authenticator.create(SPN) client = AMPS.Client('KerberosTestPublisher') for _ in range(10): client.connect(URI) client.logon(10000, authenticator) client.close()
def test_undefined_spn(): error_thrown = False authenticator = amps_kerberos_authenticator.create('AMPS/foo.com') try: authenticator.authenticate(None, None) except Exception: error_thrown = True assert error_thrown
def test_multiple_auth_with_failure(): authenticator = amps_kerberos_authenticator.create(SPN) client = AMPS.Client('KerberosTestPublisher') for i in range(10): client.connect(URI) if i % 2 == 0: client.logon(10000, authenticator) client.close() else: try: client.logon() except AMPS.AuthenticationException: pass finally: client.close()
def test_publish(): authenticator = amps_kerberos_authenticator.create(SPN) client = AMPS.Client('KerberosTestPublisher') client.connect(URI) client.logon(10000, authenticator) client.publish('/topic', "{'foo': 'bar'}")
def test_obtain_token(): authenticator = amps_kerberos_authenticator.create(SPN) token = authenticator.authenticate(None, None) assert token assert token.startswith('YII')