How to use _log_messages method in autotest

Best Python code snippet using autotest_python

auth_plugin.py

Source:auth_plugin.py Github

copy

Full Screen

1"""2AuthPlugin.py3Copyright 2011 Andres Riancho4This file is part of w3af, http://w3af.org/ .5w3af is free software; you can redistribute it and/or modify6it under the terms of the GNU General Public License as published by7the Free Software Foundation version 2 of the License.8w3af is distributed in the hope that it will be useful,9but WITHOUT ANY WARRANTY; without even the implied warranty of10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the11GNU General Public License for more details.12You should have received a copy of the GNU General Public License13along with w3af; if not, write to the Free Software14Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA15"""16import w3af.core.controllers.output_manager as om17import w3af.core.data.kb.knowledge_base as kb18from w3af.core.controllers.plugins.plugin import Plugin19from w3af.core.data.kb.info import Info20from w3af.core.data.fuzzer.utils import rand_alnum21class AuthPlugin(Plugin):22 """23 This is the base class for auth plugins, all auth plugins should inherit24 from it and implement the following methods:25 1. login(...)26 2. logout(...)27 2. has_active_session(...)28 :author: Dmitriy V. Simonov ( dsimonov@yandex-team.com )29 """30 def __init__(self):31 Plugin.__init__(self)32 self._uri_opener = None33 self._debugging_id = None34 self._http_response_ids = []35 self._log_messages = []36 def login(self):37 """38 Login user into web application.39 It is called in the begging of w3afCore::_discover_and_bruteforce() method40 if current user session is not valid.41 """42 raise NotImplementedError('Plugin is not implementing required method login')43 def logout(self):44 """45 Logout user from web application.46 TODO: need to add calling of this method to w3afCore::_end()47 """48 raise NotImplementedError('Plugin is not implementing required method logout')49 def has_active_session(self):50 """51 Check if current session is still valid.52 It is called in the begging of w3afCore::_discover_and_bruteforce() method.53 """54 raise NotImplementedError('Plugin is not implementing required method isLogged')55 def _log_http_response(self, http_response):56 self._http_response_ids.append(http_response.id)57 def _clear_log(self):58 self._http_response_ids = []59 self._log_messages = []60 def _log_debug(self, message):61 self._log_messages.append(message)62 formatted_message = self._format_message(message)63 om.out.debug(formatted_message)64 def _log_error(self, message):65 self._log_messages.append(message)66 formatted_message = self._format_message(message)67 om.out.error(formatted_message)68 def _format_message(self, message):69 message_fmt = '[auth.%s] %s (did: %s)'70 return message_fmt % (self.get_name(), message, self._debugging_id)71 def _new_debugging_id(self):72 self._debugging_id = rand_alnum(8)73 def _get_main_authentication_url(self):74 """75 :return: The main authentication URL, this can be the URL where the76 credentials are sent to, the location where the login form77 should be found, or any other URL which identifies the78 authentication.79 """80 raise NotImplementedError81 def _log_info_to_kb(self):82 """83 This method creates an Info object containing information about failed84 authentication attempts and stores it in the knowledge base.85 The information stored in the Info object is:86 * The log messages from self._log_messages87 * HTTP response IDs from self._htp_response_ids88 :return: None89 """90 desc = ('The authentication plugin failed to get a valid application'91 ' session using the user-provided configuration settings.\n'92 '\n'93 'The plugin generated the following log messages:\n'94 '\n')95 desc += '\n'.join(self._log_messages)96 i = Info('Authentication failure',97 desc,98 self._http_response_ids,99 self.get_name())100 i.set_uri(self._get_main_authentication_url())101 kb.kb.clear('authentication', 'error')102 kb.kb.append('authentication', 'error', i)103 def get_type(self):...

Full Screen

Full Screen

LogicPlg.py

Source:LogicPlg.py Github

copy

Full Screen

...9 LOG_INFO_MESSAGE_START = { "text": "the plugin was started", "id" : -1}10 LOG_INFO_MESSAGE_STOPED = { "text": "the plugin was stoped", "id" : -1}11 LOG_INFO_MESSAGE_FINISH = { "text": "the plugin finished executing", "id" : -1}12 def init(self):13 self.register_log_messages()14 self.log(ILogicPlugin.LOG_INFO_MESSAGE_INIT['id'])15 def log(self, msg_id):16 self.__logger.log(self.get_name(), msg_id)17 def register_log_messages(self):18 self._log_messages = list()19 self._log_messages.append({"text": ILogicPlugin.LOG_INFO_MESSAGE_INIT["text"], "level": MessageLevels.INFO})20 ILogicPlugin.LOG_INFO_MESSAGE_INIT["id"] = len(self._log_messages) - 121 self._log_messages.append({"text": ILogicPlugin.LOG_INFO_MESSAGE_START["text"], "level": MessageLevels.INFO})22 ILogicPlugin.LOG_INFO_MESSAGE_START["id"] = len(self._log_messages) - 123 self._log_messages.append({"text": ILogicPlugin.LOG_INFO_MESSAGE_STOPED["text"], "level": MessageLevels.INFO})24 ILogicPlugin.LOG_INFO_MESSAGE_STOPED["id"] = len(self._log_messages) - 125 self._log_messages.append({"text": ILogicPlugin.LOG_INFO_MESSAGE_FINISH["text"], "level": MessageLevels.INFO})26 ILogicPlugin.LOG_INFO_MESSAGE_FINISH["id"] = len(self._log_messages) - 127 self.__logger = self._plugin_manager.getPluginByName('Text Local Logging', 'Logging').plugin_object28 self.__logger.register_module_messages(self.get_name(), self._log_messages)29 def start(self):30 self.log(ILogicPlugin.LOG_INFO_MESSAGE_START['id'])31 def stop(self):...

Full Screen

Full Screen

testlogger.py

Source:testlogger.py Github

copy

Full Screen

2import lib.logger3import unittest4import logging5class TestLogger(unittest.TestCase):6 def _log_messages(self, l):7 # 1 - default behavior - only prints INFO and above.8 # This DEBUG message will be suppressed, all the rest are printed.9 l.debug('This is a debug log message. (1)')10 l.info('This is an info log message. (1)')11 l.warning('This is a warning log message. (1)')12 l.error('This is an error log message. (1)')13 l.critical('This is a critical log message. (1)')14 # 2 - Set all handlers of this logger to output DEBUG and higher level messages.15 lib.logger.set_level(l, logging.DEBUG)16 l.debug('This is a debug log message. (2)')17 l.info('This is an info log message. (2)')18 l.warning('This is a warning log message. (2)')19 l.error('This is an error log message. (2)')20 l.critical('This is a critical log message. (2)')21 def test_logger(self):22 self._log_messages(lib.logger.get_logger('testlogger-test_logger', './'))23 def test_stdout_logger(self):24 self._log_messages(lib.logger.get_stdout_logger())25 def test_file_logger(self):...

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