Skip to content

Commit

Permalink
Redis: Add password to URL environment
Browse files Browse the repository at this point in the history
This is follow-up of d37bae2 and
ensures the password value is included in the url, presented by
the URL environment, so that the value can be looked up.
  • Loading branch information
kajinamit committed Mar 8, 2024
1 parent d37bae2 commit 97fe711
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions pifpaf/drivers/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,8 @@ def _setUp(self):
str(self.sentinel_port))

self.putenv("REDIS_PORT", str(self.port))
self.url = "redis://localhost:%d" % self.port
self.putenv("URL", self.url)
if self.password:
url = "redis://:%s@localhost:%d" % (self.password, self.port)
else:
url = "redis://localhost:%d" % self.port
self.putenv("URL", url)
2 changes: 1 addition & 1 deletion pifpaf/tests/test_drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def test_redis_sentinel_with_password(self):
port = 6385
f = self.useFixture(redis.RedisDriver(sentinel=True, port=port,
password='secrete'))
self.assertEqual("redis://localhost:%d" % port,
self.assertEqual("redis://:secrete@localhost:%d" % port,
os.getenv("PIFPAF_URL"))
self.assertEqual(str(port), os.getenv("PIFPAF_REDIS_PORT"))
self.assertEqual("6380", os.getenv("PIFPAF_REDIS_SENTINEL_PORT"))
Expand Down

0 comments on commit 97fe711

Please sign in to comment.