mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-07-04 07:26:14 +02:00
Fix for new test from develop branch
There was a new test added for re-encrypting a journal. This updates the refactor to match the old (previously untested) behavior of jrnl. Co-authored-by: Micah Jerome Ellison <micah.jerome.ellison@gmail.com>
This commit is contained in:
parent
12bcc644d8
commit
33b0de862f
6 changed files with 75 additions and 16 deletions
|
@ -48,6 +48,7 @@ Feature: Encrypting and decrypting journals
|
|||
|
||||
Scenario: Encrypt journal twice and get prompted each time
|
||||
Given we use the config "simple.yaml"
|
||||
And we don't have a keyring
|
||||
When we run "jrnl --encrypt" and enter
|
||||
swordfish
|
||||
swordfish
|
||||
|
@ -56,7 +57,26 @@ Feature: Encrypting and decrypting journals
|
|||
And the output should contain "Journal encrypted"
|
||||
When we run "jrnl --encrypt" and enter
|
||||
swordfish
|
||||
tuna
|
||||
tuna
|
||||
y
|
||||
Then we should get no error
|
||||
And the output should contain "Journal default is already encrypted. Create a new password."
|
||||
And we should be prompted for a password
|
||||
And the config for journal "default" should contain "encrypt: true"
|
||||
|
||||
Scenario: Encrypt journal twice and get prompted each time with keyring
|
||||
Given we use the config "simple.yaml"
|
||||
And we have a keyring
|
||||
When we run "jrnl --encrypt" and enter
|
||||
swordfish
|
||||
swordfish
|
||||
y
|
||||
Then we should get no error
|
||||
And the output should contain "Journal encrypted"
|
||||
When we run "jrnl --encrypt" and enter
|
||||
tuna
|
||||
tuna
|
||||
y
|
||||
Then we should get no error
|
||||
And the output should contain "Journal default is already encrypted. Create a new password."
|
||||
|
|
|
@ -17,6 +17,7 @@ from pytest_bdd.parsers import parse
|
|||
from jrnl import __version__
|
||||
from jrnl.time import __get_pdt_calendar
|
||||
from tests.lib.fixtures import FailedKeyring
|
||||
from tests.lib.fixtures import NoKeyring
|
||||
from tests.lib.fixtures import TestKeyring
|
||||
from tests.lib.helpers import get_fixture
|
||||
|
||||
|
@ -67,13 +68,20 @@ def now_is_str(date_str, mock_factories):
|
|||
)
|
||||
|
||||
|
||||
@given("we don't have a keyring", target_fixture="keyring")
|
||||
def we_dont_have_keyring(keyring_type):
|
||||
return NoKeyring()
|
||||
|
||||
|
||||
@given("we have a keyring", target_fixture="keyring")
|
||||
@given(parse("we have a {keyring_type} keyring"), target_fixture="keyring")
|
||||
def we_have_type_of_keyring(keyring_type):
|
||||
if keyring_type == "failed":
|
||||
return FailedKeyring()
|
||||
else:
|
||||
return TestKeyring()
|
||||
match keyring_type:
|
||||
case "failed":
|
||||
return FailedKeyring()
|
||||
|
||||
case _:
|
||||
return TestKeyring()
|
||||
|
||||
|
||||
@given(parse('we use the config "{config_file}"'), target_fixture="config_path")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue