Skip to content

Commit

Permalink
Warn when DayOne/directory journals have encrypt: true in config (#1325)
Browse files Browse the repository at this point in the history
* Raise exception when trying to commit folder-based journal (including DayOne)
* Change negative bool name to a positive
* Add test to ensure this doesn't mess with encrypting normal journals
* Consolidate and standardized tests
* Add failing test for new error message about unencryptable journals
* Warn when encrypt is true and journal type is directory/DayOne
  • Loading branch information
micahellison authored Aug 21, 2021
1 parent c52e878 commit fa146b1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions jrnl/Journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,12 @@ def open_journal(journal_name, config, legacy=False):
config["journal"] = os.path.expanduser(os.path.expandvars(config["journal"]))

if os.path.isdir(config["journal"]):
if config["encrypt"]:
print(
"Warning: This journal's config has 'encrypt' set to true, but this type of journal can't be encrypted.",
file=sys.stderr,
)

if config["journal"].strip("/").endswith(".dayone") or "entries" in os.listdir(
config["journal"]
):
Expand Down
11 changes: 9 additions & 2 deletions tests/bdd/features/encrypt.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,16 @@ Feature: Encrypting and decrypting journals
Then we should be prompted for a password
And the output should contain "2013-06-10 15:40 Life is good"


Scenario Outline: Running jrnl with encrypt: true on unencryptable journals
Given we use the config "<config_file>"
When we run "jrnl --config-override encrypt true here is a new entry"
Then the error output should contain "this type of journal can't be encrypted"

Examples: configs
| config_file |
| basic_onefile.yaml |
| config_file |
| basic_folder.yaml |
| basic_dayone.yaml |


Scenario Outline: Attempt to encrypt a folder or DayOne journal should result in an error
Expand Down

0 comments on commit fa146b1

Please sign in to comment.