public void SaveSettings_PreexistsAndWeSave_MovesCredentials([Values(true, false)] bool isResumable) { ServerSettingsModel.PasswordForSession = Settings.Default.LanguageForgePass = Settings.Default.LanguageForgeUser = null; using (var folder = new TemporaryFolder("ServerSettingsModel")) { const string user = "******"; const string pass = "******"; var subdomain = isResumable ? "resumable" : "hg-public"; var oldHost = $"{subdomain}.languagedepot.org/tpi"; var oldUrl = $"https://{user}:{pass}@{oldHost}"; const string newDomainAndProj = ".languageforge.org/tpi"; var newUrl = $"https://{subdomain}{newDomainAndProj}"; var newUrlWithCredentials = $"https://{user}:{pass}@{subdomain}{newDomainAndProj}"; // Precondition is some url that is not our default from the ServerSettingsModel var original = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); original.SetKnownRepositoryAddresses(new[] { new HttpRepositoryPath("languageForge.org [legacy sync]", oldUrl, false) }); var m = new ServerSettingsModel(); m.InitFromProjectPath(folder.Path); m.SaveSettings(); Assert.AreEqual(user, Settings.Default.LanguageForgeUser); Assert.AreEqual(pass, ServerSettingsModel.DecryptPassword(Settings.Default.LanguageForgePass)); Assert.That(folder.Combine(".hg"), Does.Exist); Assert.That(folder.Combine(".hg", "hgrc"), Does.Exist); var repo = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); var address = repo.GetDefaultNetworkAddress <HttpRepositoryPath>(); Assert.AreEqual(newUrl, address.URI); Assert.AreEqual(isResumable ? newUrl : newUrlWithCredentials, address.GetPotentialRepoUri(null, null, null), "The new 'potential' URI should contain credentials only when non-resumable"); } }
public void DefaultUrlsAreIgnored() { using (var folder = new TemporaryFolder("ServerSettingsModel")) { var original = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); original.SetKnownRepositoryAddresses(new[] { new HttpRepositoryPath("default", "c://abc.com", false) }); var m = new ServerSettingsModel(); const string url = "unclickable://hg-private.languageforge.org/tpi"; m.InitFromProjectPath(folder.Path); m.SetUrlToUseIfSettingsAreEmpty(url); Assert.AreEqual(url, m.URL); } }
public void SetUrlToUseIfSettingsAreEmpty_RepoAlreadyExistsWithAServerAddress_IgnoresOfferedUrl() { using (var folder = new TemporaryFolder("ServerSettingsModel")) { var original = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); var existing = "https://abc.com"; original.SetKnownRepositoryAddresses(new[] { new HttpRepositoryPath("languageforge.org [Safe Mode]", existing, false) }); var m = new ServerSettingsModel(); var url = "https://*****:*****@hg-public.languageforge.org/tpi"; m.InitFromProjectPath(folder.Path); m.SetUrlToUseIfSettingsAreEmpty(url); Assert.AreEqual(existing, m.URL); } }
public void DefaultUrlsAreIgnored() { using (var folder = new TemporaryFolder("ServerSettingsModel")) { var original = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); var existing = "c://abc.com"; original.SetKnownRepositoryAddresses(new[] { new HttpRepositoryPath("default", existing, false) }); var m = new ServerSettingsModel(); var url = "c://*****:*****@hg-public.languagedepot.org/tpi"; m.InitFromProjectPath(folder.Path); m.SetUrlToUseIfSettingsAreEmpty(url); Assert.AreEqual(url, m.URL); } }
public void SaveSettings_NoHgFolderExists_CreatesOneWithCorrectPath() { using (var folder = new TemporaryFolder("ServerSettingsModel")) { var m = new ServerSettingsModel(); var url = "http://*****:*****@hg-public.languagedepot.org/tpi"; m.InitFromProjectPath(folder.Path); m.SetUrlToUseIfSettingsAreEmpty(url); m.SaveSettings(); Assert.IsTrue(Directory.Exists(folder.Combine(".hg"))); Assert.IsTrue(File.Exists(folder.Combine(".hg", "hgrc"))); var repo = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); var address = repo.GetDefaultNetworkAddress <HttpRepositoryPath>(); Assert.AreEqual("languageDepot.org[safemode]".ToLower(), address.Name.ToLower()); Assert.AreEqual(url, address.URI); } }
public void SaveSettings_ForgetsPassword() { ServerSettingsModel.PasswordForSession = null; using (var folder = new TemporaryFolder("ServerSettingsModel")) { const string user = "******"; const string pass = "******"; var m = new ServerSettingsModel { Username = user, Password = pass, RememberPassword = false }; m.InitFromProjectPath(folder.Path); m.SaveSettings(); Assert.AreEqual(user, Settings.Default.LanguageForgeUser); Assert.Null(Settings.Default.LanguageForgePass); Assert.AreEqual(pass, ServerSettingsModel.PasswordForSession); var repo = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); var address = repo.GetDefaultNetworkAddress <HttpRepositoryPath>(); Assert.That(address.URI, Does.Not.Contain(pass)); } }
public SendReceiveSettings(string repositoryLocation) { InitializeComponent(); RequireThat.Directory(repositoryLocation).Exists(); var repository = HgRepository.CreateOrUseExisting(repositoryLocation, new NullProgress()); _model = new SettingsModel(repository); userNameTextBox.Text = _model.GetUserName(new NullProgress()); _internetModel = new ServerSettingsModel(); _internetModel.InitFromProjectPath(repositoryLocation); _serverSettingsControl.Model = _internetModel; _internetButtonEnabledCheckBox.CheckedChanged += internetCheckChanged; _internetButtonEnabledCheckBox.Checked = Properties.Settings.Default.InternetEnabled; _serverSettingsControl.Enabled = _internetButtonEnabledCheckBox.Checked; _showChorusHubInSendReceive.Checked = Properties.Settings.Default.ShowChorusHubInSendReceive; }
public void SaveSettings_PrexistsButWeChangePasswordAndSave_ChangesPassword() { using (var folder = new TemporaryFolder("ServerSettingsModel")) { // Precondition is some url that is not our default from the ServerSettingsModel var original = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); original.SetKnownRepositoryAddresses(new[] { new HttpRepositoryPath("languagedepot.org [legacy sync]", "http://*****:*****@hg-public.languagedepot.org/tpi", false) }); var m = new ServerSettingsModel(); m.InitFromProjectPath(folder.Path); m.Password = "******"; m.SaveSettings(); Assert.IsTrue(Directory.Exists(folder.Combine(".hg"))); Assert.IsTrue(File.Exists(folder.Combine(".hg", "hgrc"))); var repo = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); var address = repo.GetDefaultNetworkAddress <HttpRepositoryPath>(); Assert.AreEqual("http://*****:*****@hg-public.languagedepot.org/tpi", address.URI); Assert.AreEqual("newPassword", address.Password); } }
public void SaveSettings_NoHgFolderExists_CreatesOneWithCorrectPath() { using (var folder = new TemporaryFolder("ServerSettingsModel")) { const string user = "******"; const string pass = "******"; const string host = "hg-public.languageforge.org/tpi"; const string url = "https://" + user + ":" + pass + "@" + host; var m = new ServerSettingsModel(); m.InitFromProjectPath(folder.Path); m.SetUrlToUseIfSettingsAreEmpty(url); m.SaveSettings(); Assert.That(folder.Combine(".hg"), Does.Exist); Assert.That(folder.Combine(".hg", "hgrc"), Does.Exist); var repo = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); var address = repo.GetDefaultNetworkAddress <HttpRepositoryPath>(); Assert.AreEqual(new ServerSettingsModel.BandwidthItem(ServerSettingsModel.BandwidthEnum.High), m.Bandwidth); Assert.AreEqual("https://" + host, address.URI); Assert.AreEqual(user, m.Username); Assert.AreEqual(pass, m.Password); } }
public void SaveSettings_PrexistsButWeChangePasswordAndSave_ChangesPassword() { using (var folder = new TemporaryFolder("ServerSettingsModel")) { // Precondition is some url that is not our default from the ServerSettingsModel var original = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); original.SetKnownRepositoryAddresses(new[] { new HttpRepositoryPath("languagedepot.org [legacy sync]", "http://*****:*****@hg-public.languagedepot.org/tpi", false) }); var m = new ServerSettingsModel(); m.InitFromProjectPath(folder.Path); m.Password = "******"; m.SaveSettings(); Assert.IsTrue(Directory.Exists(folder.Combine(".hg"))); Assert.IsTrue(File.Exists(folder.Combine(".hg", "hgrc"))); var repo = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); var address = repo.GetDefaultNetworkAddress<HttpRepositoryPath>(); Assert.AreEqual("http://*****:*****@hg-public.languagedepot.org/tpi", address.URI); Assert.AreEqual("newPassword", address.Password); } }
public void SaveSettings_NoHgFolderExists_CreatesOneWithCorrectPath() { using (var folder = new TemporaryFolder("ServerSettingsModel")) { var m = new ServerSettingsModel(); var url = "http://*****:*****@hg-public.languagedepot.org/tpi"; m.InitFromProjectPath(folder.Path); m.SetUrlToUseIfSettingsAreEmpty(url); m.SaveSettings(); Assert.IsTrue(Directory.Exists(folder.Combine(".hg"))); Assert.IsTrue(File.Exists(folder.Combine(".hg","hgrc"))); var repo = HgRepository.CreateOrUseExisting(folder.Path, new NullProgress()); var address = repo.GetDefaultNetworkAddress<HttpRepositoryPath>(); Assert.AreEqual("languageDepot.org[safemode]".ToLower(), address.Name.ToLower()); Assert.AreEqual(url, address.URI); } }