How to use get_remote_client method in tempest

Best Python code snippet using tempest_python

white_list.py

Source:white_list.py Github

copy

Full Screen

...23from swift.common.swob import Request, HTTPForbidden24from swift.common.utils import get_logger252627def get_remote_client(req):28 # remote host for zeus29 client = req.headers.get('x-cluster-client-ip')30 if not client and 'x-forwarded-for' in req.headers:31 # remote host for other lbs32 client = req.headers['x-forwarded-for'].split(',')[0].strip()33 if not client:34 client = req.remote_addr3536 # if client ip with port, delete port37 if client is not None and len(client) > 6:38 length = len(client)39 pos = client.rfind(":", length - 6, length)40 if pos > 0:41 client = client[:pos]42 return client434445def ip_check(ip):46 if ip is None:47 return False48 q = ip.split('.')49 return len(q) == 4 and len(filter(lambda x: x >= 0 and x <= 255, \50 map(int, filter(lambda x: x.isdigit(), q)))) == 4515253class WhiteListMiddleware(object):54 def __init__(self, app, conf):55 self.app = app56 self.conf = conf57 if conf is None:58 self.conf = {}59 self.white_list_file = self.conf.get('white_list_file', '/etc/swift/white_list')60 self.white_list = None61 self.logger = get_logger(self.conf, log_route='proxy-server')6263 self._parse_config_file()6465 def __call__(self, env, start_response):66 req = Request(env)67 remote_addr = get_remote_client(req)68 if remote_addr is not None:69 if self.white_list.get(remote_addr, None) is None:70 return HTTPForbidden(request=req)71 return self.app(env, start_response)7273 def allow(self, env):74 if self.white_list is not None:75 req = Request(env)76 remote_addr = get_remote_client(req)77 if self.white_list.get(remote_addr, None) is not None:78 return True79 return False8081 def is_valid(self):82 return True if self.white_list is not None else False8384 def _parse_config_file(self):85 if not os.path.isfile(self.white_list_file):86 self.white_list = None87 self.logger.info("WhiteListMiddleware: white list file not exist, use default authentication")88 return8990 try: ...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...5from pykeval.frontend import Client6def get_local_client(*args, **kwargs):7 broker = pykeval.broker.LocalBroker(*args, **kwargs)8 return Client(broker)9def get_remote_client(*args, **kwargs):10 broker = pykeval.broker.RemoteBroker(*args, **kwargs)11 return Client(broker)12def start_interactive_shell():13 pykeval.log.setup_root_logger()14 embed(header="\n".join((15 "Welcome to Keval's interactive client shell!",16 "",17 "To get a client, you can use:",18 "* `get_local_client()`: If the driver is running on this machine",19 "* `get_remote_client()`: If you want to connect to a remote machine " # Note: no comma continues line20 "(also see the console command `keval-server`)"...

Full Screen

Full Screen

xmanager_client.py

Source:xmanager_client.py Github

copy

Full Screen

...3 from xmanager.xmanager.server import XManagerServer4except ImportError:5 from xmanager.server import XManagerServer6def get_xmanager_client(*args, **kwargs):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful