How to use handle_external method in avocado

Best Python code snippet using avocado_python

nginx.py

Source:nginx.py Github

copy

Full Screen

...89 "Auth-Wait": 090 }91 elif auth_method == "external":92 is_authenticated = False93 is_authenticated = handle_external(headers) 94 server, port = get_server(auth_protocol, True)95 if is_authenticated:96 return {97 "Auth-Status": "OK",98 "Auth-Server": server,99 "Auth-Port": port100 }101 else:102 request_status, request_code = get_status(auth_protocol, "authentication")103 return {104 "Auth-Status": request_status,105 "Auth-Error-Code": request_code,106 "Auth-Wait": 0107 }108 else:109 # Unexpected110 return {}111def parse_credentials(headers):112 """ According to RFC2616 section 3.7.1 and PEP 3333, HTTP headers should113 be ASCII and are generally considered ISO8859-1. However when passing114 the password, nginx does not transcode the input UTF string, thus115 we need to manually decode.116 """117 118 raw_user_email = urllib.parse.unquote(headers["Auth-User"])119 user_email = raw_user_email.encode("iso8859-1").decode("utf8")120 raw_password = urllib.parse.unquote(headers["Auth-Pass"])121 password = raw_password.encode("iso8859-1").decode("utf8")122 ip = urllib.parse.unquote(headers["Client-Ip"])123 124 return user_email, password, ip125def handle_external(headers):126 """ Handle an HTTPS external authentication request127 https://tools.ietf.org/html/rfc4422128 """129 130 # process headers131 # call external authentication daemon/connector script132 # Not implemented133 return {}134def get_status(protocol, status):135 """ Return the proper error code depending on the protocol136 """137 138 status, codes = PROTOCOL_STATUSES[status]139 return status, codes[protocol]...

Full Screen

Full Screen

toplevel.py

Source:toplevel.py Github

copy

Full Screen

1from app.general.tkinter_imports import *2from app.general.functions import purge_plan_name3from app.general.constants import *4from app.data.NodeData import *5from app.widgets import canvas6from app.Config import Config7from app.network.access_points import AccessPointList8# std9from xml.etree import ElementTree10from os.path import splitext, relpath11import sqlite312class ExternalNodeFinder:13 @staticmethod14 def find(tkinter_master, plan_path, database):15 top = t.Toplevel(tkinter_master)16 top.title('Select the node to link with current one')17 cv = canvas.SelectableGraphCanvas(top, database, width=500, height=500)18 cv.load_plan(plan_path)19 #cv.load_xml(plan_path)20 cv.pack(fill='both', expand='yes')21 top.wait_window()22 return cv.selected_node_name()23class NodeConfigurationToplevel(t.Toplevel):24 def __init__(self, master, plan, database, node_id='', node_aliases=tuple(), handle_external=False):25 super().__init__(master)26 self.database = database27 self.master = master28 self.plan_name = plan29 self.node_data = NodeData(node_id, node_aliases)30 self.handle_external_edges = handle_external31 self.init_variables()32 self.create_widgets()33 # Add first plan34 self.wm_attributes("-topmost", 1)35 self.focus_force()36 #@TODO Use this when improving code37 def init_variables(self):38 # start at -1 so that increment makes it start from 039 self.row = -140 def create_widgets(self):41 # Do not show main window, only let this toplevel42 #self.master.master.master.withdraw()43 self.create_widgets_aliases()44 if self.handle_external_edges:45 self.create_widgets_external_edges()46 self.create_widgets_validation()47 def create_widgets_aliases(self):48 self.aliases = list(self.node_data.aliases)49 # Information about node50 if(self.node_data.name != ""):51 print("Information about node: " + str(self.node_data.name))52 nodeInfo = t.Label(self, text="Node: " + str(self.node_data.name))53 nodeInfo.grid(row=0, column=0, columnspan=2)54 # Aliases55 self.aliases_group = t.LabelFrame(self, text='Aliases Management', padx=5, pady=5, relief=t.SUNKEN, borderwidth=3)56 self.aliases_group.grid(row=1, column=0, columnspan=2)57 self.lb = t.Listbox(self.aliases_group, listvar=self.aliases)58 self.lb.grid(row=1, column=0, rowspan=3)59 self.lb.delete(0, t.END)60 for alias in self.aliases:61 self.lb.insert(t.END, alias)62 self.alias = t.StringVar()63 entry = t.Entry(self.aliases_group, textvariable=self.alias)64 entry.grid(row=1, column=1)65 entry.focus_set()66 t.Button(self.aliases_group, text='Add alias', command=self.add_alias).grid(row=2, column=1)67 t.Button(self.aliases_group, text='Remove alias', command=self.delete_alias).grid(row=3, column=1)68 def add_alias(self):69 alias = self.alias.get()70 if alias == '':71 return72 self.lb.insert(t.END, alias)73 self.aliases.append(alias)74 def delete_alias(self):75 for sel in self.lb.curselection():76 del self.aliases[sel]77 self.lb.delete(t.ANCHOR)78 def create_widgets_external_edges(self):79 # External edges80 self.ext_edges_group = t.LabelFrame(self, text='External edges', padx=5, pady=5, relief=t.SUNKEN, borderwidth=3)81 self.ext_edges_group.grid(row=4, column=0, columnspan=2, rowspan=3)82 # This list contains all the external edges going out of the current_node83 self.ext_edges = list()84 self.ext_edges_lb = t.Listbox(self.ext_edges_group, listvar=self.ext_edges)85 already_existing_external_edges = self.database.load_external_edges_from_node(self.node_data.name)86 for edge in already_existing_external_edges:87 other_id = edge[1] if edge[2] == self.node_data.name else edge[2]88 plan = self.database.get_plan_name_from_node(other_id)89 self.ext_edges_lb.insert(t.END, plan + EXTERNAL_EDGES_SEPARATOR + str(other_id))90 self.ext_edges_lb.grid(row=5, column=0, rowspan=2)91 t.Button(self.ext_edges_group, text='Add external edge \nfrom this node',92 command=self.get_external_node).grid(row=5, column=1)93 t.Button(self.ext_edges_group, text='Remove external edge',94 command=self.remove_ext_edge).grid(row=6, column=1)95 # Display at the end to have the correct row number96 def create_widgets_validation(self):97 # Validation & scans98 t.Button(self, text='Ok', command=self.destroy).grid(row=7, column=0)99 self.ap = None100 t.Button(self, text='Scan access points', command=self.scan).grid(row=7, column=1)101 def get_current_row(self):102 self.row += 1103 return self.row104 def remove_ext_edge(self):105 for sel in self.ext_edges_lb.curselection():106 print(sel)107 # remove edge from db108 str_edge = self.ext_edges_lb.get(sel)109 other_node_id = int(str_edge.split(EXTERNAL_EDGES_SEPARATOR)[1])110 self.database.remove_edge_by_nodes(other_node_id, self.node_data.name)111 # remove edge from listbox112 del self.ext_edges[sel]113 self.ext_edges_lb.delete(t.ANCHOR)114 def configure(self):115 self.wait_window()116 self.master.master.master.deiconify()117 ap = self.ap118 aliases = list(set(self.aliases))119 return list() if ap is None else ap, aliases120 def get_external_node(self):121 name = self.node_data.name122 # ask plan (PNG)123 plan_path = t.filedialog.askopenfilename(initialdir=Config.MAPS_PATH,124 filetypes=[('PNG Files', '.png')])125 if plan_path == '' or plan_path is None:126 print('ERROR') # TODO: handle properly with a popup127 return128 try:129 node_name = ExternalNodeFinder.find(self, plan_path, self.database)130 plan_short_name = purge_plan_name(plan_path, Config.MAPS_PATH)131 edge = canvas.ExternalEdge([node_name, name], plan_short_name)132 # add edge to db133 self.database.save_edge(edge)134 self.ext_edges.append(edge)135 str_to_add = plan_short_name + EXTERNAL_EDGES_SEPARATOR + str(node_name)136 self.ext_edges_lb.insert(t.END, str_to_add)137 except sqlite3.IntegrityError as e:138 print('SQLite error:', e)139 def scan(self):140 self.wm_title('Scanning access points...')141 self.ap = AccessPointList(iterations=5)142 self.ap.scan()...

Full Screen

Full Screen

kanshi.py

Source:kanshi.py Github

copy

Full Screen

...6 print("Dual head active")7def handle_internal(internal):8 print("Internal only")9 10def handle_external(external):11 print("External only")12def get_output(outputs, name):13 for output in outputs:14 if output["name"] == name and output["active"]:15 return output16 return None17def detect_screens():18 outputs_json = "".join(os.popen("swaymsg -r -t get_outputs").readlines())19 outputs = json.loads(outputs_json)20 internal_screen = get_output(outputs, "eDP-1")21 external_screen = get_output(outputs, "DP-1")22 if internal_screen and external_screen:23 return handle_dualhead(internal_screen, external_screen)24 if internal_screen:25 return handle_internal(internal_screen)26 27 if external_screen:28 return handle_external(external_screen)29 30 print("No known screens")...

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 avocado 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