public static SyncSource GetSource(string Name) { foreach (Type T in Assembly.GetExecutingAssembly().GetTypes()) { if (T == typeof(SyncSource)) { continue; } if (typeof(SyncSource).IsAssignableFrom(T)) { SyncSource Instance = (SyncSource)Activator.CreateInstance(T); if (Instance.Name.ToLower() == Name.ToLower()) { return(Instance); } } } foreach (Assembly Plugin in LibManager.AvailablePlugins) { foreach (Type T in Plugin.GetTypes()) { if (typeof(SyncSource).IsAssignableFrom(T)) { SyncSource Instance = (SyncSource)Activator.CreateInstance(T); if (Instance.Name.ToLower() == Name.ToLower()) { return(Instance); } } } } return(null); }
public void ShouldExportAfterChangedContent() { PwEntry mrX = TestHelper.GetUserRootNodeFor(m_database, 0); //the first autoExport only checks if there is a delta container allready and if not it will export one //in our case there should be no existing container so a new one will be created. string exportPath = GetTestPath(); PwGroup exportGroup = new PwGroup(true, true, exportPath, PwIcon.Apple); m_database.GetExportGroup().AddGroup(exportGroup, true); exportGroup.AddEntry(mrX.CreateProxyNode(), true); string exportFile = exportPath + SyncSource.FileNameFor(mrX) + SyncExporter.FileExtension; Assert.IsFalse(File.Exists(exportFile)); m_syncManager.RefeshSourcesList(); m_syncManager.Export(); mrX = TestHelper.GetUserRootNodeFor(m_database, 0); Assert.AreEqual("mrX", mrX.GetTitle()); Assert.IsTrue(File.Exists(exportFile)); //now we will change a password that is shared to mrX and then trigger the AutoExport method //like it will happen on any OnChangeEvent. After that again we validate the data in the export container. PwEntry entry1 = m_database.RootGroup.FindEntry(Uuid1, true); entry1.SetTitle("new title"); //due to the fact that the UnitTest is way faster than userIneraction we have to manipulate the lastModTimestamp //because if we don't do that the um.Update() method will maybe use another value to update all references and //then we will have the old title in the stringField TestHelper.SimulateTouch(entry1); //now we run the update methods that will be triggered on every UiChangeEvent m_treeManager.CorrectStructure(); m_syncManager.RefeshSourcesList(); //the autoexport method was triggered by in import or OnSaveEvent only so we have to trigger it manually here m_syncManager.Export(); PwDatabase deltaDB = new PwDatabase(); Assert.DoesNotThrow(delegate { deltaDB.Open(IOConnectionInfo.FromPath(exportFile), m_standardKey, null); }); //as before we want to have the same content except that entry1 should now have a new title! Assert.AreEqual(5, deltaDB.RootGroup.GetEntries(true).UCount); Assert.AreEqual(3, deltaDB.RootGroup.Entries.UCount); Assert.AreEqual("grp1", deltaDB.RootGroup.Groups.GetAt(0).Name); Assert.AreEqual(2, deltaDB.RootGroup.Groups.GetAt(0).Entries.UCount); //now we will test in detail if there are only the expected entries in the created delta container Assert.AreEqual(Uuid1, deltaDB.RootGroup.Entries.GetAt(0).Uuid); Assert.AreEqual(Uuid3, deltaDB.RootGroup.Entries.GetAt(2).Uuid); Assert.AreEqual(Uuid6, deltaDB.RootGroup.Entries.GetAt(1).Uuid); Assert.AreEqual(Uuid4, deltaDB.RootGroup.Groups.GetAt(0).Entries.GetAt(0).Uuid); Assert.AreEqual(Uuid5, deltaDB.RootGroup.Groups.GetAt(0).Entries.GetAt(1).Uuid); Assert.AreEqual("new title", deltaDB.RootGroup.Entries.GetAt(0).GetTitle()); deltaDB.Close(); }
/// <summary> /// Spawns content with the given parent. If no parent is specified it will be parented to the spawn manager itself. /// </summary> /// <param name="dataModel">Data model to use for spawning.</param> /// <param name="localPosition">Local position for the new instance.</param> /// <param name="localRotation">Local rotation for the new instance.</param> /// <param name="localScale">optional local scale for the new instance. If not specified, uses the prefabs scale.</param> /// <param name="parent">Parent to assign to the object.</param> /// <param name="baseName">Base name to use to name the created game object.</param> /// <param name="isOwnedLocally"> /// Indicates if the spawned object is owned by this device or not. /// An object that is locally owned will be removed from the sync system when its owner leaves the session. /// </param> /// <returns>True if spawning succeeded, false if not.</returns> public bool Spawn(SyncSpawnedObject dataModel, Vector3 localPosition, Quaternion localRotation, Vector3?localScale, GameObject parent, string baseName, bool isOwnedLocally, string textMeshStr, int colorOfText) { if (SyncSource == null) { Debug.LogError("Can't spawn an object: PrefabSpawnManager is not initialized."); return(false); } if (dataModel == null) { Debug.LogError("Can't spawn an object: dataModel argument is null."); return(false); } if (parent == null) { parent = gameObject; } // Validate that the prefab is valid GameObject prefabToSpawn = GetPrefab(dataModel, baseName); if (!prefabToSpawn) { return(false); } // Get a name for the object to create string instanceName = CreateInstanceName(baseName); // Add the data model object to the networked array, for networking and history purposes dataModel.Initialize(instanceName, parent.transform.GetFullPath("/")); dataModel.Transform.Position.Value = localPosition; dataModel.Transform.Rotation.Value = localRotation; dataModel.MeshTextString.Value = textMeshStr; dataModel.ColorOfString.Value = colorOfText; if (localScale.HasValue) { dataModel.Transform.Scale.Value = localScale.Value; } else { dataModel.Transform.Scale.Value = prefabToSpawn.transform.localScale; } User owner = null; if (isOwnedLocally) { owner = SharingStage.Instance.Manager.GetLocalUser(); } SyncSource.AddObject(dataModel, owner); return(true); }
public void ShouldExportImportedNodes() { var importDatabase = TestHelper.CreateDatabase(); var importedEntry = new PwEntry(true, true); importedEntry.SetTitle("ImportedEntry"); var importedGroup = new PwGroup(true, true); importedGroup.Name = "ImportedGroup"; importedGroup.AddEntry(importedEntry, true); importDatabase.RootGroup.AddGroup(importedGroup, true); var exportPath = GetTestPath(); m_syncManager.AddExportPath(exportPath); var userMrX = TestHelper.GetUserRootNodeByNameFor(m_database, "mrX"); m_database.GetExportGroup().Groups.GetAt(0).AddEntry(userMrX.CreateProxyNode(), true); m_database.RootGroup.AddEntry(userMrX.CreateProxyNode(), true); var existingEntry = new PwEntry(true, true); existingEntry.SetTitle("ExistingEntry"); m_database.RootGroup.AddEntry(existingEntry, true); m_treeManager.CorrectStructure(); string exportFile = exportPath + SyncSource.FileNameFor(userMrX) + SyncExporter.FileExtension; Assert.IsFalse(File.Exists(exportFile)); Assert.AreEqual(0, m_database.RootGroup.GetEntries(true).Count(e => e.GetTitle() == "ImportedEntry")); Assert.AreEqual(0, m_database.RootGroup.GetGroups(true).Count(g => g.Name == "ImportedGroup")); m_syncManager.Export(); Assert.IsTrue(File.Exists(exportFile)); var importer = new SyncImporterAccessor(); importer.MergeInAccessor(m_database, importDatabase); Assert.AreEqual(1, m_database.RootGroup.GetEntries(true).Count(e => e.GetTitle() == "ImportedEntry")); Assert.AreEqual(1, m_database.RootGroup.GetGroups(true).Count(g => g.Name == "ImportedGroup")); m_syncManager.Export(); Assert.IsTrue(File.Exists(exportFile)); var deltaDBUpdated = new PwDatabase(); deltaDBUpdated.Open(IOConnectionInfo.FromPath(exportFile), m_standardKey, null); Assert.AreEqual(1, deltaDBUpdated.RootGroup.GetEntries(true).Count(e => e.GetTitle() == "ImportedEntry")); Assert.AreEqual(1, deltaDBUpdated.RootGroup.GetGroups(true).Count(g => g.Name == "ImportedGroup")); deltaDBUpdated.Close(); }
/// <summary> /// Spawns content with the given parent. If no parent is specified it will be parented to the spawn manager itself. /// </summary> /// <param name="dataModel">Data model to use for spawning.</param> /// <param name="localPosition">Local position for the new instance.</param> /// <param name="localRotation">Local rotation for the new instance.</param> /// <param name="localScale">optional local scale for the new instance. If not specified, uses the prefabs scale.</param> /// <param name="parent">Parent to assign to the object.</param> /// <param name="baseName">Base name to use to name the created game object.</param> /// <param name="isOwnedLocally"> /// Indicates if the spawned object is owned by this device or not. /// An object that is locally owned will be removed from the sync system when its owner leaves the session. /// </param> /// <returns>True if spawning succeeded, false if not.</returns> public bool Spawn(SyncSpawnedObject dataModel, Vector3 localPosition, Quaternion localRotation, Vector3?localScale, GameObject parent, string baseName, bool isOwnedLocally) { if (SyncSource == null) { //Display Error to user GameObject.Find("MenuController").GetComponent <MenuController>().ShowErrorMessage("No Network Found. \n\nDid you turn it on?"); Debug.LogError("Can't spawn an object: PrefabSpawnManager is not initialized."); return(false); } if (dataModel == null) { Debug.LogError("Can't spawn an object: dataModel argument is null."); return(false); } if (parent == null) { parent = gameObject; } // Validate that the prefab is valid GameObject prefabToSpawn = GetPrefab(dataModel, baseName); if (!prefabToSpawn) { return(false); } // Get a name for the object to create string instanceName = CreateInstanceName(baseName); // Add the data model object to the networked array, for networking and history purposes dataModel.Initialize(instanceName, parent.transform.GetFullPath("/")); dataModel.Transform.Position.Value = localPosition; dataModel.Transform.Rotation.Value = localRotation; if (localScale.HasValue) { dataModel.Transform.Scale.Value = localScale.Value; } else { dataModel.Transform.Scale.Value = prefabToSpawn.transform.localScale; } User owner = null; if (isOwnedLocally) { owner = SharingStage.Instance.Manager.GetLocalUser(); } SyncSource.AddObject(dataModel, owner); return(true); }
private void SetValue(string name, SyncSource value) { try { SetValue(name, (int)value); } catch (Exception ex) { Logger.Error(ex); } }
public void ShouldHandleExportAndImportOfDifferentDatabasesSuccessfully() { var exportKeeShare = new KeeShare.KeeShare(); var exportDatabase = TestHelper.CreateDatabase(); exportKeeShare.Initialize(exportDatabase); var treeManagerAccessor = new TreeManagerAccessor(); treeManagerAccessor.Initialize(exportDatabase); treeManagerAccessor.CreateNewUser("MrX"); exportKeeShare.EnsureValidTree(exportDatabase); var userNode = TestHelper.GetUserRootNodeByNameFor(exportDatabase, "MrX"); var userHome = TestHelper.GetUserHomeNodeByNameFor(exportDatabase, "MrX"); var exportRootEntry = new PwEntry(true, true); exportRootEntry.SetTitle("ExportRootEntry"); exportDatabase.RootGroup.AddEntry(exportRootEntry, true); var exportPath = GetTestPath(); var exportFile = exportPath + SyncSource.FileNameFor(userNode) + SyncExporter.FileExtension; exportKeeShare.AddExportPath(exportPath); var exportTarget = exportDatabase.GetExportGroup().Groups.GetAt(0); exportTarget.AddEntry(userNode.CreateProxyNode(), true); var exportHomeEntry = new PwEntry(true, true); exportHomeEntry.SetTitle("ExportHomeEntry"); userHome.AddEntry(exportHomeEntry, true); exportDatabase.RootGroup.AddEntry(userNode.CreateProxyNode(), true); var importDatabase = TestHelper.CreateDatabase(); var importKeeShare = new KeeShare.KeeShare(); importKeeShare.Initialize(importDatabase); exportKeeShare.Export(); importKeeShare.AddImportPath(exportFile); var importGroup = importDatabase.GetImportGroup().Groups.GetAt(0); var importSource = importGroup.Entries.GetAt(0); importSource.SetPassword(userNode.Strings.ReadSafe(KeeShare.KeeShare.PasswordField)); importKeeShare.EnsureValidTree(importDatabase); Assert.AreEqual(1, importDatabase.RootGroup.GetEntries(true).CloneShallowToList().Count(e => e.GetTitle() == "ExportRootEntry")); Assert.AreEqual(1, importDatabase.RootGroup.GetEntries(true).CloneShallowToList().Count(e => e.GetTitle() == "ExportHomeEntry")); }
public static void SyncFrom(SyncSource Source) { SyncExclusionList Exclusions = LoadExclusions(); foreach (SyncFile LFile in Source.GetFiles("")) { if (!Exclusions.SyncPath(LFile.Path)) { continue; } string RealPath = Path.Combine(PathHelpers.RocketDirectory, LFile.Name); if (!File.Exists(RealPath) || !Source.CompareFiles(LFile.Path, RealPath)) { bool exists = File.Exists(RealPath); File.Delete(RealPath); using (Stream RemoteStream = LFile.GetStream()) using (FileStream LocalStream = new FileStream(RealPath, FileMode.OpenOrCreate, FileAccess.Write)) { RemoteStream.CopyTo(LocalStream); LocalStream.Flush(); LocalStream.Close(); } Source.FilesChanged = true; Source.NewFiles += 1; if (exists) { LogClient.LogMessage($"[Sync][Updated][File]: {LFile.Path}"); } else { LogClient.LogMessage($"[Sync][Created][File]: {LFile.Path}"); } } } foreach (SyncDirectory Dir in Source.GetDirectories("")) { string RealPath = Path.Combine(PathHelpers.RocketDirectory, Dir.Name); if (Exclusions.SyncPath(Dir.Path)) { if (!Directory.Exists(RealPath)) { Source.FilesChanged = true; Directory.CreateDirectory(RealPath); LogClient.LogMessage($"[Sync][Created][Dir] : {Dir.Path}"); } SyncDirectory(Source, Dir.Path, Exclusions); } } }
public void ShouldExportToTargets() { //we change the password which is used to encrypt the delta container so we can later access the delta container //more easily. PwEntry mrX = TestHelper.GetUserRootNodeFor(m_database, 0); //the first autoExport only checks if there is a delta container allready and if not it will export one //in our case there should be no existing container so a new one will be created. var exportFolder = m_database.GetExportGroup(); Assert.IsTrue(0 == exportFolder.Groups.UCount); string exportPath = GetTestPath(); m_syncManager.AddExportPath(exportPath); var exportGroup = exportFolder.Groups.GetAt(0); exportGroup.AddEntry(mrX.CreateProxyNode(), true); string exportFile = exportPath + SyncSource.FileNameFor(mrX) + SyncExporter.FileExtension; Assert.IsFalse(File.Exists(exportFile)); m_syncManager.RefeshSourcesList(); m_syncManager.Export(); mrX = TestHelper.GetUserRootNodeFor(m_database, 0); Assert.AreEqual("mrX", mrX.Strings.ReadSafe(KeeShare.KeeShare.TitleField)); Assert.IsTrue(File.Exists(exportFile)); //now we open the creted delta container and verify the contend PwDatabase deltaDB = new PwDatabase(); Assert.DoesNotThrow(delegate { deltaDB.Open(IOConnectionInfo.FromPath(exportFile), m_standardKey, null); }); Assert.AreEqual(5, deltaDB.RootGroup.GetEntries(true).UCount); Assert.AreEqual(3, deltaDB.RootGroup.Entries.UCount); Assert.AreEqual("grp1", deltaDB.RootGroup.Groups.GetAt(0).Name); Assert.AreEqual(2, deltaDB.RootGroup.Groups.GetAt(0).Entries.UCount); //now we will test in detail if there are only the expected entries in the created delta container Assert.AreEqual(Uuid1, deltaDB.RootGroup.Entries.GetAt(0).Uuid); Assert.AreEqual(Uuid3, deltaDB.RootGroup.Entries.GetAt(2).Uuid); Assert.AreEqual(Uuid6, deltaDB.RootGroup.Entries.GetAt(1).Uuid); Assert.AreEqual(Uuid4, deltaDB.RootGroup.Groups.GetAt(0).Entries.GetAt(0).Uuid); Assert.AreEqual(Uuid5, deltaDB.RootGroup.Groups.GetAt(0).Entries.GetAt(1).Uuid); Assert.AreEqual("normalEntry1", deltaDB.RootGroup.Entries.GetAt(0).GetTitle()); deltaDB.Close(); }
public void ShouldIgnoreUsersWithoutTargets() { PwEntry mrY = m_database.GetUsersGroup().Groups.GetAt(1).Entries.GetAt(0); Assert.AreEqual("mrY", mrY.Strings.ReadSafe(KeeShare.KeeShare.TitleField)); string exportPath = GetTestPath(); string exportFile = exportPath + SyncSource.FileNameFor(mrY) + SyncExporter.FileExtension; Assert.IsFalse(File.Exists(exportFile)); m_syncManager.RefeshSourcesList(); m_syncManager.Export(); Assert.IsFalse(File.Exists(exportFile)); }
private SyncSource GetValue(string name, SyncSource defValue) { try { var iValue = GetValue(name, (int)defValue); if (Enum.IsDefined(typeof(SyncSource), iValue)) { return((SyncSource)iValue); } return(defValue); } catch (Exception ex) { Logger.Error(ex); return(defValue); } }
public void Init() { LogClient.LogMessage("Loading PatchMod"); if (!System.IO.Directory.Exists(PathHelpers.PatchModDepDirectory)) { LogClient.LogMessage($"ERROR: Missing lib directory at {PathHelpers.PatchModDepDirectory}"); } LibManager.LoadDeps(); PathHelpers.CheckDirectories(); LibManager.LoadPlugins(); LogClient.LogMessage("PatchMod Loaded"); Patcher.Patch(); if (Patcher.PatchMessageSent) { LogClient.LogMessage($"Patches Complete"); } if ((bool)PatchMod.Config["SyncEnabled", typeof(bool)]) { SyncSource S = SyncProviderManager.GetSource((string)PatchMod.Config["SyncMode"]); if (S == null) { LogClient.LogMessage($"Invalid Sync Source '{(string)PatchMod.Config["SyncMode"]}'"); } else { S.Source = (string)PatchMod.Config["SyncPath"]; S.Init(); LogClient.LogMessage($"Starting Sync..."); FileSync.SyncFrom(S); if (S.FilesChanged) { LogClient.LogMessage($"Files synced from server. Acquired {S.NewFiles} new file/s from server."); } else { LogClient.LogMessage($"Files are up to date."); } S.Shutdown(); } } }
public void ShouldHandleCyclesOfNodesInImportAndExport() { var exportPath = GetTestPath(); m_syncManager.AddExportPath(exportPath); var userMrX = TestHelper.GetUserRootNodeByNameFor(m_database, "mrX"); m_database.GetExportGroup().Groups.GetAt(0).AddEntry(userMrX.CreateProxyNode(), true); var existingEntry = new PwEntry(true, true); existingEntry.SetTitle("Entry Version 1"); m_database.RootGroup.AddEntry(existingEntry, true); m_database.RootGroup.AddEntry(userMrX.CreateProxyNode(), true); m_treeManager.CorrectStructure(); string exportFile = exportPath + SyncSource.FileNameFor(userMrX) + SyncExporter.FileExtension; Assert.IsFalse(File.Exists(exportFile)); m_syncManager.Export(); var deltaDBInitial = new PwDatabase(); deltaDBInitial.Open(IOConnectionInfo.FromPath(exportFile), m_standardKey, null); Assert.AreEqual(1, deltaDBInitial.RootGroup.GetEntries(true).Count(e => e.GetTitle() == "Entry Version 1")); foreach (var entry in deltaDBInitial.RootGroup.GetEntries(true)) { entry.SetTitle("Changed"); } deltaDBInitial.Save(null); deltaDBInitial.Close(); m_syncManager.AddImportPath(exportFile); m_database.GetImportGroup().Groups.GetAt(0).Entries.GetAt(0).SetPassword(userMrX.Strings.ReadSafe(KeeShare.KeeShare.PasswordField)); m_syncManager.RefeshSourcesList(); // Node normalEntry6 is within the user home and is relocated on export which changes the parent node - during import, the parents of // not "officially" relocated nodes is checked and an assertion is thrown Assert.AreEqual(0, m_database.RootGroup.GetEntries(true).Count(e => e.GetTitle() == "Changed")); }
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); } }
public void ShouldNotImportDatabasesWithDifferentUsers() { var exportPath = GetTestPath(); m_syncManager.AddExportPath(exportPath); var userMrX = TestHelper.GetUserRootNodeByNameFor(m_database, "mrX"); var userMrY = TestHelper.GetUserRootNodeByNameFor(m_database, "mrY"); m_database.GetExportGroup().Groups.GetAt(0).AddEntry(userMrY.CreateProxyNode(), true); var existingEntry = new PwEntry(true, true); existingEntry.SetTitle("Entry Version 1"); m_database.RootGroup.AddEntry(existingEntry, true); m_database.RootGroup.AddEntry(userMrY.CreateProxyNode(), true); m_treeManager.CorrectStructure(); string exportFile = exportPath + SyncSource.FileNameFor(userMrY) + SyncExporter.FileExtension; Assert.IsFalse(File.Exists(exportFile)); m_syncManager.Export(); existingEntry.SetTitle("Entry Version 2"); var deltaDBInitial = new PwDatabase(); deltaDBInitial.Open(IOConnectionInfo.FromPath(exportFile), m_standardKey, null); Assert.AreEqual(0, deltaDBInitial.RootGroup.GetEntries(true).Count(e => e.GetTitle() == "Entry Version 2")); Assert.AreEqual(1, deltaDBInitial.RootGroup.GetEntries(true).Count(e => e.GetTitle() == "Entry Version 1")); deltaDBInitial.Close(); m_syncManager.AddImportPath(exportFile); m_database.GetImportGroup().Groups.GetAt(0).Entries.GetAt(0).SetPassword("InvalidPassword"); m_syncManager.RefeshSourcesList(); Assert.AreEqual(1, m_database.RootGroup.GetEntries(true).Count(e => e.GetTitle() == "Entry Version 2")); Assert.AreEqual(0, m_database.RootGroup.GetEntries(true).Count(e => e.GetTitle() == "Entry Version 1")); }
public bool CheckSyncSourceSupported(SyncSource value) { switch (value) { case SyncSource.None: return(true); case SyncSource.Time: var timeSync = m_timeSync; return(timeSync != null && timeSync.IsSyncSupported); case SyncSource.Sound: var sound = m_sound; return(sound != null && sound.IsSyncSupported); case SyncSource.Video: var video = m_video; return(video != null && video.IsSyncSupported); default: return(false); } }
public override void Delete(SyncSpawnedObject objectToDelete) { SyncSource.RemoveObject(objectToDelete); }
public void ShouldOnlyExportToCurrentSharedUsers() { m_treeManager.Initialize(m_database); var exportPath = GetTestPath(); m_syncManager.AddExportPath(exportPath); var exportGroup = m_database.GetExportGroup().Groups.GetAt(0); m_treeManager.CreateNewUser("Adam"); m_treeManager.CreateNewUser("Eva"); var userAdam = TestHelper.GetUserRootNodeByNameFor(m_database, "Adam"); var userEva = TestHelper.GetUserRootNodeByNameFor(m_database, "Eva"); userAdam.SetPassword(STANDARD_PASSWORD); userEva.SetPassword(STANDARD_PASSWORD); m_database.RootGroup.AddEntry(userAdam.CreateProxyNode(), true); m_database.RootGroup.AddEntry(userEva.CreateProxyNode(), true); exportGroup.AddEntry(userAdam.CreateProxyNode(), true); exportGroup.AddEntry(userEva.CreateProxyNode(), true); m_treeManager.CorrectStructure(); string exportFileAdam = exportPath + SyncSource.FileNameFor(userAdam) + SyncExporter.FileExtension; string exportFileEva = exportPath + SyncSource.FileNameFor(userEva) + SyncExporter.FileExtension; Assert.IsFalse(File.Exists(exportFileAdam)); Assert.IsFalse(File.Exists(exportFileEva)); m_syncManager.Export(); // TODO CK: At this point it may be possible that the files are not created - we need to wait for the filesystem to respond - maybe using a delay? Assert.IsTrue(File.Exists(exportFileAdam)); Assert.IsTrue(File.Exists(exportFileEva)); var homeAdam = TestHelper.GetUserHomeNodeByNameFor(m_database, "Adam"); homeAdam.ParentGroup.Groups.Remove(homeAdam); var trash = m_database.RootGroup.FindGroup(m_database.RecycleBinUuid, true); trash.AddGroup(homeAdam, true); trash.DeleteAllObjects(m_database); //update should delete all references to the non existing user m_treeManager.CorrectStructure(); var changedEntry = m_database.RootGroup.Entries.GetAt(0); changedEntry.SetTitle("Changed"); TestHelper.SimulateTouch(changedEntry); m_syncManager.Export(); TestHelper.DelayAction(); var deltaDBAdamReexport = new PwDatabase(); deltaDBAdamReexport.Open(IOConnectionInfo.FromPath(exportFileAdam), m_standardKey, null); Assert.AreEqual(Uuid1, deltaDBAdamReexport.RootGroup.Entries.GetAt(0).Uuid); Assert.AreNotEqual("Changed", deltaDBAdamReexport.RootGroup.Entries.GetAt(0).GetTitle()); deltaDBAdamReexport.Close(); var deltaDBEvaReexport = new PwDatabase(); deltaDBEvaReexport.Open(IOConnectionInfo.FromPath(exportFileEva), m_standardKey, null); Assert.AreEqual(Uuid1, deltaDBEvaReexport.RootGroup.Entries.GetAt(0).Uuid); Assert.AreEqual("Changed", deltaDBEvaReexport.RootGroup.Entries.GetAt(0).GetTitle()); deltaDBEvaReexport.Close(); }
public override void Delete(SyncSpawnedObject objectToDelete) { print("Deleting locally"); SyncSource.RemoveObject(objectToDelete); }
private void FillInFixture() { PwGroup rootGroup = m_database.RootGroup; m_treeManager.CreateNewUser("mrX"); m_treeManager.CreateNewUser("mrY"); m_standardKey = SyncSource.CreateKeyFor(STANDARD_PASSWORD); PwEntry mrX = TestHelper.GetUserRootNodeByNameFor(m_database, "mrX"); PwEntry mrY = TestHelper.GetUserRootNodeByNameFor(m_database, "mrY"); mrX.SetPassword(STANDARD_PASSWORD); mrY.SetPassword(STANDARD_PASSWORD); PwGroup mrXhome = m_database.GetUsersGroup().Groups.GetAt(0); //normal entries PwEntry normalEntry1 = new PwEntry(true, false); normalEntry1.SetTitle("normalEntry1"); Uuid1 = normalEntry1.Uuid; PwEntry normalEntry2 = new PwEntry(true, false); normalEntry2.SetTitle("normalEntry2"); Uuid2 = normalEntry2.Uuid; PwEntry normalEntry3 = new PwEntry(true, false); normalEntry3.SetTitle("normalEntry3"); Uuid3 = normalEntry3.Uuid; PwEntry normalEntry4 = new PwEntry(true, false); normalEntry4.SetTitle("normalEntry4"); Uuid4 = normalEntry4.Uuid; PwEntry normalEntry5 = new PwEntry(true, false); normalEntry5.SetTitle("normalEntry5"); Uuid5 = normalEntry5.Uuid; PwEntry normalEntry6 = new PwEntry(true, false); normalEntry6.SetTitle("normalEntry6"); Uuid6 = normalEntry6.Uuid; //pwdProxies PwEntry pwdProxyTo1 = normalEntry1.CreateProxyNode(); PwEntry pwdProxyTo3 = normalEntry3.CreateProxyNode(); //userProxies PwEntry userProxyToMrX = mrX.CreateProxyNode(); PwGroup grp1 = new PwGroup(true, true, "grp1", PwIcon.BlackBerry); rootGroup.AddEntry(normalEntry1, true); rootGroup.AddEntry(normalEntry2, true); rootGroup.AddEntry(normalEntry3, true); rootGroup.AddGroup(grp1, true); grp1.AddEntry(normalEntry4, true); grp1.AddEntry(normalEntry5, true); grp1.AddEntry(userProxyToMrX, true); grp1.AddEntry(pwdProxyTo1, true); mrXhome.AddEntry(normalEntry6, true); mrXhome.AddEntry(pwdProxyTo3, true); Assert.AreEqual(13, rootGroup.GetEntries(true).UCount); }