def test_federated_happy_path_and_correlation_id(self):
        correlationId = '12300002-0000-0000-c000-000000000000'
        util.set_correlation_id(correlationId)

        util.setup_expected_user_realm_response_common(True)
        util.setup_expected_mex_wstrust_request_common()

        response = util.create_response()
        assertion = self.setup_expected_oauth_assertion_request(response)

        logFunctionCalled = False
        def testCorrelationIdLog(level, message):
            logFunctionCalled = True
            self.assertIsNotNone(message)


        logOptions = {
            'level' : 3,
            'log' : testCorrelationIdLog
        }
        oldOptions = log.get_logging_options()
        log.set_logging_options(logOptions)

        authorityUrl = response['authority'] + '/' + cp['tenant']

        token_response = adal.acquire_token_with_username_password(authorityUrl, cp['username'], cp['password'], cp['clientId'], response['resource'])
        self.assertTrue(util.isMatchTokenResponse(response['cachedResponse'], token_response), 'Response did not match expected: ' + JSON.stringify(token_response))
        log.set_logging_options(oldOptions)
        util.set_correlation_id()

        self.assertTrue(util.isMatchTokenResponse(response['cachedResponse'], token_response), 'The response did not match what was expected')
        self.assertTrue(logFunctionCalled, 'Logging was turned on but no messages were recieved.')
    def test_settings_none(self):
        current_options = log.get_logging_options()

        log.set_logging_options()

        options = log.get_logging_options()
        log.set_logging_options(current_options)

        noOptions = len(options) == 1 and options['level'] == 0
        self.assertTrue(noOptions, 'Did not expect to find any logging options set: ' + json.dumps(options))
Ejemplo n.º 3
0
    def test_settings_none(self):
        current_options = adal_logging.get_logging_options()

        adal_logging.set_logging_options()

        options = adal_logging.get_logging_options()
        adal_logging.set_logging_options(current_options)

        noOptions = len(options) == 1 and options['level'] == 'ERROR'
        self.assertTrue(noOptions, 'Did not expect to find any logging options set: ' + json.dumps(options))
    def test_console_settings(self):
        currentOptions = log.get_logging_options()
        util.turn_on_logging()
        options = log.get_logging_options()
        level = options['level']

        # Set the looging options back to what they were before this test so that
        # future tests are logged as they should be.
        log.set_logging_options(currentOptions)

        self.assertEqual(level, log.LOGGING_LEVEL.DEBUG, 'Logging level was not the expected value of LOGGING_LEVEL.DEBUG: {}'.format(level))
Ejemplo n.º 5
0
    def test_console_settings(self):
        currentOptions = adal_logging.get_logging_options()
        util.turn_on_logging()
        options = adal_logging.get_logging_options()
        level = options['level']

        # Set the looging options back to what they were before this test so that
        # future tests are logged as they should be.
        adal_logging.set_logging_options(currentOptions)

        self.assertEqual(level, 'DEBUG', 'Logging level was not the expected value of LOGGING_LEVEL.DEBUG: {}'.format(level))
Ejemplo n.º 6
0
def turn_on_logging(level=log.LOGGING_LEVEL.DEBUG):
    log.set_logging_options({'level': level})
def turn_on_logging(level='DEBUG', handler=None):
    log.set_logging_options({'level': level, 'handler': handler})
def turn_on_logging(level='DEBUG', handler = None):
    log.set_logging_options({
        'level' : level,
        'handler' : handler
        })
def turn_on_logging(level=log.LOGGING_LEVEL.DEBUG):
    log.set_logging_options({'level':level})