-
Notifications
You must be signed in to change notification settings - Fork 690
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring back the try/except blocks needed to support long-running instance configurations that may lack newer attributes.
- Loading branch information
Showing
2 changed files
with
144 additions
and
32 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import importlib | ||
|
||
import config as _config | ||
|
||
|
||
def test_missing_config_attribute_is_handled(): | ||
""" | ||
Test handling of incomplete configurations. | ||
Long-running SecureDrop instances might not have ever updated | ||
config.py, so could be missing newer settings. This tests that | ||
sdconfig.SDConfig can be initialized without error with such a | ||
configuration. | ||
""" | ||
attributes_to_test = ( | ||
"JournalistInterfaceFlaskConfig", | ||
"SourceInterfaceFlaskConfig", | ||
"DATABASE_ENGINE", | ||
"DATABASE_FILE", | ||
"ADJECTIVES", | ||
"NOUNS", | ||
"GPG_KEY_DIR", | ||
"JOURNALIST_KEY", | ||
"JOURNALIST_TEMPLATES_DIR", | ||
"SCRYPT_GPG_PEPPER", | ||
"SCRYPT_ID_PEPPER", | ||
"SCRYPT_PARAMS", | ||
"SECUREDROP_DATA_ROOT", | ||
"SECUREDROP_ROOT", | ||
"SESSION_EXPIRATION_MINUTES", | ||
"SOURCE_TEMPLATES_DIR", | ||
"TEMP_DIR", | ||
"STORE_DIR", | ||
"WORKER_PIDFILE", | ||
) | ||
|
||
importlib.reload(_config) | ||
|
||
for a in attributes_to_test: | ||
delattr(_config, a) | ||
|
||
from sdconfig import SDConfig | ||
|
||
SDConfig() |