Ejemplo n.º 1
0
        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");
            }
        }
Ejemplo n.º 2
0
 private void okButton_Click(object sender, EventArgs e)
 {
     if (_internetButtonEnabledCheckBox.Checked)
     {
         _internetModel.SaveSettings();
     }
     _model.SaveSettings();
     Properties.Settings.Default.InternetEnabled            = _internetButtonEnabledCheckBox.Checked;
     Properties.Settings.Default.ShowChorusHubInSendReceive = _showChorusHubInSendReceive.Checked;
     Properties.Settings.Default.Save();
     DialogResult = DialogResult.OK;
     Close();
 }
Ejemplo n.º 3
0
 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);
     }
 }
Ejemplo n.º 4
0
 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));
     }
 }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 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);
     }
 }
Ejemplo n.º 7
0
        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);
            }
        }
Ejemplo n.º 8
0
 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);
     }
 }