From 0cdeffa5280fec551312173d0ea17e4ed5691536 Mon Sep 17 00:00:00 2001 From: Scott DeWitt Date: Tue, 21 May 2024 13:29:51 -0400 Subject: [PATCH] feat: allow redis password to be empty --- src/newrelic_logging/__init__.py | 2 +- src/newrelic_logging/cache.py | 4 +-- src/tests/test_cache.py | 60 -------------------------------- 3 files changed, 3 insertions(+), 63 deletions(-) diff --git a/src/newrelic_logging/__init__.py b/src/newrelic_logging/__init__.py index f9a3907..19fca8d 100644 --- a/src/newrelic_logging/__init__.py +++ b/src/newrelic_logging/__init__.py @@ -3,7 +3,7 @@ # Integration definitions -VERSION = "2.0.0" +VERSION = "2.2.0" NAME = "salesforce-exporter" PROVIDER = "newrelic-labs" COLLECTOR_NAME = "newrelic-salesforce-exporter" diff --git a/src/newrelic_logging/cache.py b/src/newrelic_logging/cache.py index 2fd57ea..b3c7119 100644 --- a/src/newrelic_logging/cache.py +++ b/src/newrelic_logging/cache.py @@ -4,7 +4,7 @@ from . import CacheException from .config import Config -from .telemetry import print_info +from .telemetry import print_info, print_warn CONFIG_CACHE_ENABLED = 'cache_enabled' @@ -63,7 +63,7 @@ def new_backend( password = config.get(CONFIG_REDIS_PASSWORD) if not password: - raise CacheException('missing redis password') + print_warn('missing Redis password, connecting without a password') password_display = "XXXXXX" diff --git a/src/tests/test_cache.py b/src/tests/test_cache.py index eda470b..003fbaa 100644 --- a/src/tests/test_cache.py +++ b/src/tests/test_cache.py @@ -264,66 +264,6 @@ def redis_connect(**kwargs): self.assertTrue(hasattr(r, 'ssl')) self.assertEqual(r.ssl, True) - def test_new_backend_raises_cache_exception_given_missing_redis_password(self): - ''' - new_backend() raises a CacheException given the Redis password is missing - given: an instance configuration - when: new_backend() is called - and when: the Redis password is missing - then: raise a CacheException - ''' - - # setup - def redis_connect(**kwargs): - return SimpleNamespace(**kwargs) - - config = mod_config.Config({ - 'redis': { - 'host': 'foo', - 'port': 1234, - 'db_number': 2, - 'ssl': True, - } - }) - - # execute / verify - with self.assertRaises(CacheException) as _: - f = cache.BackendFactory() - _ = f.new_backend( - config, - redis_connector=redis_connect, - ) - - def test_new_backend_raises_cache_exception_given_empty_redis_password(self): - ''' - new_backend() raises a CacheException given the Redis password is empty - given: an instance configuration - when: new_backend() is called - and when: the Redis password is empty - then: raise a CacheException - ''' - - # setup - def redis_connect(**kwargs): - return SimpleNamespace(**kwargs) - - config = mod_config.Config({ - 'redis': { - 'host': 'foo', - 'port': 1234, - 'db_number': 2, - 'password': '', - 'ssl': True, - } - }) - - # execute / verify - with self.assertRaises(CacheException) as _: - f = cache.BackendFactory() - _ = f.new_backend( - config, - redis_connector=redis_connect, - ) class TestBufferedAddSetCache(unittest.TestCase): def test_check_or_set_true_when_item_exists(self):