示例#1
0
        public void SetGetURLTest()
        {
            // Arrange
            LoginInformation li     = new LoginInformation(newTitle: "Random forum", newUrl: "https://somedomain.com", newEmail: "*****@*****.**", newUsername: "******", newPassword: "******");
            string           newURL = "https://otherdomain.com";

            // Act
            li.UpdateURL(newURL);

            // Assert
            Assert.AreEqual(newURL, li.GetURL());
        }
示例#2
0
 public static LoginSimplified TurnIntoEditable(LoginInformation loginInformation, int zeroBasedIndexNumber)
 {
     return(new LoginSimplified()
     {
         zeroBasedIndexNumber = zeroBasedIndexNumber,
         IsSecure = false,
         Title = loginInformation.GetTitle(),
         URL = loginInformation.GetURL(),
         Email = loginInformation.GetEmail(),
         Username = loginInformation.GetUsername(),
         Password = loginInformation.GetPassword(),
         Notes = loginInformation.GetNotes(),
         Icon = loginInformation.GetIcon(),
         Category = loginInformation.GetCategory(),
         Tags = loginInformation.GetTags(),
         CreationTime = loginInformation.GetCreationTime().ToString("s", System.Globalization.CultureInfo.InvariantCulture),
         ModificationTime = loginInformation.GetModificationTime().ToString("s", System.Globalization.CultureInfo.InvariantCulture),
     });
 }
示例#3
0
        public void ReplaceLoginInformationSecretTest()
        {
            // Arrange
            string kdfeIdentifier = "somethingheremuch";
            string password       = "******";

            KeyDerivationFunctionEntry kdfe = KeyDerivationFunctionEntry.CreateHMACSHA256KeyDerivationFunctionEntry(kdfeIdentifier);
            CommonSecretsContainer     csc  = new CommonSecretsContainer(kdfe);

            LoginInformation add1 = ContentGenerator.GenerateRandomLoginInformation();
            LoginInformation add2 = ContentGenerator.GenerateRandomLoginInformation();

            LoginInformation replace1 = ContentGenerator.GenerateRandomLoginInformation();
            LoginInformation replace2 = ContentGenerator.GenerateRandomLoginInformation();

            // Act
            var addResultSuccess1 = csc.AddLoginInformationSecret(password, add1, kdfeIdentifier);
            var addResultSuccess2 = csc.AddLoginInformationSecret(kdfe.GeneratePasswordBytes(password), add2, kdfeIdentifier);

            var replaceResultSuccess1 = csc.ReplaceLoginInformationSecret(0, password, replace1, kdfeIdentifier);
            var replaceResultSuccess2 = csc.ReplaceLoginInformationSecret(1, kdfe.GeneratePasswordBytes(password), replace2, kdfeIdentifier);

            var replaceResultFailure1 = csc.ReplaceLoginInformationSecret(0, password, null, kdfeIdentifier);
            var replaceResultFailure2 = csc.ReplaceLoginInformationSecret(0, password, ContentGenerator.GenerateRandomLoginInformation(), "not existing");
            var replaceResultFailure3 = csc.ReplaceLoginInformationSecret(0, "", ContentGenerator.GenerateRandomLoginInformation(), kdfeIdentifier);
            var replaceResultFailure4 = csc.ReplaceLoginInformationSecret(-1, password, replace1, kdfeIdentifier);
            var replaceResultFailure5 = csc.ReplaceLoginInformationSecret(2, password, replace1, kdfeIdentifier);

            // Assert
            Assert.AreNotEqual(add1.GetURL(), replace1.GetURL(), "Make sure that random content do not match!");
            Assert.AreNotEqual(add2.GetURL(), replace2.GetURL(), "Make sure that random content do not match!");

            Assert.AreEqual(replace1.GetURL(), csc.loginInformationSecrets[0].GetURL(kdfe.GeneratePasswordBytes(password)));
            Assert.AreEqual(replace2.GetURL(), csc.loginInformationSecrets[1].GetURL(kdfe.GeneratePasswordBytes(password)));

            Assert.IsTrue(addResultSuccess1.success);
            Assert.AreEqual("", addResultSuccess1.possibleError);

            Assert.IsTrue(addResultSuccess2.success);
            Assert.AreEqual("", addResultSuccess2.possibleError);

            Assert.IsTrue(replaceResultSuccess1.success);
            Assert.AreEqual("", replaceResultSuccess1.possibleError);

            Assert.IsTrue(replaceResultSuccess2.success);
            Assert.AreEqual("", replaceResultSuccess2.possibleError);

            Assert.IsFalse(replaceResultFailure1.success);
            Assert.IsFalse(string.IsNullOrEmpty(replaceResultFailure1.possibleError));

            Assert.IsFalse(replaceResultFailure2.success);
            Assert.IsFalse(string.IsNullOrEmpty(replaceResultFailure2.possibleError));

            Assert.IsFalse(replaceResultFailure3.success);
            Assert.IsFalse(string.IsNullOrEmpty(replaceResultFailure3.possibleError));

            Assert.IsFalse(replaceResultFailure4.success);
            Assert.IsFalse(string.IsNullOrEmpty(replaceResultFailure4.possibleError));

            Assert.IsFalse(replaceResultFailure5.success);
            Assert.IsFalse(string.IsNullOrEmpty(replaceResultFailure5.possibleError));

            Assert.AreEqual(2, csc.loginInformationSecrets.Count);
        }