Files
ssh.net/test/Renci.SshNet.Tests/Classes/PasswordConnectionInfoTest.cs
dependabot[bot] 03ae6bfa0f Bump dependencies (#1682)
* Bump the dependencies group with 4 updates

Bumps BouncyCastle.Cryptography from 2.6.1 to 2.6.2
Bumps Meziantou.Analyzer from 2.0.205 to 2.0.210
Bumps MSTest from 3.9.3 to 3.10.0
Bumps SonarAnalyzer.CSharp from 10.13.0.120203 to 10.15.0.120848

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rob Hague <rob.hague00@gmail.com>
2025-08-02 17:57:09 +02:00

67 lines
2.1 KiB
C#

using System;
using System.Net;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Renci.SshNet.Tests.Common;
using Renci.SshNet.Tests.Properties;
namespace Renci.SshNet.Tests.Classes
{
/// <summary>
/// Provides connection information when password authentication method is used
/// </summary>
[TestClass]
public class PasswordConnectionInfoTest : TestBase
{
[TestMethod]
public void Test_ConnectionInfo_Host_Is_Null()
{
try
{
_ = new PasswordConnectionInfo(null, Resources.USERNAME, Resources.PASSWORD);
Assert.Fail();
}
catch (ArgumentNullException ex)
{
Assert.IsNull(ex.InnerException);
Assert.AreEqual("host", ex.ParamName);
}
}
[TestMethod]
public void Test_ConnectionInfo_Username_Is_Null()
{
Assert.ThrowsExactly<ArgumentNullException>(() => new PasswordConnectionInfo(Resources.HOST, null, Resources.PASSWORD));
}
[TestMethod]
public void Test_ConnectionInfo_Password_Is_Null()
{
Assert.ThrowsExactly<ArgumentNullException>(
() => new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, (string)null));
}
[TestMethod]
public void Test_ConnectionInfo_Username_Is_Whitespace()
{
Assert.ThrowsExactly<ArgumentException>(() => new PasswordConnectionInfo(Resources.HOST, " ", Resources.PASSWORD));
}
[TestMethod]
public void Test_ConnectionInfo_SmallPortNumber()
{
Assert.ThrowsExactly<ArgumentOutOfRangeException>(
() => new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MinPort - 1, Resources.USERNAME, Resources.PASSWORD));
}
[TestMethod]
public void Test_ConnectionInfo_BigPortNumber()
{
Assert.ThrowsExactly<ArgumentOutOfRangeException>(
() => new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MaxPort + 1, Resources.USERNAME, Resources.PASSWORD));
}
}
}