Пример #1
0
        public void ModificationTimeTest()
        {
            // Arrange
            LoginInformation li = new LoginInformation(newTitle: "Random forum", newUrl: "https://somedomain.com", newEmail: "*****@*****.**", newUsername: "******", newPassword: "******");

            // Act
            DateTimeOffset modificationTime1 = li.GetModificationTime();

            Thread.Sleep(1100);
            li.UpdateUsername("dragon2");
            DateTimeOffset modificationTime2 = li.GetModificationTime();

            // Assert
            Assert.Greater(modificationTime2, modificationTime1);
        }
        public void GetModificationTimeTest()
        {
            // Arrange
            byte[] derivedKey = new byte[16] {
                111, 222, 31, 4, 5, 68, 78, 83, 9, 110, 211, 128, 213, 104, 15, 16
            };
            byte[] initialCounter = new byte[] { 0xf0, 0xf1, 0xfb, 0xf3, 0xaa, 0xc5, 0xd6, 0xbb, 0xf8, 0x19, 0x11, 0xfb, 0x33, 0xfd, 0xfe, 0xff };

            SettingsAES_CTR settingsAES_CTR = new SettingsAES_CTR(initialCounter);

            SymmetricKeyAlgorithm skaAES_CTR = new SymmetricKeyAlgorithm(SymmetricEncryptionAlgorithm.AES_CTR, 128, settingsAES_CTR);

            LoginInformation loginInformationModified = loginInformation.ShallowCopy();

            Thread.Sleep(1100);
            loginInformationModified.UpdateNotes("Some text to here so modification time triggers");

            LoginInformationSecret loginInformationSecret = new LoginInformationSecret(loginInformationModified, "does not matter", skaAES_CTR, derivedKey);

            // Act
            DateTimeOffset loginInformationModificationTime = loginInformationSecret.GetModificationTime(derivedKey);

            // Assert
            Assert.IsTrue(loginInformationModified.modificationTime > loginInformationModified.creationTime);
            Assert.AreEqual(loginInformationModified.GetModificationTime(), loginInformationModificationTime);
        }
Пример #3
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),
     });
 }