コード例 #1
0
        public void NewUserShouldCreateValidTreeStructure()
        {
            m_treeManager.Initialize(m_database);
            m_treeManager.CreateNewUser("Hans");

            PwGroup usersGroup = TestHelper.GetUsersGroupFor(m_database);

            Assert.AreEqual(1, usersGroup.Entries.UCount);
            Assert.AreEqual(1, usersGroup.Groups.UCount);

            PwGroup userHome = TestHelper.GetUserHomeNodeFor(m_database, 0);

            Assert.AreEqual(1, userHome.Entries.UCount);
            Assert.AreEqual("Hans", userHome.Name);

            PwEntry userEntry = TestHelper.GetUserRootNodeFor(m_database, 0);

            Assert.AreEqual("Hans", userEntry.Strings.ReadSafe(KeeShare.KeeShare.TitleField));
            Assert.IsFalse(userEntry.IsProxyNode());
            Assert.IsFalse(userEntry.IsNormalPwEntry());

            PwEntry userProxy = TestHelper.GetUserRootProxyFor(m_database, 0);

            Assert.AreEqual("Hans", userProxy.Strings.ReadSafe(KeeShare.KeeShare.TitleField));
            Assert.IsTrue(userProxy.IsProxyNode());

            Assert.AreEqual(2, NumberOfEntriesIn(m_database)); // a root node and a proxy node

            IsUsersGroupSane(m_database, 1);
        }
コード例 #2
0
        public void ShouldAllowUsersWithSameName()
        {
            m_treeManager.Initialize(m_database);
            m_treeManager.CreateNewUser("Hans");
            m_treeManager.CreateNewUser("Hans");

            PwGroup usersGroup = TestHelper.GetUsersGroupFor(m_database);

            Assert.AreEqual(2, usersGroup.Entries.UCount);
            Assert.AreEqual(2, usersGroup.Groups.UCount);

            PwGroup userGroup1 = TestHelper.GetUserHomeNodeFor(m_database, 0);

            Assert.AreEqual(1, userGroup1.Entries.UCount);
            Assert.AreEqual("Hans", userGroup1.Name);
            PwGroup userGroup2 = TestHelper.GetUserHomeNodeFor(m_database, 1);

            Assert.AreEqual(1, userGroup2.Entries.UCount);
            Assert.AreEqual("Hans", userGroup2.Name);
            Assert.AreNotSame(userGroup1, userGroup2);

            PwEntry userEntry1 = TestHelper.GetUserRootNodeFor(m_database, 0);

            Assert.AreEqual("Hans", userEntry1.Strings.ReadSafe(KeeShare.KeeShare.TitleField));
            Assert.IsFalse(userEntry1.IsProxyNode());
            Assert.IsFalse(userEntry1.IsNormalPwEntry());
            PwEntry userEntry2 = TestHelper.GetUserRootNodeFor(m_database, 1);

            Assert.AreEqual("Hans", userEntry2.Strings.ReadSafe(KeeShare.KeeShare.TitleField));
            Assert.IsFalse(userEntry2.IsProxyNode());
            Assert.IsFalse(userEntry2.IsNormalPwEntry());
            Assert.AreNotSame(userEntry1, userEntry2);
            Assert.AreNotEqual(userEntry1.Uuid, userEntry2.Uuid);

            PwEntry userProxy1 = TestHelper.GetUserRootProxyFor(m_database, 0);

            Assert.IsTrue(userProxy1.IsProxyNode());
            PwEntry userProxy2 = TestHelper.GetUserRootProxyFor(m_database, 1);

            Assert.IsTrue(userProxy2.IsProxyNode());
            Assert.AreNotSame(userProxy1, userProxy2);
            Assert.AreNotEqual(userProxy1.Strings.ReadSafe(KeeShare.KeeShare.UuidLinkField), userProxy2.Strings.ReadSafe(KeeShare.KeeShare.UuidLinkField));

            Assert.AreEqual(4, NumberOfEntriesIn(m_database)); // each a root node and a proxy node!

            IsUsersGroupSane(m_database, 2);
        }
コード例 #3
0
        public void IsNormalPwEntryTest()
        {
            //should all be false:
            Assert.IsFalse(root1.IsNormalPwEntry());
            Assert.IsFalse(root2.IsNormalPwEntry());
            Assert.IsFalse(pwdProxyTo1.IsNormalPwEntry());
            Assert.IsFalse(pwdProxyTo3.IsNormalPwEntry());
            Assert.IsFalse(pwdProxyTo3_1.IsNormalPwEntry());
            Assert.IsFalse(proxyToRoot1.IsNormalPwEntry());
            Assert.IsFalse(brokenProxy1.IsNormalPwEntry());
            Assert.IsFalse(brokenProxy2.IsNormalPwEntry());

            //should all be true:
            Assert.IsTrue(normalEntry1.IsNormalPwEntry());
            Assert.IsTrue(normalEntry2.IsNormalPwEntry());
            Assert.IsTrue(normalEntry3.IsNormalPwEntry());
        }