Skip to content

Commit

Permalink
feat: allow redis password to be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
sdewitt-newrelic committed May 21, 2024
1 parent c717f4a commit 0cdeffa
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/newrelic_logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/newrelic_logging/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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"

Expand Down
60 changes: 0 additions & 60 deletions src/tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 0cdeffa

Please sign in to comment.