mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 09:15:47 +00:00
c0a353a4de
* Preparation to enforce formatting and style in CI - enabled IDE0055 to enforce formatting on build - disabled SA1137 and SA1025 because they are already covered by IDE0055 - disabled SA1021 because it conflicts with csharp_space_after_cast * Cleanup formatting and style on codebase This commit has no manual changes, it is the result of running "dotnet format whitespace" and "dotnet format style" * new formatting fixes after merge * appveyor: set git autocrlf as suggested by sharwell to hopefully fix Windows CI. * use autocrlf input to hopefully fix Linux tests * fix formatting * use autocrlf input for Linux only * set csharp_space_after_cast to false * Revert SA1021 suppression --------- Co-authored-by: Robert Hague <rh@johnstreetcapital.com>
48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using System;
|
|
using System.Net.Sockets;
|
|
using System.Threading.Tasks;
|
|
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
|
|
namespace Renci.SshNet.Tests.Classes
|
|
{
|
|
public partial class SftpClientTest
|
|
{
|
|
[TestMethod]
|
|
public async Task ConnectAsync_HostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostNotFound()
|
|
{
|
|
var connectionInfo = new ConnectionInfo(Guid.NewGuid().ToString("N"), 40, "user",
|
|
new KeyboardInteractiveAuthenticationMethod("user"));
|
|
var sftpClient = new SftpClient(connectionInfo);
|
|
|
|
try
|
|
{
|
|
await sftpClient.ConnectAsync(default);
|
|
Assert.Fail();
|
|
}
|
|
catch (SocketException ex)
|
|
{
|
|
Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain, $"Socket error is {ex.SocketErrorCode}");
|
|
}
|
|
}
|
|
|
|
[TestMethod]
|
|
public async Task ConnectAsync_ProxyHostNameInvalid_ShouldThrowSocketExceptionWithErrorCodeHostNotFound()
|
|
{
|
|
var connectionInfo = new ConnectionInfo("localhost", 40, "user", ProxyTypes.Http, Guid.NewGuid().ToString("N"), 80,
|
|
"proxyUser", "proxyPwd", new KeyboardInteractiveAuthenticationMethod("user"));
|
|
var sftpClient = new SftpClient(connectionInfo);
|
|
|
|
try
|
|
{
|
|
await sftpClient.ConnectAsync(default);
|
|
Assert.Fail();
|
|
}
|
|
catch (SocketException ex)
|
|
{
|
|
Assert.IsTrue(ex.SocketErrorCode is SocketError.HostNotFound or SocketError.TryAgain, $"Socket error is {ex.SocketErrorCode}");
|
|
}
|
|
}
|
|
}
|
|
}
|