public void InitFromUri_FullTypicalLangDepot_PasswordCorrect()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("http://*****:*****@hg-public.languagedepot.org/tpi");
            Assert.AreEqual("pass", m.Password);
        }
        public void InitFromUri_FullPrivateLangDepot_SelectedServerLabel()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("http://*****:*****@hg-private.languagedepot.org/tpi");
            Assert.AreEqual("LanguageDepot.org [private]".ToLower(), m.SelectedServerLabel.ToLower());
        }
        public void InitFromUri_FullTypicalLangDepot_SelectedServerLabel()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("http://*****:*****@hg-public.languagedepot.org/tpi");
            Assert.AreEqual("languagedepot.org [safe mode]", m.SelectedServerLabel.ToLower());
        }
Пример #4
0
        public void InitFromUri_LanguageDepot_ConvertedToLanguageForge(string subdomain, bool isResumable)
        {
            try
            {
                if (subdomain.Equals("hg-private"))
                {
                    // Setting IsPrivateServer is necessary to prevent hg-private.languageforge.org being marked as custom.
                    // If IsPrivateServer is set incorrectly (either way), the URL will be imported and scrubbed correctly,
                    // but marked as custom (tested in other tests)
                    ServerSettingsModel.IsPrivateServer = true;
                }

                var expectedNewHost   = $"{subdomain}.languageforge.org";
                var expectedBandwidth = isResumable
                                        ? ServerSettingsModel.BandwidthEnum.Low
                                        : ServerSettingsModel.BandwidthEnum.High;
                var m = new ServerSettingsModel();
                // SUT
                // ReSharper disable once StringLiteralTypo - the old server used to be called Language Depot
                m.InitFromUri($"http://*****:*****@{subdomain}.languagedepot.org/mcx");

                Assert.False(m.IsCustomUrl);

                Assert.AreEqual(expectedNewHost, m.Host);
                Assert.AreEqual("joe", m.Username);
                Assert.AreEqual("cool", m.Password);
                Assert.AreEqual(expectedBandwidth, m.Bandwidth.Value);
                Assert.AreEqual("mcx", m.ProjectId);
                Assert.AreEqual($"https://{expectedNewHost}/mcx", m.URL);
            }
            finally
            {
                ServerSettingsModel.IsPrivateServer = false;
            }
        }
        public void InitFromUri_FullTypicalLangDepot_CustomUrlFalse()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("http://*****:*****@hg-public.languagedepot.org/tpi");
            Assert.IsFalse(m.CustomUrlSelected);
        }
Пример #6
0
        public void InitFromUri_UnknownHttpGiven_CustomUrlIsTrue()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("https://somewhereelse.net/xyz");
            Assert.IsTrue(m.IsCustomUrl);
        }
Пример #7
0
        public void InitFromUri_HasFolderDesignator_IdIsCorrect()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("https://*****:*****@hg-public.languageforge.org/tpi?localFolder=foo");
            Assert.AreEqual("tpi", m.ProjectId);
        }
Пример #8
0
        public void InitFromUri_LANPathGiven_CustomUrlIsTrue()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("\\mybox\tpi");
            Assert.IsTrue(m.IsCustomUrl);
        }
Пример #9
0
        public void InitFromUri_FullTypicalLangForge_AccountNameCorrect()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("https://*****:*****@hg-public.languageforge.org/tpi");
            Assert.AreEqual("joe", m.Username);
        }
Пример #10
0
        public void InitFromUri_FullTypicalLangForge_ProjectIdCorrect()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("https://*****:*****@hg-public.languageforge.org/tpi");
            Assert.AreEqual("tpi", m.ProjectId);
        }
Пример #11
0
        public void InitFromUri_LANPathGiven_SelectedServerLabelIsCorrect()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("\\mybox\tpi");
            Assert.IsTrue(m.SelectedServerLabel.ToLower().Contains("custom"));
        }
Пример #12
0
        public void InitFromUri_FullTypicalLangDepot_SelectedServerPathCorrect()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("http://*****:*****@hg-public.languagedepot.org/tpi");
            Assert.AreEqual("hg-public.languagedepot.org", m.SelectedServerPath);
        }
Пример #13
0
        public void InitFromUri_ResumableLangForge_DomainAndBandwidthCorrectAndNotCustom()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("https://resumable.languageforge.org/tpi");
            Assert.AreEqual("resumable.languageforge.org", m.Host);
            Assert.AreEqual(ServerSettingsModel.BandwidthEnum.Low, m.Bandwidth.Value);
            Assert.False(m.IsCustomUrl);
        }
Пример #14
0
        public void InitFromUri_FullTypicalLangForge_ExistingProjectIdDisplayedOnLoad(
            [Values(true, false)] bool hasProjId)
        {
            const string proj = "tpi";
            var          m    = new ServerSettingsModel();

            m.InitFromUri($"https://*****:*****@hg-public.languageforge.org/{(hasProjId ? proj : string.Empty)}");
            Assert.AreEqual(hasProjId, m.HasLoggedIn);
        }
Пример #15
0
        public void InitFromUri_FullTypicalLangForge_DomainAndBandwidthCorrectAndNotCustom()
        {
            var m = new ServerSettingsModel();

            m.InitFromUri("https://*****:*****@hg-public.languageforge.org/tpi");
            Assert.AreEqual("hg-public.languageforge.org", m.Host);
            Assert.AreEqual(ServerSettingsModel.BandwidthEnum.High, m.Bandwidth.Value);
            Assert.False(m.IsCustomUrl);
        }
Пример #16
0
        private static void LaunchCustomUrl(string url)
        {
            var model = new ServerSettingsModel();

            model.InitFromUri(url);
            using (var dlg = new ServerSettingsDialog(model))
            {
                dlg.ShowDialog();
            }
        }
Пример #17
0
        public void InitFromUri_UsernameAndPass_OverwritesSettings()
        {
            Settings.Default.LanguageForgeUser = "******";
            Settings.Default.LanguageForgePass = ServerSettingsModel.EncryptPassword("settings");
            var m = new ServerSettingsModel();

            m.InitFromUri("https://*****:*****@hg-public.languageforge.org/tps");
            Assert.AreEqual("jan", m.Username);
            Assert.AreEqual("pass", m.Password);
            Assert.AreEqual("tps", m.ProjectId);
        }
Пример #18
0
        private void LaunchCustomUrl(string url)
        {
            var model = new ServerSettingsModel();

            model.InitFromUri(url);
            using (var dlg = new ServerSettingsDialog(model))
            {
                if (DialogResult.OK != dlg.ShowDialog())
                {
                    return;
                }
            }
        }
Пример #19
0
        public void InitFromUri_NoUsernameOrPass_UsesSettings()
        {
            const string user = "******";
            const string pass = "******";

            Settings.Default.LanguageForgeUser = user;
            Settings.Default.LanguageForgePass = ServerSettingsModel.EncryptPassword(pass);
            var m = new ServerSettingsModel();

            m.InitFromUri("https://hg.languageforge.org/tpi");
            Assert.AreEqual(user, m.Username);
            Assert.AreEqual(pass, m.Password);
            Assert.AreEqual("tpi", m.ProjectId);
        }
Пример #20
0
        public void InitFromUri_CredentialsOriginallySetFromModelWithSpecialCharacters_AbleToRoundTripCredentialsBackFromURIOK()
        {
            var model = new ServerSettingsModel();
            const string accountName = "*****@*****.**";
            const string password = "******";
            const string projectId = "projectId";
            model.AccountName = accountName;
            model.Password = password;
            model.ProjectId = projectId;
            var urlWithEncodedChars = model.URL;

            var newModel = new ServerSettingsModel();
            newModel.InitFromUri(urlWithEncodedChars);
            Assert.AreEqual(accountName, newModel.AccountName);
            Assert.AreEqual(password, newModel.Password);
            Assert.AreEqual(projectId, newModel.ProjectId);
        }
Пример #21
0
        public void InitFromUri_CredentialsOriginallySetFromModelWithSpecialCharacters_AbleToRoundTripCredentialsBackFromURIOK()
        {
            var          model       = new ServerSettingsModel();
            const string accountName = "*****@*****.**";
            const string password    = "******";
            const string projectId   = "projectId";

            model.AccountName = accountName;
            model.Password    = password;
            model.ProjectId   = projectId;
            var urlWithEncodedChars = model.URL;

            var newModel = new ServerSettingsModel();

            newModel.InitFromUri(urlWithEncodedChars);
            Assert.AreEqual(accountName, newModel.AccountName);
            Assert.AreEqual(password, newModel.Password);
            Assert.AreEqual(projectId, newModel.ProjectId);
        }
Пример #22
0
        public void InitFromUri_UnknownHttpGiven_InitializesEverything()
        {
            const string user        = "******";
            const string pass        = "******";
            const string proj        = "ngl";
            const string host        = "chorus.elsewhere.net";
            const string hostAndProj = host + "/" + proj;
            // URL is intentionally insecure: just in case some self-hosting user hasn't implemented security
            const string url = "http://" + user + ":" + pass + "@" + hostAndProj;
            const string urlSansCredentials = "http://" + hostAndProj;
            var          m = new ServerSettingsModel();

            // SUT
            m.InitFromUri(url);

            Assert.IsTrue(m.IsCustomUrl);
            Assert.AreEqual(host, m.Host);
            Assert.AreEqual(user, m.Username);
            Assert.AreEqual(pass, m.Password);
            Assert.AreEqual(ServerSettingsModel.BandwidthEnum.High, m.Bandwidth.Value, "Custom URL's aren't known to be resumable");
            Assert.AreEqual(proj, m.ProjectId);
            Assert.AreEqual(urlSansCredentials, m.URL);
        }
Пример #23
0
 public void InitFromUri_FullTypicalLangDepot_PasswordCorrect()
 {
     var m = new ServerSettingsModel();
     m.InitFromUri("http://*****:*****@hg-public.languagedepot.org/tpi");
     Assert.AreEqual("pass", m.Password);
 }
Пример #24
0
 public void InitFromUri_FullTypicalLangDepot_SelectedServerLabel()
 {
     var m = new ServerSettingsModel();
     m.InitFromUri("http://*****:*****@hg-public.languagedepot.org/tpi");
     Assert.AreEqual("languagedepot.org [safe mode]", m.SelectedServerLabel.ToLower());
 }
Пример #25
0
 public void InitFromUri_FullTypicalLangDepot_SelectedServerPathCorrect()
 {
     var m = new ServerSettingsModel();
     m.InitFromUri("http://*****:*****@hg-public.languagedepot.org/tpi");
     Assert.AreEqual("hg-public.languagedepot.org", m.SelectedServerPath);
 }
Пример #26
0
 public void InitFromUri_HasFolderDesignator_IdIsCorrect()
 {
     var m = new ServerSettingsModel();
     m.InitFromUri("http://*****:*****@hg-public.languagedepot.org/tpi?localFolder=foo");
     Assert.AreEqual("tpi", m.ProjectId);
 }
Пример #27
0
 public void InitFromUri_FullTypicalLangDepot_CustomUrlFalse()
 {
     var m = new ServerSettingsModel();
     m.InitFromUri("http://*****:*****@hg-public.languagedepot.org/tpi");
     Assert.IsFalse(m.CustomUrlSelected);
 }
Пример #28
0
 public void InitFromUri_LANPathGiven_CustomUrlIsTrue()
 {
     var m = new ServerSettingsModel();
     m.InitFromUri("\\mybox\tpi");
     Assert.IsTrue(m.CustomUrlSelected);
 }
Пример #29
0
 public void InitFromUri_LANPathGiven_SelectedServerLabelIsCorrect()
 {
     var m = new ServerSettingsModel();
     m.InitFromUri("\\mybox\tpi");
     Assert.IsTrue(m.SelectedServerLabel.ToLower().Contains("custom"));
 }
Пример #30
0
 public void InitFromUri_UnknownHttpGiven_CustomUrlIsTrue()
 {
     var m = new ServerSettingsModel();
     m.InitFromUri("http://somewhereelse.net/xyz");
     Assert.IsTrue(m.CustomUrlSelected);
 }
Пример #31
0
 public void InitFromUri_FullPrivateLangDepot_SelectedServerLabel()
 {
     var m = new ServerSettingsModel();
     m.InitFromUri("http://*****:*****@hg-private.languagedepot.org/tpi");
     Assert.AreEqual("LanguageDepot.org [private]".ToLower(), m.SelectedServerLabel.ToLower());
 }
Пример #32
0
 public void InitFromUri_FullTypicalLangDepot_AccountNameCorrect()
 {
     var m = new ServerSettingsModel();
     m.InitFromUri("http://*****:*****@hg-public.languagedepot.org/tpi");
     Assert.AreEqual("joe",m.AccountName);
 }