public void ShouldNotExportKeeShareNodes() { m_treeManager.Initialize(m_database); var exportPath = GetTestPath(); m_syncManager.AddExportPath(exportPath); var userMrX = TestHelper.GetUserRootNodeByNameFor(m_database, "mrX"); var userMrY = TestHelper.GetUserRootNodeByNameFor(m_database, "mrY"); userMrY.SetPassword(STANDARD_PASSWORD); m_database.GetExportGroup().Groups.GetAt(0).AddEntry(userMrY.CreateProxyNode(), true); m_database.RootGroup.AddEntry(userMrX.CreateProxyNode(), true); m_treeManager.CorrectStructure(); m_database.GetUserHomeFor(userMrY).AddEntry(userMrX.CreateProxyNode(), true); m_database.GetUserHomeFor(userMrX).AddEntry(userMrY.CreateProxyNode(), true); string exportFile = exportPath + SyncSource.FileNameFor(userMrY) + SyncExporter.FileExtension; Assert.IsFalse(File.Exists(exportFile)); m_syncManager.Export(); TestHelper.DelayAction(); Assert.IsTrue(File.Exists(exportFile)); var deltaDBAdamReexport = new PwDatabase(); deltaDBAdamReexport.Open(IOConnectionInfo.FromPath(exportFile), m_standardKey, null); foreach (var entry in deltaDBAdamReexport.RootGroup.GetEntries(true)) { Assert.AreNotEqual(userMrX.GetTitle(), entry.GetTitle()); } foreach (var group in deltaDBAdamReexport.RootGroup.GetGroups(true)) { Assert.AreNotEqual(userMrX.GetTitle(), group.Name); } }
/// <summary> /// The <c>CreateNewUser</c> function creates a new user you /// later can share passwords with. /// This includes a proxy in the UsersGroupName group and also /// creates a new user-specific group in the tree UsersGroupName /// </summary> /// <param name="name">oldUserName of the new user</param> /// <returns>True if all is done properly! False otherwise!</returns> protected Changes CreateNewUser(string name, PwGroup useAsHome = null) { PwEntry newUser = CreateUserNode(name); PwGroup newUserGroup = useAsHome; if (newUserGroup == null) //create a new home for that user { newUserGroup = m_database.GetUserHomeFor(newUser, true); } else { newUserGroup.IconId = PwIcon.UserKey; newUserGroup.Notes += newUser.Uuid.ToHexString(); } //put the userRootNode into his homefolder newUser.SetParent(newUserGroup); //due to better userHandling while dragNdrop we create a proxyNode in the usersGroup PwEntry proxy = newUser.CreateProxyNode(); proxy.SetParent(m_database.GetUsersGroup()); return(Changes.GroupCreated | Changes.EntryCreated); }
/// <summary> /// a fuction which returns a list of all folder which are shared to a specified user /// </summary> /// <param name="userRoot">The rootNode of the user you want to export you data to.</param> /// <returns>A <c>PwObjectList<PwGroup></c> which contains all PwGroups which are shared to /// the given user.</returns> public PwObjectList <PwGroup> GetSharedFolders(PwDatabase database, PwEntry userRoot) { PwObjectList <PwGroup> sharedFolders = new PwObjectList <PwGroup>(); foreach (PwEntry proxy in database.GetAllProxyNodes()) { if (userRoot.Uuid.ToHexString() == proxy.Strings.ReadSafe(KeeShare.UuidLinkField)) { PwGroup group = proxy.ParentGroup; //we don't want to share the "Users"-folder, so if we find it, we skip it! if (group == database.GetUsersGroup()) { continue; } sharedFolders.Add(group); //include all subfolders sharedFolders.Add(group.GetGroups(true)); } } //find the homeFolder and add it to the sharedList sharedFolders.Add(database.GetUserHomeFor(userRoot)); return(sharedFolders); }