Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CBR-437] Kernel.Wallets.updatePassword should record if the user decided to remove it #3621

Merged
merged 1 commit into from
Sep 21, 2018

Conversation

Anviking
Copy link
Member

Description

When the password is updated we should check if it is the
emptyPassphrase and, if so, update HdRoot to have no spending
password.

This commit pr also adds a test property that ensures the hdRoot has no
spending password afterwards, and modifies the existing property to only
test updates with non-empty passwords, where we expect the new hdRoot to
have a spending password.

Linked issue

CBR-437

Type of change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🛠 New feature (non-breaking change which adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🏭 Refactoring that does not change existing functionality but does improve things like code readability, structure etc
  • 🔨 New or improved tests for existing code
  • ⛑ git-flow chore (backport, hotfix, etc)

Developer checklist

  • I have read the style guide document, and my code follows the code style of this project.
  • If my code deals with exceptions, it follows the guidelines.
  • I have updated any documentation accordingly, if needed. Documentation changes can be reflected in opening a PR on cardanodocs.com, amending the inline Haddock comments, any relevant README file or one of the document listed in the docs directory.
  • CHANGELOG entry has been added and is linked to the correct PR on GitHub.

Testing checklist

  • I have added tests to cover my changes.
  • All new and existing tests passed.

QA Steps

Screenshots (if available)

Copy link
Contributor

@adinapoli-iohk adinapoli-iohk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @Anviking I have added a couple of remarks I would like to see fixed/explained, but I have approved nevertheless as I don't think they are necessarily deal breakers :)

@@ -311,8 +313,9 @@ spec = describe "Wallets" $ do
describe "Wallet update password (kernel)" $ do
prop "correctly replaces the ESK in the keystore" $ withMaxSuccess 50 $
monadicIO $ do
newPwd <- pick arbitrary
newPwd <- pick $ arbitrary `suchThat` (/= emptyPassphrase)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest not to touch the logic of this test, as this properly tests only one thing, which is the keystore replacement. What am I missing? What's the rationale behind the change?

Copy link
Member Author

@Anviking Anviking Sep 18, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I basically duplicated this test, checked for HasSpendingPassword here, and NoSpendingPassword in the new one.

I considered re-calculating the HasSpendingPassword from the arbitrary password in the test below making sure it was the same as the one in the hdRoot, but that felt to implicit, and dependent on arbitrary picking both empty and non-empty passwords.

I could make another copy? (Also, should I strip away the checks already tested here?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My (relatively small) concern is that the first property is called "correctly replaces the ESK in the keystore" and, as such, it should work regardless of which spending password we pick to begin with. Right now it feels like this first test is a bit misleading, this is why I have proposed to leave it be and simply add another one (like you did) to check for this specific concern only.


let hasSpendingPassword = if (newPassword == emptyPassphrase)
then HD.NoSpendingPassword
else HD.HasSpendingPassword lastUpdateNow
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the way to go. However, also let's add a comment on why we do this, as it might not be totally obvious to the reader that actually the frontend does allow the removal of the spending password after the wallet has been created (I, for one, got to know it just today)

@Anviking Anviking force-pushed the anviking/CBR-437/update-password branch 5 times, most recently from 77398d5 to 2960f39 Compare September 19, 2018 13:26
@Anviking
Copy link
Member Author

Anviking commented Sep 19, 2018

Addressed now, I believe.
Edit: Oh, didn't expect the failing CI 🙃

@Anviking Anviking force-pushed the anviking/CBR-437/update-password branch from 2960f39 to 5d45665 Compare September 20, 2018 10:24
@adinapoli-iohk
Copy link
Contributor

Looks great, thanks @Anviking !

When the password is updated we should check if it is the
`emptyPassphrase` and, if so, update `HdRoot` to have no spending
password.

This commit also adds a test property that ensures the hdRoot has no
spending password afterwards, and modifies the existing property to only
test updates with non-empty passwords, where we expect the new hdRoot to
*have* a spending password.
@Anviking Anviking force-pushed the anviking/CBR-437/update-password branch from 5d45665 to b7f1e5d Compare September 20, 2018 13:51
@KtorZ KtorZ merged commit 7a90c51 into develop Sep 21, 2018
@KtorZ KtorZ deleted the anviking/CBR-437/update-password branch September 21, 2018 08:01
KtorZ added a commit that referenced this pull request Nov 9, 2018
…-password

[CBR-437] Kernel.Wallets.updatePassword should record if the user decided to remove it
KtorZ added a commit to input-output-hk/cardano-wallet-legacy that referenced this pull request Nov 9, 2018
…hk/anviking/CBR-437/update-password

[CBR-437] Kernel.Wallets.updatePassword should record if the user decided to remove it
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants