Skip to content

Commit

Permalink
Refactor functional test fixtures in source timeout and metadata tests
Browse files Browse the repository at this point in the history
Refactor source app warning tests using new fixtures

Refactor source app metadata test using new fixtures
  • Loading branch information
nabla-c0d3 committed Feb 27, 2022
1 parent a5f7e39 commit 22cdf95
Show file tree
Hide file tree
Showing 15 changed files with 938 additions and 102 deletions.
4 changes: 3 additions & 1 deletion securedrop/source_app/session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import sqlalchemy
from flask import session

from sdconfig import config
from source_user import SourceUser, authenticate_source_user, InvalidPassphraseError

if TYPE_CHECKING:
Expand Down Expand Up @@ -40,6 +39,9 @@ def log_user_in(
db_session: sqlalchemy.orm.Session,
supplied_passphrase: "DicewarePassphrase"
) -> SourceUser:
# Late import so the module can be used without a config.py in the parent folder
from sdconfig import config

# Validate the passphrase; will raise an exception if it is not valid
source_user = authenticate_source_user(
db_session=db_session, supplied_passphrase=supplied_passphrase
Expand Down
3 changes: 1 addition & 2 deletions securedrop/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ def __init__(self, storage_path: str, temp_dir: str) -> None:

# where files and directories are sent to be securely deleted
self.__shredder_path = os.path.abspath(os.path.join(self.__storage_path, "../shredder"))
if not os.path.exists(self.__shredder_path):
os.makedirs(self.__shredder_path, mode=0o700)
os.makedirs(self.__shredder_path, mode=0o700, exist_ok=True)

# crash if we don't have a way to securely remove files
if not rm.check_secure_delete_capability():
Expand Down
2 changes: 1 addition & 1 deletion securedrop/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def setup_journalist_key_and_gpg_folder() -> Generator[Tuple[str, Path], None, N
# This path matches the GPG_KEY_DIR defined in the config.py used for the tests
# If they don't match, it can make the tests flaky and very hard to debug
tmp_gpg_dir = Path("/tmp") / "securedrop" / "keys"
tmp_gpg_dir.mkdir(parents=True, exist_ok=True)
tmp_gpg_dir.mkdir(parents=True, exist_ok=True, mode=0o0700)

try:
# GPG 2.1+ requires gpg-agent, see #4013
Expand Down
Loading

0 comments on commit 22cdf95

Please sign in to comment.