def web_app_login(self, email): try: socketio.emit('open', "Opening web app...") # first login try add_running_account(email) self.driver = create_driver_instance(email) self.element_actions = ElementActions(self.driver) existing_account = check_account_if_exists(email) if existing_account["cookies"]: self.login_with_cookies(existing_account["cookies"]) else: self.login_first_time() return self._launch() except TimeoutException as e: close_driver(email) return server_response( code=503, msg=server_status_messages.COULD_NOT_GET_SID) except UserNotFound as e: close_driver(email) return server_response(code=401, msg=e.reason) except AuthCodeRequired as e: return server_response(msg=e.reason, codeRequired=True) except WebAppLoginError as e: close_driver(email) return server_response(code=e.code, msg=e.reason) except MaxRetryError as e: close_driver(email) return server_response(code=503, msg=server_status_messages.DRIVER_OPEN_FAIL)
def run(self, message): print("Received message: {}".format(message)) if message.get('action') == "openBible": data = self.get_bible(message.get('query')) print("data retrieved: ", data) socketio.emit("result", {"data": data}, namespace="/marvis") elif message.get('action') == "search": data = self.search(message.get('query')) print("data retrieved 2: ", data) socketio.emit("result", {"data": data}, namespace="/marvis")
def check_if_web_app_is_available(self): self._wait_for_page_to_load_first_time_after_login() socketio.emit('captchaCheck', "checking for captchas...") getting_started = self.get_element(elements.GETTING_STARTED) logged_on_console = self.get_element(elements.LOGGED_ON_CONSOLE) login_captcha = self.get_element(elements.LOGIN_CAPTHA) login_popup = self.get_element(elements.LOGIN_POPUP) if getting_started or logged_on_console or login_captcha or login_popup: print("found captcha/login screen issue") raise WebAppLoginError( code=503, reason=server_status_messages.WEB_APP_NOT_AVAILABLE)
def _launch(self): socketio.emit('correctCredentials', "Login Success. Launching web app... ") self.element_actions.check_if_web_app_is_available() self._set_sid_from_requests() self._set_fut_host() self._add_authenticated_ea_account() close_driver(self.email) print("sid = " + self.sid) if self.sid else print("NO SID found") if self.sid: update_ea_account_status(self.email, EaAccountStatus.CONNECTED) return server_response(msg=server_status_messages.LOGIN_SUCCESS, code=200) raise WebAppLoginError( reason=server_status_messages.WEB_APP_NOT_AVAILABLE, code=503)
def login_with_cookies(self, cookies): # self.driver.delete_all_cookies() for cookie in cookies: if 'expiry' in cookie: del cookie['expiry'] self.driver.add_cookie(cookie) self.driver.get(app.WEB_APP_URL) self.element_actions.execute_element_action(elements.FIRST_LOGIN, ElementCallback.CLICK, None, timeout=60) # Entering password left, and you are in! socketio.emit('credentialsCheck', "checking account credentials...") self.element_actions.execute_element_action(elements.PASSWORD_FIELD, ElementCallback.SEND_KEYS, self.password) self.element_actions.execute_element_action(elements.BTN_NEXT, ElementCallback.CLICK) # check for login credentials captcha self._raise_if_login_error_label_exists() login_attempts[self.email] = self
def start_activities_analysis(filename, activities, scenario_settings_id): static_analysis_results = StaticAnalysisResults.query.get(filename) smart_input_results = SmartInputResult.query.get(filename) if smart_input_results: smart_input_results = smart_input_results.result scenario_datas = scenario_service.get_for_choosen_activities_and_settings( static_analysis_results, activities, scenario_settings_id, current_user) if scenario_datas: scenario_data = scenario_datas[0] celery.send_task('dynamic_analysis_task', args=[ static_analysis_results.apk_filename, scenario_data, smart_input_results, current_user.username ], task_id=current_user.username) html = templates_service.render_selected_activities( scenario_data, scenario_settings_id, current_user) socketio.emit('html', {'html': html}, room=current_user.username)