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

            LoginInformation li3 = new LoginInformation(newTitle: "Random forum", newUrl: "https://somedomain.com", newEmail: "*****@*****.**", newUsername: "******", newPassword: "******",
                                                        newNotes: "funny dialog is funny", newMFA: "otpauth://totp/DRAGON?secret=SECRET", newIcon: new byte[] { 0, 1, 3, 4, 5, 7 }, newCategory: "forums", newTags: "daily\tmodern");

            // Act
            LoginInformation li2 = li1.ShallowCopy();

            LoginInformation li4 = li3.ShallowCopy();

            string checksum1 = li1.GetChecksumAsHex();
            string checksum2 = li2.GetChecksumAsHex();

            string checksum3 = li3.GetChecksumAsHex();
            string checksum4 = li4.GetChecksumAsHex();

            // Assert
            Assert.IsNotNull(li2);
            Assert.IsNotNull(li4);
            Assert.AreEqual(checksum1, checksum2);
            Assert.AreEqual(checksum3, checksum4);
        }
        public void GetLoginInformationNotesTest()
        {
            // 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();

            loginInformationModified.UpdateNotes("Nice story about how I found the missing tapes of ...");

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

            // Act
            string loginInformationNotes = loginInformationSecret.GetNotes(derivedKey);

            // Assert
            Assert.IsFalse(string.IsNullOrEmpty(loginInformationNotes));
            Assert.AreEqual(loginInformationModified.notes, loginInformationNotes);
        }