mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-03 22:28:11 +08:00
update to get_secrets_key (#1755)
* raise exception when get_secrets fails, get db_uri and set as a default_dataset_config var * log as info not an error
This commit is contained in:
@@ -112,19 +112,25 @@ class AppConfigTest(unittest.TestCase):
|
||||
def test_get_config_vars_from_aws_secrets(self, mock_get_secret_key):
|
||||
mock_get_secret_key.return_value = {
|
||||
"flask_secret_key": "mock_flask_secret",
|
||||
"oauth_client_secret": "mock_oauth_secret"
|
||||
"oauth_client_secret": "mock_oauth_secret",
|
||||
"db_uri": "mock_db_uri"
|
||||
}
|
||||
|
||||
config = AppConfig()
|
||||
|
||||
with self.assertLogs(level="ERROR") as logger:
|
||||
with self.assertLogs(level="INFO") as logger:
|
||||
|
||||
from server.common.aws_secret_utils import handle_config_from_secret
|
||||
# should not throw error
|
||||
# "AttributeError: 'ServerConfig' object has no attribute 'user_annotations__hosted_tiledb_array__db_uri'"
|
||||
# "AttributeError: 'XConfig' object has no attribute 'x'"
|
||||
handle_config_from_secret(config)
|
||||
|
||||
# should throw 2 errors (one for each var set from a secret)
|
||||
self.assertEqual(len(logger.output), 2)
|
||||
self.assertIn('ERROR:root:set app__flask_secret_key from secret', logger.output[0])
|
||||
self.assertIn('ERROR:root:set authentication__params_oauth__client_secret from secret', logger.output[1])
|
||||
# should log 3 lines (one for each var set from a secret)
|
||||
self.assertEqual(len(logger.output), 3)
|
||||
self.assertIn('INFO:root:set app__flask_secret_key from secret', logger.output[0])
|
||||
self.assertIn('INFO:root:set authentication__params_oauth__client_secret from secret', logger.output[1])
|
||||
self.assertIn('INFO:root:set user_annotations__hosted_tiledb_array__db_uri from secret', logger.output[2])
|
||||
self.assertEqual(config.server_config.app__flask_secret_key, "mock_flask_secret")
|
||||
self.assertEqual(config.server_config.authentication__params_oauth__client_secret, "mock_oauth_secret")
|
||||
self.assertEqual(config.default_dataset_config.user_annotations__hosted_tiledb_array__db_uri, "mock_db_uri")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user