def test_remote_config_fixups_hsm_enabled(local_settings, server_settings): assert "high_security" in local_settings assert local_settings["high_security"] is True assert "high_security" in server_settings _settings = global_settings() settings = override_generic_settings(_settings, local_settings)(AgentProtocol._apply_high_security_mode_fixups)( server_settings, _settings ) agent_config = settings["agent_config"] assert "high_security" not in settings assert "capture_params" not in settings assert "transaction_tracer.record_sql" not in settings assert "strip_exception_messages.enabled" not in settings assert "custom_insights_events.enabled" not in settings assert "application_logging.forwarding.enabled" not in settings assert "capture_params" not in agent_config assert "transaction_tracer.record_sql" not in agent_config assert "strip_exception_messages.enabled" not in agent_config assert "custom_insights_events.enabled" not in agent_config assert "application_logging.forwarding.enabled" not in agent_config
def test_remote_config_fixups_hsm_disabled(local_settings, server_settings): assert "high_security" in local_settings assert local_settings["high_security"] is False assert "high_security" not in server_settings agent_config = server_settings["agent_config"] original_capture_params = agent_config["capture_params"] original_record_sql = agent_config["transaction_tracer.record_sql"] original_strip_messages = agent_config["strip_exception_messages.enabled"] original_custom_events = agent_config["custom_insights_events.enabled"] original_log_forwarding = agent_config["application_logging.forwarding.enabled"] _settings = global_settings() settings = override_generic_settings(_settings, local_settings)(AgentProtocol._apply_high_security_mode_fixups)( server_settings, _settings ) agent_config = settings["agent_config"] assert "high_security" not in settings assert agent_config["capture_params"] == original_capture_params assert agent_config["transaction_tracer.record_sql"] == original_record_sql assert agent_config["strip_exception_messages.enabled"] == original_strip_messages assert agent_config["custom_insights_events.enabled"] == original_custom_events assert agent_config["application_logging.forwarding.enabled"] == original_log_forwarding
def test_remote_config_fixups_hsm_disabled(local_settings, server_settings): assert 'high_security' in local_settings assert local_settings['high_security'] is False assert u'high_security' not in server_settings agent_config = server_settings['agent_config'] original_capture_params = agent_config['capture_params'] original_record_sql = agent_config['transaction_tracer.record_sql'] original_strip_messages = agent_config['strip_exception_messages.enabled'] original_custom_events = agent_config['custom_insights_events.enabled'] _settings = global_settings() settings = override_generic_settings(_settings, local_settings)( AgentProtocol._apply_high_security_mode_fixups)(server_settings, _settings) agent_config = settings['agent_config'] assert u'high_security' not in settings assert agent_config['capture_params'] == original_capture_params assert agent_config['transaction_tracer.record_sql'] == original_record_sql assert agent_config['strip_exception_messages.enabled'] == \ original_strip_messages assert agent_config['custom_insights_events.enabled'] == \ original_custom_events
def test_middleware(nr_enabled, aiohttp_app, middleware, metric): @asyncio.coroutine def fetch(): resp = yield from aiohttp_app.client.request('GET', '/coro') assert resp.status == 200 text = yield from resp.text() assert "Hello Aiohttp!" in text return resp def _test(): aiohttp_app.loop.run_until_complete(fetch()) if nr_enabled: scoped_metrics = [ ('Function/_target_application:index', 1), (metric, 1), ] rollup_metrics = [ ('Function/_target_application:index', 1), (metric, 1), ('Python/Framework/aiohttp/%s' % aiohttp.__version__, 1), ] _test = validate_transaction_metrics( '_target_application:index', scoped_metrics=scoped_metrics, rollup_metrics=rollup_metrics)(_test) else: settings = global_settings() _test = override_generic_settings(settings, {'enabled': False})(_test) _test()
def test_remote_config_hsm_fixups_server_side_disabled(): local_settings = {"high_security": True} server_settings = {"high_security": True} _settings = global_settings() settings = override_generic_settings(_settings, local_settings)(AgentProtocol._apply_high_security_mode_fixups)( server_settings, _settings ) assert "high_security" not in settings
def test_remote_config_fixups_hsm_enabled(local_settings, server_settings): assert 'high_security' in local_settings assert local_settings['high_security'] is True assert u'high_security' in server_settings _settings = global_settings() settings = override_generic_settings(_settings, local_settings)( AgentProtocol._apply_high_security_mode_fixups)(server_settings, _settings) agent_config = settings['agent_config'] assert u'high_security' not in settings assert u'capture_params' not in settings assert u'transaction_tracer.record_sql' not in settings assert u'strip_exception_messages.enabled' not in settings assert u'custom_insights_events.enabled' not in settings assert u'capture_params' not in agent_config assert u'transaction_tracer.record_sql' not in agent_config assert u'strip_exception_messages.enabled' not in agent_config assert u'custom_insights_events.enabled' not in agent_config
def test_unsupported_method(app, nr_enabled, ignore_status_codes): def _test(): response = app.fetch('/simple', method='TEAPOT', body=b'', allow_nonstandard_methods=True) assert response.code == 405 if nr_enabled: _test = override_ignore_status_codes(ignore_status_codes)(_test) _test = validate_transaction_metrics( '_target_application:SimpleHandler')(_test) if ignore_status_codes: _test = validate_transaction_errors(errors=[])(_test) else: _test = validate_transaction_errors( errors=['tornado.web:HTTPError'])(_test) else: settings = global_settings() _test = override_generic_settings(settings, {'enabled': False})(_test) _test()