Esempio n. 1
0
        public void Entry_New()
        {
            var entry = new PwSafe.Entry();

            Assert.Equal(3, entry.Records.Count);
            Assert.True(entry.Records.Contains(PwSafe.RecordType.Uuid));
            Assert.True(entry.Records.Contains(PwSafe.RecordType.Title));
            Assert.True(entry.Records.Contains(PwSafe.RecordType.Password));
            Assert.True(entry.Uuid != Guid.Empty);
            Assert.Equal("", entry.Title);
            Assert.Equal("", entry.Password);
        }
Esempio n. 2
0
        public void Entry_Clone()
        {
            var entry = new PwSafe.Entry("Test");

            Assert.Equal(3, entry.Records.Count);
            Assert.True(entry.Records.Contains(PwSafe.RecordType.Uuid));
            Assert.True(entry.Records.Contains(PwSafe.RecordType.Title));
            Assert.True(entry.Records.Contains(PwSafe.RecordType.Password));
            Assert.True(entry.Uuid != Guid.Empty);
            Assert.Equal("Test", entry.Title);
            Assert.Equal("", entry.Password);

            var clone = entry.Clone();

            Assert.Equal(3, clone.Records.Count);
            Assert.True(clone.Records.Contains(PwSafe.RecordType.Uuid));
            Assert.True(clone.Records.Contains(PwSafe.RecordType.Title));
            Assert.True(clone.Records.Contains(PwSafe.RecordType.Password));
            Assert.True(clone.Uuid != Guid.Empty);
            Assert.Equal("Test", clone.Title);
            Assert.Equal("", clone.Password);
        }
Esempio n. 3
0
        private static PwSafe.Entry GetExampleEntry(string autotypeText, bool amexCard = false)
        {
            var entry = new PwSafe.Entry()
            {
                Title                       = "Example",
                Group                       = "Examples",
                UserName                    = "******",
                Password                    = "******",
                CreditCardNumber            = amexCard ? "123 4567 8901 2345" : "1234 5678 9012 3456",
                CreditCardExpiration        = "01/79",
                CreditCardVerificationValue = "123",
                CreditCardPin               = "1234",
                TwoFactorKey                = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 },
                Email                       = "*****@*****.**",
                Url   = "medo64.com",
                Notes = "1\r\n2\n3\r^\n",
            };

            if (autotypeText != null)
            {
                entry.Autotype = autotypeText;
            }
            return(entry);
        }
Esempio n. 4
0
        public void Entry_TestNamed()
        {
            var guid = Guid.NewGuid();

            var doc = new PwSafe.Document("Password")
            {
                TrackAccess = false, TrackModify = false
            };
            var entry = new PwSafe.Entry();

            doc.Entries.Add(entry);

            entry.Uuid                     = guid;
            entry.Group                    = "Group";
            entry.Title                    = "Title";
            entry.UserName                 = "******";
            entry.Notes                    = "Notes";
            entry.Password                 = "******";
            entry.CreationTime             = new DateTime(2001, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            entry.PasswordModificationTime = new DateTime(2002, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            entry.LastAccessTime           = new DateTime(2003, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            entry.PasswordExpiryTime       = new DateTime(2004, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            entry.LastModificationTime     = new DateTime(2005, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            entry.Url                         = "http://example.com";
            entry.Email                       = "*****@*****.**";
            entry.TwoFactorKey                = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            entry.CreditCardNumber            = "1234 5678 9012 3456";
            entry.CreditCardExpiration        = "Title";
            entry.CreditCardVerificationValue = "0987";
            entry.CreditCardPin               = "6543";
            entry.QRCode                      = "https://medo64.com/";

            Assert.Equal(guid, entry.Uuid);
            Assert.Equal("Group", (string)entry.Group);
            Assert.Equal("Title", entry.Title);
            Assert.Equal("UserName", entry.UserName);
            Assert.Equal("Notes", entry.Notes);
            Assert.Equal("Password", entry.Password);
            Assert.Equal(new DateTime(2001, 1, 1, 0, 0, 0, DateTimeKind.Utc), entry.CreationTime);
            Assert.Equal(new DateTime(2002, 1, 1, 0, 0, 0, DateTimeKind.Utc), entry.PasswordModificationTime);
            Assert.Equal(new DateTime(2003, 1, 1, 0, 0, 0, DateTimeKind.Utc), entry.LastAccessTime);
            Assert.Equal(new DateTime(2004, 1, 1, 0, 0, 0, DateTimeKind.Utc), entry.PasswordExpiryTime);
            Assert.Equal(new DateTime(2005, 1, 1, 0, 0, 0, DateTimeKind.Utc), entry.LastModificationTime);
            Assert.Equal("http://example.com", entry.Url);
            Assert.Equal("*****@*****.**", entry.Email);
            Assert.Equal("00-01-02-03-04-05-06-07-08-09", BitConverter.ToString(entry.TwoFactorKey));
            Assert.Equal("1234 5678 9012 3456", entry.CreditCardNumber);
            Assert.Equal("Title", entry.CreditCardExpiration);
            Assert.Equal("0987", entry.CreditCardVerificationValue);
            Assert.Equal("6543", entry.CreditCardPin);
            Assert.Equal("https://medo64.com/", entry.QRCode);

            Assert.Equal(guid, entry[PwSafe.RecordType.Uuid].Uuid);
            Assert.Equal("Group", entry[PwSafe.RecordType.Group].Text);
            Assert.Equal("Title", entry[PwSafe.RecordType.Title].Text);
            Assert.Equal("UserName", entry[PwSafe.RecordType.UserName].Text);
            Assert.Equal("Notes", entry[PwSafe.RecordType.Notes].Text);
            Assert.Equal("Password", entry[PwSafe.RecordType.Password].Text);
            Assert.Equal(new DateTime(2001, 1, 1, 0, 0, 0, DateTimeKind.Utc), entry[PwSafe.RecordType.CreationTime].Time);
            Assert.Equal(new DateTime(2002, 1, 1, 0, 0, 0, DateTimeKind.Utc), entry[PwSafe.RecordType.PasswordModificationTime].Time);
            Assert.Equal(new DateTime(2003, 1, 1, 0, 0, 0, DateTimeKind.Utc), entry[PwSafe.RecordType.LastAccessTime].Time);
            Assert.Equal(new DateTime(2004, 1, 1, 0, 0, 0, DateTimeKind.Utc), entry[PwSafe.RecordType.PasswordExpiryTime].Time);
            Assert.Equal(new DateTime(2005, 1, 1, 0, 0, 0, DateTimeKind.Utc), entry[PwSafe.RecordType.LastModificationTime].Time);
            Assert.Equal("http://example.com", entry[PwSafe.RecordType.Url].Text);
            Assert.Equal("*****@*****.**", entry[PwSafe.RecordType.EmailAddress].Text);
            Assert.Equal("00-01-02-03-04-05-06-07-08-09", BitConverter.ToString(entry[PwSafe.RecordType.TwoFactorKey].GetBytes()));
            Assert.Equal("1234 5678 9012 3456", entry[PwSafe.RecordType.CreditCardNumber].Text);
            Assert.Equal("Title", entry[PwSafe.RecordType.CreditCardExpiration].Text);
            Assert.Equal("0987", entry[PwSafe.RecordType.CreditCardVerificationValue].Text);
            Assert.Equal("6543", entry[PwSafe.RecordType.CreditCardPin].Text);
            Assert.Equal("https://medo64.com/", entry[PwSafe.RecordType.QRCode].Text);
        }