Example #1
0
        public void TestConnectionPasswordMissing()
        {
            var mockCxSettings = new Mock <ISitecoreConnectionSettings>();

            mockCxSettings.SetupGet(cxSettings => cxSettings.Username).Returns(@"sitecore\admin");
            mockCxSettings.SetupGet(cxSettings => cxSettings.Password).Returns((string)null);
            mockCxSettings.SetupGet(cxSettings => cxSettings.ClientUrl).Returns("http://sc80/sitecore");
            var manager  = new SitecoreConnectionManager(mockCxSettings.Object);
            var response = manager.TestConnection();

            Assert.IsNotNull(response);
            Assert.IsFalse(response.Data);
            Assert.IsNotNull(response.GetExceptions());
            Assert.IsTrue(response.GetExceptions().Any(ex => ex.GetType() == typeof(AuthenticationException)));
        }
Example #2
0
        public void TestConnectionSitecore80()
        {
            var mockCxSettings = new Mock <ISitecoreConnectionSettings>();

            mockCxSettings.SetupGet(cxSettings => cxSettings.Username).Returns(@"sitecore\admin");
            mockCxSettings.SetupGet(cxSettings => cxSettings.Password).Returns("b");
            mockCxSettings.SetupGet(cxSettings => cxSettings.ClientUrl).Returns("http://sc80/sitecore");
            var manager  = new SitecoreConnectionManager(mockCxSettings.Object);
            var response = manager.TestConnection();

            Assert.IsNotNull(response);
            Assert.IsTrue(response.Data);
            Assert.IsNotNull(response.GetExceptions());
            Assert.IsFalse(response.GetExceptions().Any());
        }
Example #3
0
        public void TestConnectionClientUrlHostNotFound()
        {
            var mockCxSettings = new Mock <ISitecoreConnectionSettings>();

            mockCxSettings.SetupGet(cxSettings => cxSettings.Username).Returns(@"sitecore\admin");
            mockCxSettings.SetupGet(cxSettings => cxSettings.Password).Returns("b");
            mockCxSettings.SetupGet(cxSettings => cxSettings.ClientUrl).Returns("http://localhost/sitecore");
            var manager  = new SitecoreConnectionManager(mockCxSettings.Object);
            var response = manager.TestConnection();

            Assert.IsNotNull(response);
            Assert.IsFalse(response.Data);
            Assert.IsNotNull(response.GetExceptions());
            Assert.IsTrue(response.GetExceptions().Any(ex => ex.GetType() == typeof(WebException)));
        }
 protected virtual bool IsValidConnectionSettings(SitecoreConnectionManager manager)
 {
     if (string.IsNullOrEmpty(this.ClientUrl))
     {
         return(false);
     }
     Mouse.OverrideCursor = Cursors.Wait;
     try
     {
         var version = GetSitecoreVersion(manager);
         if (version == null)
         {
             return(false);
         }
         var response = manager.TestConnection();
         if (response == null)
         {
             MessageBox.Show("TestConnection() returned a null response.", TEST_CONNECTION_CAPTION, MessageBoxButton.OK, MessageBoxImage.Error);
             return(false);
         }
         if (!response.Data)
         {
             var b1 = new StringBuilder();
             b1.AppendLine("Unable to connect to the Sitecore server using the specified settings.");
             if (response.GetExceptions().Any())
             {
                 b1.AppendLine("\n\nThe following exceptions were thrown:\n");
                 b1.AppendLine(string.Join("\n", response.GetExceptions().Select(ex => string.Format("* {0}", ex.Message))));
             }
             MessageBox.Show(b1.ToString(), TEST_CONNECTION_CAPTION, MessageBoxButton.OK, MessageBoxImage.Error);
         }
         return(response.Data);
     }
     finally
     {
         Mouse.OverrideCursor = null;
     }
 }