11using KeyVaultCli . Domain . Entities ;
2+ using KeyVaultCli . Domain . Exceptions ;
23using KeyVaultCli . Domain . UnitTests . Fakes ;
34
45namespace KeyVaultCli . Domain . UnitTests . Entities ;
@@ -36,6 +37,9 @@ public void TestUpdateMasterPassword_Success()
3637 var result = _vault . UpdateMasterPassword ( "masterPassword" , "newMasterPassword" ) ;
3738
3839 Assert . IsTrue ( result , "Master password should have been updated successfully." ) ;
40+
41+ var oldPasswordWorks = _vault . UpdateMasterPassword ( "masterPassword" , "someOtherPassword" ) ;
42+ Assert . IsFalse ( oldPasswordWorks , "Old master password should no longer work." ) ;
3943 }
4044
4145 [ TestMethod ]
@@ -64,12 +68,23 @@ public void TestUpdatePasswordEntry_Success()
6468 var result =
6569 _vault . UpdateAndSavePasswordEntry ( "testService" , "testAccount" , "newService" , "newAccount" , 10 ,
6670 "newPassword" ) ;
67- var password = _vault . DecryptAndRetrievePassword ( "newService" , "newAccount" ) ;
6871
6972 Assert . IsTrue ( result , "Password entry should have been updated successfully." ) ;
73+
74+ var password = _vault . DecryptAndRetrievePassword ( "newService" , "newAccount" ) ;
7075 Assert . AreEqual ( "newPassword" , password , "Password should have been updated successfully." ) ;
76+
77+ try
78+ {
79+ var oldPassword = _vault . DecryptAndRetrievePassword ( "testService" , "testAccount" ) ;
80+ }
81+ catch ( PasswordNotFoundException )
82+ {
83+ Assert . IsTrue ( true , "Old password entry should no longer exist and thus throw exception." ) ;
84+ }
7185 }
7286
87+
7388 [ TestMethod ]
7489 public void TestDeleteAllPasswordEntries_Success ( )
7590 {
@@ -105,5 +120,8 @@ public void TestSearchPasswordEntries_Success()
105120 "Searched password entry should match the service name." ) ;
106121 Assert . AreEqual ( "testService3" , expectedResult2 . First ( ) . ServiceName ,
107122 "Searched password entry should match the service name." ) ;
123+
124+ var nonExistentResult = _vault . SearchPasswordEntries ( "nonExistentService" ) ;
125+ Assert . AreEqual ( 0 , nonExistentResult . Count , "Search result for non-existent service should be an empty list." ) ;
108126 }
109127}
0 commit comments