예제 #1
0
        private void TestPanoramaServerUrls()
        {
            var PWEB         = "panoramaweb.org";
            var PWEB_FULL    = "https://panoramaweb.org/";
            var PWEB_LK      = "panoramaweb.org/labkey";
            var PWEB_LK_FULL = "https://panoramaweb.org/labkey/";

            var serverUri = PanoramaUtil.ServerNameToUri(PWEB);
            var pServer   = new PanoramaServer(serverUri, string.Empty, string.Empty);

            Assert.AreEqual(pServer.ServerUri.AbsoluteUri, PWEB_FULL);
            Assert.IsFalse(pServer.RemoveContextPath());
            Assert.IsTrue(pServer.AddLabKeyContextPath());
            Assert.AreEqual(pServer.ServerUri.AbsoluteUri, PWEB_LK_FULL);

            serverUri = PanoramaUtil.ServerNameToUri(PWEB_LK);
            pServer   = new PanoramaServer(serverUri, string.Empty, string.Empty);
            Assert.AreEqual(pServer.ServerUri.AbsoluteUri, PWEB_LK_FULL);
            Assert.IsFalse(pServer.AddLabKeyContextPath());
            Assert.IsTrue(pServer.RemoveContextPath());
            Assert.AreEqual(pServer.ServerUri.AbsoluteUri, PWEB_FULL);

            serverUri = PanoramaUtil.ServerNameToUri(PWEB_LK);
            pServer   = new PanoramaServer(serverUri, string.Empty, string.Empty);
            Assert.AreEqual(pServer.ServerUri, PWEB_LK_FULL);
            Assert.IsTrue(pServer.Redirect(PWEB_FULL + PanoramaUtil.ENSURE_LOGIN_PATH,
                                           PanoramaUtil.ENSURE_LOGIN_PATH));
            Assert.AreEqual(pServer.ServerUri, PWEB_FULL);

            Assert.IsFalse(pServer.Redirect("/labkey/" + PanoramaUtil.ENSURE_LOGIN_PATH, PanoramaUtil.ENSURE_LOGIN_PATH));              // Need full URL
            Assert.IsFalse(pServer.Redirect("http:/another.server/" + PanoramaUtil.ENSURE_LOGIN_PATH, PanoramaUtil.ENSURE_LOGIN_PATH)); // Not the same host
        }
예제 #2
0
        public void OkDialog()
        {
            MessageBoxHelper helper = new MessageBoxHelper(this);
            string           serverName;

            if (!helper.ValidateNameTextBox(textServerURL, out serverName))
            {
                return;
            }

            Uri uriServer = PanoramaUtil.ServerNameToUri(serverName);

            if (uriServer == null)
            {
                helper.ShowTextBoxError(textServerURL, Resources.EditServerDlg_OkDialog_The_text__0__is_not_a_valid_server_name_, serverName);
                return;
            }

            var panoramaClient = PanoramaClient ?? new WebPanoramaClient(uriServer);

            using (var waitDlg = new LongWaitDlg {
                Text = Resources.EditServerDlg_OkDialog_Verifying_server_information
            })
            {
                try
                {
                    waitDlg.PerformWork(this, 1000, () => PanoramaUtil.VerifyServerInformation(panoramaClient, Username, Password));
                }
                catch (Exception x)
                {
                    helper.ShowTextBoxError(textServerURL, x.Message);
                    return;
                }
            }

            Uri updatedUri = panoramaClient.ServerUri ?? uriServer;

            if (_existing.Contains(server => !ReferenceEquals(_server, server) && Equals(updatedUri, server.URI)))
            {
                helper.ShowTextBoxError(textServerURL, Resources.EditServerDlg_OkDialog_The_server__0__already_exists_, uriServer.Host);
                return;
            }

            _server      = new Server(updatedUri, Username, Password);
            DialogResult = DialogResult.OK;
        }