| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- 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}");
- }
- }
- }
- }
|