Ejemplo n.º 1
0
def create_empty_adal_object():
    context = log.create_log_context()
    component = 'TEST'
    logger = log.Logger(component, context)
    call_context = {'log_context': context}
    adal_object = {'log': logger, 'call_context': call_context}
    return adal_object
Ejemplo n.º 2
0
 def test_logging(self):
     log_capture_string = StringIO()
     handler = logging.StreamHandler(log_capture_string)
     util.turn_on_logging(handler=handler)
     
     test_logger = adal_logging.Logger("TokenRequest", {'correlation_id':'12345'})
     test_logger.warn('a warning', log_stack_trace=True)
     log_contents = log_capture_string.getvalue()
     logging.getLogger(adal_logging.ADAL_LOGGER_NAME).removeHandler(handler)
     self.assertTrue('12345 - TokenRequest:a warning' in log_contents and 'Stack:' in log_contents)
Ejemplo n.º 3
0
    def test_scrub_pii(self):
        not_pii = "not pii"
        pii = "*****@*****.**"
        content_with_pii = {"message": not_pii, "email": pii}
        expected = {"message": not_pii, "email": "..."}
        self.assertEqual(adal_logging.scrub_pii(content_with_pii), expected)

        log_capture_string = StringIO()
        handler = logging.StreamHandler(log_capture_string)
        util.turn_on_logging(handler=handler)
        test_logger = adal_logging.Logger("TokenRequest", {'correlation_id':'12345'})
        test_logger.warn('%(message)s for user email %(email)s', content_with_pii)
        log_contents = log_capture_string.getvalue()
        logging.getLogger(adal_logging.ADAL_LOGGER_NAME).removeHandler(handler)
        self.assertTrue(not_pii in log_contents and pii not in log_contents)