-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from TogetherCrew/fix/credentials-passing
fix: update mongodb credentials!
- Loading branch information
Showing
9 changed files
with
126 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
|
||
setup( | ||
name="tc-messageBroker", | ||
version="1.6.6", | ||
version="1.6.7", | ||
author="Mohammad Amin Dadgar, RnDAO", | ||
maintainer="Mohammad Amin Dadgar", | ||
maintainer_email="[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
|
||
from dotenv import load_dotenv | ||
|
||
|
||
def load_mongo_credentials(): | ||
""" | ||
load mongo db credentials from .env | ||
Returns: | ||
--------- | ||
mongo_creds : dict[str, Any] | ||
mongodb credentials | ||
a dictionary representive of | ||
`user`: str | ||
`password` : str | ||
`host` : str | ||
`port` : int | ||
`connection_str`: str | ||
""" | ||
load_dotenv() | ||
|
||
mongo_creds = {} | ||
|
||
user = os.getenv("MONGODB_USER") | ||
password = os.getenv("MONGODB_PASS") | ||
host = os.getenv("MONGODB_HOST") | ||
port = os.getenv("MONGODB_PORT") | ||
|
||
mongo_creds["user"] = user | ||
mongo_creds["password"] = password | ||
mongo_creds["host"] = host | ||
mongo_creds["port"] = port | ||
|
||
connection = f"mongodb://{user}:{password}@{host}:{port}" | ||
mongo_creds["connection_str"] = connection | ||
|
||
return mongo_creds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from unittest import TestCase | ||
|
||
from tc_messageBroker.utils.credentials import load_mongo_credentials | ||
|
||
|
||
class TestCredentialsLoading(TestCase): | ||
def test_non_none_values(self): | ||
creds = load_mongo_credentials() | ||
self.assertIsNotNone(creds["user"]) | ||
self.assertIsNotNone(creds["password"]) | ||
self.assertIsNotNone(creds["host"]) | ||
self.assertIsNotNone(creds["port"]) | ||
self.assertNotEqual(creds["connection_str"], "mongodb://None:None@None:None") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters