| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459 |
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using Renci.SshNet.Common;
- using Renci.SshNet.Tests.Common;
- using Renci.SshNet.Tests.Properties;
- using System;
- using System.Net;
- namespace Renci.SshNet.Tests.Classes
- {
- /// <summary>
- /// Provides connection information when password authentication method is used
- /// </summary>
- [TestClass]
- public class PasswordConnectionInfoTest : TestBase
- {
- [TestMethod]
- [TestCategory("PasswordConnectionInfo")]
- public void Test_PasswordConnectionInfo()
- {
- var host = Resources.HOST;
- var username = Resources.USERNAME;
- var password = Resources.PASSWORD;
- #region Example PasswordConnectionInfo
- var connectionInfo = new PasswordConnectionInfo(host, username, password);
- using (var client = new SftpClient(connectionInfo))
- {
- client.Connect();
- // Do something here
- client.Disconnect();
- }
- #endregion
- Assert.AreEqual(connectionInfo.Host, Resources.HOST);
- Assert.AreEqual(connectionInfo.Username, Resources.USERNAME);
- }
- [TestMethod]
- [TestCategory("PasswordConnectionInfo")]
- public void Test_PasswordConnectionInfo_PasswordExpired()
- {
- var host = Resources.HOST;
- var username = Resources.USERNAME;
- var password = Resources.PASSWORD;
- #region Example PasswordConnectionInfo PasswordExpired
- var connectionInfo = new PasswordConnectionInfo("host", "username", "password");
- var encoding = new Renci.SshNet.Common.ASCIIEncoding();
- connectionInfo.PasswordExpired += delegate(object sender, AuthenticationPasswordChangeEventArgs e)
- {
- e.NewPassword = encoding.GetBytes("123456");
- };
- using (var client = new SshClient(connectionInfo))
- {
- client.Connect();
- client.Disconnect();
- }
- #endregion
- Assert.Inconclusive();
- }
- [TestMethod]
- [TestCategory("PasswordConnectionInfo")]
- public void Test_PasswordConnectionInfo_AuthenticationBanner()
- {
- var host = Resources.HOST;
- var username = Resources.USERNAME;
- var password = Resources.PASSWORD;
- #region Example PasswordConnectionInfo AuthenticationBanner
- var connectionInfo = new PasswordConnectionInfo(host, username, password);
- connectionInfo.AuthenticationBanner += delegate(object sender, AuthenticationBannerEventArgs e)
- {
- Console.WriteLine(e.BannerMessage);
- };
- using (var client = new SftpClient(connectionInfo))
- {
- client.Connect();
- // Do something here
- client.Disconnect();
- }
- #endregion
- Assert.AreEqual(connectionInfo.Host, Resources.HOST);
- Assert.AreEqual(connectionInfo.Username, Resources.USERNAME);
- }
- [WorkItem(703), TestMethod]
- [TestCategory("PasswordConnectionInfo")]
- [ExpectedException(typeof(ArgumentException))]
- public void Test_ConnectionInfo_Host_Is_Null()
- {
- var connectionInfo = new PasswordConnectionInfo(null, Resources.USERNAME, Resources.PASSWORD);
- }
- [WorkItem(703), TestMethod]
- [TestCategory("PasswordConnectionInfo")]
- [ExpectedException(typeof(ArgumentException))]
- public void Test_ConnectionInfo_Username_Is_Null()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, null, Resources.PASSWORD);
- }
- [WorkItem(703), TestMethod]
- [TestCategory("PasswordConnectionInfo")]
- [ExpectedException(typeof(ArgumentNullException))]
- public void Test_ConnectionInfo_Password_Is_Null()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, (string)null);
- }
- [TestMethod]
- [TestCategory("PasswordConnectionInfo")]
- [Description("Test passing whitespace to host parameter.")]
- [ExpectedException(typeof(ArgumentException))]
- public void Test_ConnectionInfo_Host_Is_Whitespace()
- {
- var connectionInfo = new PasswordConnectionInfo(" ", Resources.USERNAME, Resources.PASSWORD);
- }
- [TestMethod]
- [TestCategory("PasswordConnectionInfo")]
- [Description("Test passing whitespace to username parameter.")]
- [ExpectedException(typeof(ArgumentException))]
- public void Test_ConnectionInfo_Username_Is_Whitespace()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, " ", Resources.PASSWORD);
- }
- [WorkItem(703), TestMethod]
- [TestCategory("PasswordConnectionInfo")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void Test_ConnectionInfo_SmallPortNumber()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MinPort - 1, Resources.USERNAME, Resources.PASSWORD);
- }
- [WorkItem(703), TestMethod]
- [TestCategory("PasswordConnectionInfo")]
- [ExpectedException(typeof(ArgumentOutOfRangeException))]
- public void Test_ConnectionInfo_BigPortNumber()
- {
- var connectionInfo = new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MaxPort + 1, Resources.USERNAME, Resources.PASSWORD);
- }
- [TestMethod]
- [Owner("Kenneth_aa")]
- [Description("Test connect to remote server via a SOCKS4 proxy server.")]
- [TestCategory("Proxy")]
- public void Test_Ssh_Connect_Via_Socks4()
- {
- var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Socks4, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT));
- using (var client = new SshClient(connInfo))
- {
- client.Connect();
- var ret = client.RunCommand("ls -la");
- client.Disconnect();
- }
- }
- [TestMethod]
- [Owner("Kenneth_aa")]
- [Description("Test connect to remote server via a TCP SOCKS5 proxy server.")]
- [TestCategory("Proxy")]
- public void Test_Ssh_Connect_Via_TcpSocks5()
- {
- var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Socks5, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT));
- using (var client = new SshClient(connInfo))
- {
- client.Connect();
- var ret = client.RunCommand("ls -la");
- client.Disconnect();
- }
- }
- [TestMethod]
- [Owner("Kenneth_aa")]
- [Description("Test connect to remote server via a HTTP proxy server.")]
- [TestCategory("Proxy")]
- public void Test_Ssh_Connect_Via_HttpProxy()
- {
- var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Http, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT));
- using (var client = new SshClient(connInfo))
- {
- client.Connect();
- var ret = client.RunCommand("ls -la");
- client.Disconnect();
- }
- }
- /// <summary>
- ///A test for Dispose
- ///</summary>
- [TestMethod()]
- public void DisposeTest()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- byte[] password = null; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password); // TODO: Initialize to an appropriate value
- target.Dispose();
- Assert.Inconclusive("A method that does not return a value cannot be verified.");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- int port = 0; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- byte[] password = null; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
- string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest1()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- byte[] password = null; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
- string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest2()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- byte[] password = null; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort, proxyUsername);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest3()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- byte[] password = null; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest4()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- int port = 0; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- byte[] password = null; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password, proxyType, proxyHost, proxyPort, proxyUsername);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest5()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- int port = 0; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- byte[] password = null; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password, proxyType, proxyHost, proxyPort);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest6()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- int port = 0; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- byte[] password = null; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest7()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- byte[] password = null; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest8()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- string password = string.Empty; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
- string proxyPassword = string.Empty; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort, proxyUsername, proxyPassword);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest9()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- string password = string.Empty; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort, proxyUsername);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest10()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- string password = string.Empty; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password, proxyType, proxyHost, proxyPort);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest11()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- int port = 0; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- string password = string.Empty; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- string proxyUsername = string.Empty; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password, proxyType, proxyHost, proxyPort, proxyUsername);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest12()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- int port = 0; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- string password = string.Empty; // TODO: Initialize to an appropriate value
- ProxyTypes proxyType = new ProxyTypes(); // TODO: Initialize to an appropriate value
- string proxyHost = string.Empty; // TODO: Initialize to an appropriate value
- int proxyPort = 0; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password, proxyType, proxyHost, proxyPort);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest13()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- int port = 0; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- string password = string.Empty; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, port, username, password);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- /// <summary>
- ///A test for PasswordConnectionInfo Constructor
- ///</summary>
- [TestMethod()]
- public void PasswordConnectionInfoConstructorTest14()
- {
- string host = string.Empty; // TODO: Initialize to an appropriate value
- string username = string.Empty; // TODO: Initialize to an appropriate value
- string password = string.Empty; // TODO: Initialize to an appropriate value
- PasswordConnectionInfo target = new PasswordConnectionInfo(host, username, password);
- Assert.Inconclusive("TODO: Implement code to verify target");
- }
- }
- }
|