mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Reset asyncauth singleton in tests
This commit is contained in:
parent
952d7244b5
commit
c6245c869e
@ -792,6 +792,13 @@ class AsyncAuth(SAuth):
|
||||
# This class is only a singleton per minion/master pair
|
||||
instances = {}
|
||||
|
||||
@classmethod
|
||||
def clear_singletons(cls):
|
||||
'''
|
||||
Method to forcibly clear all singletons. This should only be used for testing
|
||||
'''
|
||||
AsyncAuth.instances = {}
|
||||
|
||||
def __new__(cls, opts):
|
||||
'''
|
||||
Only create one instance of SAuth per __key()
|
||||
|
@ -151,10 +151,7 @@ class AsyncTCPReqChannel(salt.transport.client.ReqChannel):
|
||||
# communication, we do not subscribe to return events, we just
|
||||
# upload the results to the master
|
||||
if data:
|
||||
try:
|
||||
data = self.auth.crypticle.loads(data)
|
||||
except Exception as e:
|
||||
raise e
|
||||
raise tornado.gen.Return(data)
|
||||
if not self.auth.authenticated:
|
||||
yield self.auth.authenticate()
|
||||
@ -198,7 +195,8 @@ class AsyncTCPPubChannel(salt.transport.mixins.auth.AESPubClientMixin, salt.tran
|
||||
def connect(self):
|
||||
try:
|
||||
self.auth = salt.crypt.AsyncAuth(self.opts)
|
||||
creds = yield self.auth.authenticate()
|
||||
if not self.auth.authenticated:
|
||||
yield self.auth.authenticate()
|
||||
self.message_client = SaltMessageClient(self.opts['master_ip'],
|
||||
int(self.auth.creds['publish_port']),
|
||||
io_loop=self.io_loop)
|
||||
@ -355,7 +353,6 @@ class SaltMessageServer(tornado.tcpserver.TCPServer):
|
||||
self.clients.remove(item)
|
||||
|
||||
# TODO: singleton? Something to not re-create the tcp connection so much
|
||||
# TODO: cleanup send/recv queue stuff
|
||||
class SaltMessageClient(object):
|
||||
'''
|
||||
Low-level message sending client
|
||||
|
@ -11,6 +11,7 @@ import threading
|
||||
import tornado.ioloop
|
||||
from tornado.testing import AsyncTestCase
|
||||
|
||||
import salt.crypt
|
||||
import salt.config
|
||||
import salt.utils
|
||||
import salt.transport.server
|
||||
@ -114,6 +115,7 @@ class BaseTCPPubCase(AsyncTestCase):
|
||||
'''
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
salt.crypt.AsyncAuth.clear_singletons() # clear the singletons
|
||||
cls.master_opts = salt.config.master_config(get_config_file_path('master'))
|
||||
cls.master_opts.update({
|
||||
'transport': 'tcp',
|
||||
|
Loading…
Reference in New Issue
Block a user