mirror of
https://github.com/sshnet/SSH.NET.git
synced 2026-09-10 01:05:42 +00:00
Bump test dependencies (#1583)
* Bump coverlet.collector from 6.0.2 to 6.0.4 Bumps [coverlet.collector](https://github.com/coverlet-coverage/coverlet) from 6.0.2 to 6.0.4. - [Release notes](https://github.com/coverlet-coverage/coverlet/releases) - [Commits](https://github.com/coverlet-coverage/coverlet/compare/v6.0.2...v6.0.4) --- updated-dependencies: - dependency-name: coverlet.collector dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> * update test deps * update test deps * some fixes * group dependencies * analyzer fixes * just group them all together * more cleanup * silent analyzers -> suggestion * restore constant --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Robert Hague <rh@johnstreetcapital.com> Co-authored-by: Rob Hague <rob.hague00@gmail.com>
This commit is contained in:
@@ -610,6 +610,17 @@ MA0053.class_with_virtual_member_shoud_be_sealed = true
|
||||
# This rule is disabled by default, hence we need to explicitly enable it.
|
||||
dotnet_diagnostic.MA0112.severity = error
|
||||
|
||||
# MA0165: Make interpolated string
|
||||
dotnet_diagnostic.MA0165.severity = none
|
||||
|
||||
#### MSTest rules ####
|
||||
|
||||
# MSTEST0015: Test method should not be ignored
|
||||
dotnet_diagnostic.MSTEST0015.severity = suggestion
|
||||
|
||||
# MSTEST0032: Assertion condition is always true
|
||||
dotnet_diagnostic.MSTEST0032.severity = suggestion
|
||||
|
||||
#### .NET Compiler Platform code quality rules ####
|
||||
|
||||
# CA1002: Do not expose generic lists
|
||||
|
||||
+11
-7
@@ -8,22 +8,26 @@ updates:
|
||||
- package-ecosystem: "docker"
|
||||
directory: "/test/Renci.SshNet.IntegrationTests/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
interval: "monthly"
|
||||
|
||||
- package-ecosystem: "nuget"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
ignore:
|
||||
# AsyncInterface must stay at 1.0.0 because of https://github.com/sshnet/SSH.NET/pull/1288
|
||||
interval: "monthly"
|
||||
ignore: # See justifications in Directory.Packages.props
|
||||
- dependency-name: "Microsoft.Bcl.AsyncInterfaces"
|
||||
# These should stay on LTS .NET Releases
|
||||
|
||||
- dependency-name: "System.Formats.Asn1"
|
||||
update-types: ["version-update:semver-major"]
|
||||
- dependency-name: "Microsoft.Extensions.Logging.*"
|
||||
|
||||
- dependency-name: "Microsoft.Extensions.Logging.Abstractions"
|
||||
update-types: ["version-update:semver-major"]
|
||||
groups:
|
||||
dependencies:
|
||||
patterns:
|
||||
- "*"
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
interval: "monthly"
|
||||
|
||||
+16
-12
@@ -6,27 +6,31 @@
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
|
||||
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.5.0" />
|
||||
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
|
||||
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
|
||||
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
|
||||
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
|
||||
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageVersion>
|
||||
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.163" />
|
||||
<!-- Must be kept at version 1.0.0 or higher, see https://github.com/sshnet/SSH.NET/pull/1288 for details. -->
|
||||
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.186" />
|
||||
|
||||
<!-- Must be kept at version 1.0.0, see https://github.com/sshnet/SSH.NET/pull/1288 for details. -->
|
||||
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
|
||||
|
||||
<!-- No reason to require later than 6.0.0 at this time. -->
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" />
|
||||
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
|
||||
<PackageVersion Include="MSTest.TestAdapter" Version="3.6.2" />
|
||||
<PackageVersion Include="MSTest.TestFramework" Version="3.6.2" />
|
||||
<PackageVersion Include="MSTest.TestAdapter" Version="3.7.3" />
|
||||
<PackageVersion Include="MSTest.TestFramework" Version="3.7.3" />
|
||||
<PackageVersion Include="Moq" Version="4.20.72" />
|
||||
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.77-alpha" /> <!-- can use stable once 3.7 is released -->
|
||||
<PackageVersion Include="PolySharp" Version="1.14.1" />
|
||||
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" />
|
||||
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
|
||||
<PackageVersion Include="PolySharp" Version="1.15.0" />
|
||||
<PackageVersion Include="SonarAnalyzer.CSharp" Version="10.6.0.109712" />
|
||||
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
|
||||
|
||||
<!-- Should stay on LTS .NET releases. -->
|
||||
<PackageVersion Include="System.Formats.Asn1" Version="8.0.1" />
|
||||
<PackageVersion Include="Testcontainers" Version="4.0.0" />
|
||||
<PackageVersion Include="Testcontainers" Version="4.1.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -83,6 +83,9 @@ EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Renci.SshNet.AotCompatibilityTestApp", "test\Renci.SshNet.AotCompatibilityTestApp\Renci.SshNet.AotCompatibilityTestApp.csproj", "{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{05229079-6738-42CE-8F73-F4E182929B03}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.github\dependabot.yml = .github\dependabot.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{95F25B1A-2B14-4745-9087-43C00CD90EE0}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
#if NET9_0_OR_GREATER
|
||||
using System.Threading;
|
||||
#endif
|
||||
@@ -19,7 +22,7 @@ namespace Renci.SshNet
|
||||
private readonly bool[] _activatedMessagesById;
|
||||
private readonly Lock _lock = new Lock();
|
||||
|
||||
internal static readonly MessageMetadata[] AllMessages = new MessageMetadata[]
|
||||
private static readonly MessageMetadata[] AllMessages = new MessageMetadata[]
|
||||
{
|
||||
new MessageMetadata<KeyExchangeInitMessage>(0, "SSH_MSG_KEXINIT", 20),
|
||||
new MessageMetadata<NewKeysMessage>(1, "SSH_MSG_NEWKEYS", 21),
|
||||
@@ -55,6 +58,7 @@ namespace Renci.SshNet
|
||||
new MessageMetadata<KeyExchangeEcdhReplyMessage>(31, "SSH_MSG_KEX_ECDH_REPLY", 31),
|
||||
new MessageMetadata<KeyExchangeHybridReplyMessage>(32, "SSH_MSG_KEX_HYBRID_REPLY", 31)
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, MessageMetadata> MessagesByName = CreateMessagesByNameMapping();
|
||||
|
||||
/// <summary>
|
||||
@@ -62,17 +66,14 @@ namespace Renci.SshNet
|
||||
/// </summary>
|
||||
internal const byte HighestMessageNumber = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Defines the total number of supported messages.
|
||||
/// </summary>
|
||||
internal const int TotalMessageCount = 33;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SshMessageFactory"/> class.
|
||||
/// </summary>
|
||||
public SshMessageFactory()
|
||||
{
|
||||
_activatedMessagesById = new bool[TotalMessageCount];
|
||||
Debug.Assert(AllMessages.Max(m => m.Number) == HighestMessageNumber);
|
||||
|
||||
_activatedMessagesById = new bool[AllMessages.Length];
|
||||
_enabledMessagesByNumber = new MessageMetadata[HighestMessageNumber + 1];
|
||||
}
|
||||
|
||||
@@ -289,7 +290,9 @@ namespace Renci.SshNet
|
||||
|
||||
public override Message Create()
|
||||
{
|
||||
return new T();
|
||||
var message = new T();
|
||||
Debug.Assert(message.MessageNumber == Number);
|
||||
return message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,6 +352,8 @@ namespace Renci.SshNet.IntegrationTests
|
||||
// Password expired, retype new password
|
||||
authenticationPrompt.Response = Users.Regular.Password;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
authenticationPromptCount++;
|
||||
|
||||
@@ -100,61 +100,12 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(SshConnectionException))]
|
||||
public void Test_PortForwarding_Local_Without_Connecting()
|
||||
{
|
||||
using (var client = new SshClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
using var port1 = new ForwardedPortLocal("localhost", 8084, "www.renci.org", 80);
|
||||
client.AddForwardedPort(port1);
|
||||
port1.Exception += delegate (object sender, ExceptionEventArgs e)
|
||||
{
|
||||
Assert.Fail(e.Exception.ToString());
|
||||
};
|
||||
port1.Start();
|
||||
|
||||
var test = Parallel.For(0,
|
||||
100,
|
||||
counter =>
|
||||
{
|
||||
var start = DateTime.Now;
|
||||
|
||||
#if NET6_0_OR_GREATER
|
||||
var httpClient = new HttpClient();
|
||||
using (var response = httpClient.GetAsync("http://localhost:8084").GetAwaiter().GetResult())
|
||||
{
|
||||
var data = ReadStream(response.Content.ReadAsStream());
|
||||
#else
|
||||
var request = (HttpWebRequest)WebRequest.Create("http://localhost:8084");
|
||||
using (var response = (HttpWebResponse)request.GetResponse())
|
||||
{
|
||||
var data = ReadStream(response.GetResponseStream());
|
||||
#endif // NET6_0_OR_GREATER
|
||||
var end = DateTime.Now;
|
||||
|
||||
Debug.WriteLine(string.Format("Request# {2}: Lenght: {0} Time: {1}", data.Length, end - start, counter));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static byte[] ReadStream(Stream stream)
|
||||
{
|
||||
var buffer = new byte[1024];
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
var read = stream.Read(buffer, 0, buffer.Length);
|
||||
if (read > 0)
|
||||
{
|
||||
ms.Write(buffer, 0, read);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
Assert.ThrowsException<SshConnectionException>(() => client.AddForwardedPort(port1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
scp.Disconnect();
|
||||
|
||||
Assert.IsTrue(result.Count() == uploadFilenames.Length);
|
||||
Assert.AreEqual(uploadFilenames.Length, result.Count());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+16
-16
@@ -9,97 +9,97 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
{
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public void Test_Sftp_ChangeDirectory_Root_Dont_Exists()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
sftp.ChangeDirectory("/asdasd");
|
||||
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd"));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public async Task Test_Sftp_ChangeDirectory_Root_Dont_ExistsAsync()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
|
||||
await sftp.ChangeDirectoryAsync("/asdasd", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
|
||||
() => sftp.ChangeDirectoryAsync("/asdasd", CancellationToken.None));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public void Test_Sftp_ChangeDirectory_Root_With_Slash_Dont_Exists()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
sftp.ChangeDirectory("/asdasd/");
|
||||
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/"));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public async Task Test_Sftp_ChangeDirectory_Root_With_Slash_Dont_ExistsAsync()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
|
||||
await sftp.ChangeDirectoryAsync("/asdasd/", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
|
||||
() => sftp.ChangeDirectoryAsync("/asdasd/", CancellationToken.None));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public void Test_Sftp_ChangeDirectory_Subfolder_Dont_Exists()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
sftp.ChangeDirectory("/asdasd/sssddds");
|
||||
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/sssddds"));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public async Task Test_Sftp_ChangeDirectory_Subfolder_Dont_ExistsAsync()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
|
||||
await sftp.ChangeDirectoryAsync("/asdasd/sssddds", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
|
||||
() => sftp.ChangeDirectoryAsync("/asdasd/sssddds", CancellationToken.None));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public void Test_Sftp_ChangeDirectory_Subfolder_With_Slash_Dont_Exists()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
sftp.ChangeDirectory("/asdasd/sssddds/");
|
||||
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/sssddds/"));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public async Task Test_Sftp_ChangeDirectory_Subfolder_With_Slash_Dont_ExistsAsync()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
|
||||
await sftp.ChangeDirectoryAsync("/asdasd/sssddds/", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
|
||||
() => sftp.ChangeDirectoryAsync("/asdasd/sssddds/", CancellationToken.None));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-12
@@ -24,37 +24,30 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPermissionDeniedException))]
|
||||
public void Test_Sftp_CreateDirectory_In_Forbidden_Directory()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, AdminUser.UserName, AdminUser.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
sftp.CreateDirectory("/sbin/test");
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<SftpPermissionDeniedException>(() => sftp.CreateDirectory("/sbin/test"));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public void Test_Sftp_CreateDirectory_Invalid_Path()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
sftp.CreateDirectory("/abcdefg/abcefg");
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.CreateDirectory("/abcdefg/abcefg"));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SshException))]
|
||||
public void Test_Sftp_CreateDirectory_Already_Exists()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
@@ -63,9 +56,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
sftp.CreateDirectory("test");
|
||||
|
||||
sftp.CreateDirectory("test");
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<SshException>(() => sftp.CreateDirectory("test"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-12
@@ -9,31 +9,25 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
{
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public void Test_Sftp_DeleteDirectory_Which_Doesnt_Exists()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
sftp.DeleteDirectory("abcdef");
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.DeleteDirectory("abcdef"));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPermissionDeniedException))]
|
||||
public void Test_Sftp_DeleteDirectory_Which_No_Permissions()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, AdminUser.UserName, AdminUser.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
sftp.DeleteDirectory("/usr");
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<SftpPermissionDeniedException>(() => sftp.DeleteDirectory("/usr"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,16 +49,13 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to DeleteDirectory.")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_Sftp_DeleteDirectory_Null()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
sftp.DeleteDirectory(null);
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<ArgumentNullException>(() => sftp.DeleteDirectory(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,88 +9,69 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
{
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPermissionDeniedException))]
|
||||
public void Test_Sftp_Download_Forbidden()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, AdminUser.UserName, AdminUser.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
string remoteFileName = "/root/.profile";
|
||||
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
sftp.DownloadFile(remoteFileName, ms);
|
||||
}
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<SftpPermissionDeniedException>(() => sftp.DownloadFile("/root/.profile", Stream.Null));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public void Test_Sftp_Download_File_Not_Exists()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
string remoteFileName = "/xxx/eee/yyy";
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
sftp.DownloadFile(remoteFileName, ms);
|
||||
}
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.DownloadFile("/xxx/eee/yyy", Stream.Null));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to BeginDownloadFile")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_Sftp_BeginDownloadFile_StreamIsNull()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
sftp.BeginDownloadFile("aaaa", null, null, null);
|
||||
sftp.Disconnect();
|
||||
|
||||
Assert.ThrowsException<ArgumentNullException>(() => sftp.BeginDownloadFile("aaaa", null, null, null));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to BeginDownloadFile")]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void Test_Sftp_BeginDownloadFile_FileNameIsWhiteSpace()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
sftp.BeginDownloadFile(" ", new MemoryStream(), null, null);
|
||||
sftp.Disconnect();
|
||||
|
||||
Assert.ThrowsException<ArgumentException>(() => sftp.BeginDownloadFile(" ", Stream.Null, null, null));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to BeginDownloadFile")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_Sftp_BeginDownloadFile_FileNameIsNull()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
sftp.BeginDownloadFile(null, new MemoryStream(), null, null);
|
||||
sftp.Disconnect();
|
||||
|
||||
Assert.ThrowsException<ArgumentNullException>(() => sftp.BeginDownloadFile(null, Stream.Null, null, null));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void Test_Sftp_EndDownloadFile_Invalid_Async_Handle()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
@@ -101,7 +82,8 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
sftp.UploadFile(File.OpenRead(filename), "test123");
|
||||
var async1 = sftp.BeginListDirectory("/", null, null);
|
||||
var async2 = sftp.BeginDownloadFile("test123", new MemoryStream(), null, null);
|
||||
sftp.EndDownloadFile(async1);
|
||||
|
||||
Assert.ThrowsException<ArgumentException>(() => sftp.EndDownloadFile(async1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+27
-56
@@ -11,39 +11,25 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
{
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPermissionDeniedException))]
|
||||
public void Test_Sftp_ListDirectory_Permission_Denied()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
var files = sftp.ListDirectory("/root");
|
||||
foreach (var file in files)
|
||||
{
|
||||
Debug.WriteLine(file.FullName);
|
||||
}
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<SftpPermissionDeniedException>(() => sftp.ListDirectory("/root"));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public void Test_Sftp_ListDirectory_Not_Exists()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
var files = sftp.ListDirectory("/asdfgh");
|
||||
foreach (var file in files)
|
||||
{
|
||||
Debug.WriteLine(file.FullName);
|
||||
}
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ListDirectory("/asdfgh"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,23 +101,13 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to ListDirectory.")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_Sftp_ListDirectory_Null()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
var files = sftp.ListDirectory(null);
|
||||
|
||||
Assert.IsTrue(files.Count() > 0);
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
Debug.WriteLine(file.FullName);
|
||||
}
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<ArgumentNullException>(() => sftp.ListDirectory(null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,13 +144,13 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet");
|
||||
Assert.AreEqual("/home/sshnet", sftp.WorkingDirectory);
|
||||
|
||||
sftp.CreateDirectory("test1");
|
||||
|
||||
sftp.ChangeDirectory("test1");
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1");
|
||||
Assert.AreEqual("/home/sshnet/test1", sftp.WorkingDirectory);
|
||||
|
||||
sftp.CreateDirectory("test1_1");
|
||||
sftp.CreateDirectory("test1_2");
|
||||
@@ -186,19 +162,19 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
sftp.ChangeDirectory("test1_1");
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1/test1_1");
|
||||
Assert.AreEqual("/home/sshnet/test1/test1_1", sftp.WorkingDirectory);
|
||||
|
||||
sftp.ChangeDirectory("../test1_2");
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1/test1_2");
|
||||
Assert.AreEqual("/home/sshnet/test1/test1_2", sftp.WorkingDirectory);
|
||||
|
||||
sftp.ChangeDirectory("..");
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1");
|
||||
Assert.AreEqual("/home/sshnet/test1", sftp.WorkingDirectory);
|
||||
|
||||
sftp.ChangeDirectory("..");
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet");
|
||||
Assert.AreEqual("/home/sshnet", sftp.WorkingDirectory);
|
||||
|
||||
files = sftp.ListDirectory("test1/test1_1");
|
||||
|
||||
@@ -206,15 +182,15 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
sftp.ChangeDirectory("test1/test1_1");
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1/test1_1");
|
||||
Assert.AreEqual("/home/sshnet/test1/test1_1", sftp.WorkingDirectory);
|
||||
|
||||
sftp.ChangeDirectory("/home/sshnet/test1/test1_1");
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1/test1_1");
|
||||
Assert.AreEqual("/home/sshnet/test1/test1_1", sftp.WorkingDirectory);
|
||||
|
||||
sftp.ChangeDirectory("/home/sshnet/test1/test1_1/../test1_2");
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1/test1_2");
|
||||
Assert.AreEqual("/home/sshnet/test1/test1_2", sftp.WorkingDirectory);
|
||||
|
||||
sftp.ChangeDirectory("../../");
|
||||
|
||||
@@ -237,13 +213,13 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
{
|
||||
await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet");
|
||||
Assert.AreEqual("/home/sshnet", sftp.WorkingDirectory);
|
||||
|
||||
await sftp.CreateDirectoryAsync("test1", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
await sftp.ChangeDirectoryAsync("test1", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1");
|
||||
Assert.AreEqual("/home/sshnet/test1", sftp.WorkingDirectory);
|
||||
|
||||
await sftp.CreateDirectoryAsync("test1_1", CancellationToken.None).ConfigureAwait(false);
|
||||
await sftp.CreateDirectoryAsync("test1_2", CancellationToken.None).ConfigureAwait(false);
|
||||
@@ -255,19 +231,19 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
await sftp.ChangeDirectoryAsync("test1_1", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1/test1_1");
|
||||
Assert.AreEqual("/home/sshnet/test1/test1_1", sftp.WorkingDirectory);
|
||||
|
||||
await sftp.ChangeDirectoryAsync("../test1_2", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1/test1_2");
|
||||
Assert.AreEqual("/home/sshnet/test1/test1_2", sftp.WorkingDirectory);
|
||||
|
||||
await sftp.ChangeDirectoryAsync("..", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1");
|
||||
Assert.AreEqual("/home/sshnet/test1", sftp.WorkingDirectory);
|
||||
|
||||
await sftp.ChangeDirectoryAsync("..", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet");
|
||||
Assert.AreEqual("/home/sshnet", sftp.WorkingDirectory);
|
||||
|
||||
files = sftp.ListDirectory("test1/test1_1");
|
||||
|
||||
@@ -275,15 +251,15 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
await sftp.ChangeDirectoryAsync("test1/test1_1", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1/test1_1");
|
||||
Assert.AreEqual("/home/sshnet/test1/test1_1", sftp.WorkingDirectory);
|
||||
|
||||
await sftp.ChangeDirectoryAsync("/home/sshnet/test1/test1_1", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1/test1_1");
|
||||
Assert.AreEqual("/home/sshnet/test1/test1_1", sftp.WorkingDirectory);
|
||||
|
||||
await sftp.ChangeDirectoryAsync("/home/sshnet/test1/test1_1/../test1_2", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
Assert.AreEqual(sftp.WorkingDirectory, "/home/sshnet/test1/test1_2");
|
||||
Assert.AreEqual("/home/sshnet/test1/test1_2", sftp.WorkingDirectory);
|
||||
|
||||
await sftp.ChangeDirectoryAsync("../../", CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
@@ -301,39 +277,32 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to ChangeDirectory.")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_Sftp_ChangeDirectory_Null()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
sftp.ChangeDirectory(null);
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<ArgumentNullException>(() => sftp.ChangeDirectory(null));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to ChangeDirectory.")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public async Task Test_Sftp_ChangeDirectory_NullAsync()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
await sftp.ChangeDirectoryAsync(null, CancellationToken.None).ConfigureAwait(false);
|
||||
|
||||
sftp.Disconnect();
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => sftp.ChangeDirectoryAsync(null));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test calling EndListDirectory method more then once.")]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
[Description("Test calling EndListDirectory method more than once.")]
|
||||
public void Test_Sftp_Call_EndListDirectory_Twice()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
@@ -341,7 +310,9 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
sftp.Connect();
|
||||
var ar = sftp.BeginListDirectory("/", null, null);
|
||||
var result = sftp.EndListDirectory(ar);
|
||||
var result1 = sftp.EndListDirectory(ar);
|
||||
|
||||
// TODO there is no reason that this should throw
|
||||
Assert.ThrowsException<ArgumentException>(() => sftp.EndListDirectory(ar));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,16 +37,13 @@
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to RenameFile.")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_Sftp_RenameFile_Null()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
sftp.RenameFile(null, null);
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<ArgumentNullException>(() => sftp.RenameFile(null, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-4
@@ -40,16 +40,13 @@
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to RenameFile.")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public async Task Test_Sftp_RenameFileAsync_Null()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
await sftp.ConnectAsync(default);
|
||||
|
||||
await sftp.RenameFileAsync(null, null, default);
|
||||
|
||||
sftp.Disconnect();
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => sftp.RenameFileAsync(null, null, default));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,6 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPermissionDeniedException))]
|
||||
public void Test_Sftp_Upload_Forbidden()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
@@ -67,7 +66,7 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
using (var file = File.OpenRead(uploadedFileName))
|
||||
{
|
||||
sftp.UploadFile(file, remoteFileName);
|
||||
Assert.ThrowsException<SftpPermissionDeniedException>(() => sftp.UploadFile(file, remoteFileName));
|
||||
}
|
||||
|
||||
sftp.Disconnect();
|
||||
@@ -325,48 +324,44 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to BeginUploadFile")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_Sftp_BeginUploadFile_StreamIsNull()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
_ = sftp.BeginUploadFile(null, "aaaaa", null, null);
|
||||
sftp.Disconnect();
|
||||
|
||||
Assert.ThrowsException<ArgumentNullException>(() => sftp.BeginUploadFile(null, "aaaaa", null, null));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to BeginUploadFile")]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void Test_Sftp_BeginUploadFile_FileNameIsWhiteSpace()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
_ = sftp.BeginUploadFile(new MemoryStream(), " ", null, null);
|
||||
sftp.Disconnect();
|
||||
|
||||
Assert.ThrowsException<ArgumentException>(() => sftp.BeginUploadFile(new MemoryStream(), " ", null, null));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to BeginUploadFile")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_Sftp_BeginUploadFile_FileNameIsNull()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
_ = sftp.BeginUploadFile(new MemoryStream(), null, null, null);
|
||||
sftp.Disconnect();
|
||||
|
||||
Assert.ThrowsException<ArgumentNullException>(() => sftp.BeginUploadFile(new MemoryStream(), null, null, null));
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void Test_Sftp_EndUploadFile_Invalid_Async_Handle()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
@@ -377,7 +372,8 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
CreateTestFile(filename, 100);
|
||||
using var fileStream = File.OpenRead(filename);
|
||||
var async2 = sftp.BeginUploadFile(fileStream, "test", null, null);
|
||||
sftp.EndUploadFile(async1);
|
||||
|
||||
Assert.ThrowsException<ArgumentException>(() => sftp.EndUploadFile(async1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,14 +25,13 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public void Test_Get_Invalid_Directory()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
sftp.Get("/xyz");
|
||||
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.Get("/xyz"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,17 +55,13 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to Get.")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_Get_File_Null()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
var file = sftp.Get(null);
|
||||
|
||||
sftp.Disconnect();
|
||||
Assert.ThrowsException<ArgumentNullException>(() => sftp.Get(null));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,14 +99,13 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SftpPathNotFoundException))]
|
||||
public async Task Test_Get_Invalid_DirectoryAsync()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
await sftp.GetAsync("/xyz", default).ConfigureAwait(false);
|
||||
await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(() => sftp.GetAsync("/xyz", default));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,17 +129,13 @@ namespace Renci.SshNet.IntegrationTests.OldIntegrationTests
|
||||
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[Description("Test passing null to Get.")]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public async Task Test_Get_File_NullAsync()
|
||||
{
|
||||
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
|
||||
{
|
||||
sftp.Connect();
|
||||
|
||||
var file = await sftp.GetAsync(null, default).ConfigureAwait(false);
|
||||
|
||||
sftp.Disconnect();
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => sftp.GetAsync(null, default));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
<TargetFrameworks>net48;net8.0;net9.0</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<NoWarn>$(NoWarn);SYSLIB0021;SYSLIB1045;SYSLIB0014;IDE0220;IDE0010</NoWarn>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -18,7 +17,6 @@
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="MSTest.TestAdapter" />
|
||||
|
||||
@@ -90,10 +90,9 @@ namespace Renci.SshNet.IntegrationTests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(SftpPermissionDeniedException), "Permission denied")]
|
||||
public void Test_Sftp_ListDirectory_Permission_Denied()
|
||||
{
|
||||
_sftpClient.ListDirectory("/root");
|
||||
Assert.ThrowsException<SftpPermissionDeniedException>(() => _sftpClient.ListDirectory("/root"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -1731,7 +1731,7 @@ namespace Renci.SshNet.IntegrationTests
|
||||
}
|
||||
|
||||
var actualText = client.ReadAllText(remoteFile);
|
||||
Assert.AreEqual(actualText, expectedText);
|
||||
Assert.AreEqual(expectedText, actualText);
|
||||
|
||||
using (var fs = client.OpenRead(remoteFile))
|
||||
{
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using System.ComponentModel;
|
||||
using System.Net;
|
||||
#if NETFRAMEWORK
|
||||
using System.Net.Http;
|
||||
#endif
|
||||
using System.Net.Sockets;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
@@ -537,29 +540,16 @@ namespace Renci.SshNet.IntegrationTests
|
||||
|
||||
try
|
||||
{
|
||||
var httpRequest = (HttpWebRequest)WebRequest.Create("http://" + localEndPoint);
|
||||
httpRequest.Host = hostName;
|
||||
httpRequest.Method = "GET";
|
||||
httpRequest.AllowAutoRedirect = false;
|
||||
|
||||
try
|
||||
using HttpClientHandler handler = new()
|
||||
{
|
||||
using (var httpResponse = (HttpWebResponse)httpRequest.GetResponse())
|
||||
{
|
||||
Assert.AreEqual(HttpStatusCode.MovedPermanently, httpResponse.StatusCode);
|
||||
}
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Assert.AreEqual(WebExceptionStatus.ProtocolError, ex.Status);
|
||||
Assert.IsNotNull(ex.Response);
|
||||
AllowAutoRedirect = false
|
||||
};
|
||||
|
||||
using (var httpResponse = ex.Response as HttpWebResponse)
|
||||
{
|
||||
Assert.IsNotNull(httpResponse);
|
||||
Assert.AreEqual(HttpStatusCode.MovedPermanently, httpResponse.StatusCode);
|
||||
}
|
||||
}
|
||||
using HttpClient httpClient = new(handler);
|
||||
|
||||
using HttpResponseMessage httpResponse = httpClient.GetAsync("http://" + localEndPoint).Result;
|
||||
|
||||
Assert.AreEqual(HttpStatusCode.MovedPermanently, httpResponse.StatusCode);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -606,30 +596,16 @@ namespace Renci.SshNet.IntegrationTests
|
||||
|
||||
try
|
||||
{
|
||||
var httpRequest = (HttpWebRequest)WebRequest.Create("http://" + localEndPoint);
|
||||
httpRequest.Host = hostName;
|
||||
httpRequest.Method = "GET";
|
||||
httpRequest.Accept = "text/html";
|
||||
httpRequest.AllowAutoRedirect = false;
|
||||
|
||||
try
|
||||
using HttpClientHandler handler = new()
|
||||
{
|
||||
using (var httpResponse = (HttpWebResponse)httpRequest.GetResponse())
|
||||
{
|
||||
Assert.AreEqual(HttpStatusCode.MovedPermanently, httpResponse.StatusCode);
|
||||
}
|
||||
}
|
||||
catch (WebException ex)
|
||||
{
|
||||
Assert.AreEqual(WebExceptionStatus.ProtocolError, ex.Status);
|
||||
Assert.IsNotNull(ex.Response);
|
||||
AllowAutoRedirect = false
|
||||
};
|
||||
|
||||
using (var httpResponse = ex.Response as HttpWebResponse)
|
||||
{
|
||||
Assert.IsNotNull(httpResponse);
|
||||
Assert.AreEqual(HttpStatusCode.MovedPermanently, httpResponse.StatusCode);
|
||||
}
|
||||
}
|
||||
using HttpClient httpClient = new(handler);
|
||||
|
||||
using HttpResponseMessage httpResponse = httpClient.GetAsync("http://" + localEndPoint).Result;
|
||||
|
||||
Assert.AreEqual(HttpStatusCode.MovedPermanently, httpResponse.StatusCode);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Renci.SshNet.IntegrationTests
|
||||
|
||||
protected static string CreateHash(Stream stream)
|
||||
{
|
||||
MD5 md5 = new MD5CryptoServiceProvider();
|
||||
using MD5 md5 = MD5.Create();
|
||||
var hash = md5.ComputeHash(stream);
|
||||
return Encoding.ASCII.GetString(hash);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Renci.SshNet.IntegrationTests
|
||||
{
|
||||
[TestClass]
|
||||
public class TestInitializer
|
||||
public static class TestInitializer
|
||||
{
|
||||
[AssemblyInitialize]
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "MSTests requires context parameter")]
|
||||
|
||||
@@ -4,13 +4,6 @@
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<NoWarn>$(NoWarn);SYSLIB0021;SYSLIB1045</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Properties\**" />
|
||||
<EmbeddedResource Remove="Properties\**" />
|
||||
<None Remove="Properties\**" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="SshNet.Channels.Channel.DataReceived"/> event and <see cref="SshNet.Channels.Channel.ExtendedDataReceived"/> events.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelDataEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Base class forTest : TestBaseall channel related events.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="SshNet.Channels.ClientChannel.OpenFailed"/> event.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelOpenFailedEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides data for <see cref="SshNet.Channels.Channel.RequestReceived"/> event.
|
||||
/// </summary>
|
||||
[TestClass]
|
||||
public class ChannelRequestEventArgsTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -65,9 +65,9 @@ namespace Renci.SshNet.Tests.Classes.Connection
|
||||
const string comments = "Beware, dangerous!";
|
||||
|
||||
var sshIdentification = new SshIdentification(protocolVersion, softwareVersion, comments);
|
||||
Assert.AreSame(protocolVersion, sshIdentification.ProtocolVersion);
|
||||
Assert.AreSame(softwareVersion, sshIdentification.SoftwareVersion);
|
||||
Assert.AreSame(comments, sshIdentification.Comments);
|
||||
Assert.AreEqual(protocolVersion, sshIdentification.ProtocolVersion);
|
||||
Assert.AreEqual(softwareVersion, sshIdentification.SoftwareVersion);
|
||||
Assert.AreEqual(comments, sshIdentification.Comments);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -78,9 +78,9 @@ namespace Renci.SshNet.Tests.Classes.Connection
|
||||
const string comments = null;
|
||||
|
||||
var sshIdentification = new SshIdentification(protocolVersion, softwareVersion, comments);
|
||||
Assert.AreSame(protocolVersion, sshIdentification.ProtocolVersion);
|
||||
Assert.AreSame(softwareVersion, sshIdentification.SoftwareVersion);
|
||||
Assert.IsNull(comments, sshIdentification.Comments);
|
||||
Assert.AreEqual(protocolVersion, sshIdentification.ProtocolVersion);
|
||||
Assert.AreEqual(softwareVersion, sshIdentification.SoftwareVersion);
|
||||
Assert.IsNull(sshIdentification.Comments);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -13,17 +13,15 @@ namespace Renci.SshNet.Tests.Classes
|
||||
public partial class KeyboardInteractiveAuthenticationMethodTest : TestBase
|
||||
{
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Keyboard_Test_Pass_Null()
|
||||
{
|
||||
new KeyboardInteractiveAuthenticationMethod(null);
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new KeyboardInteractiveAuthenticationMethod(null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void Keyboard_Test_Pass_Whitespace()
|
||||
{
|
||||
new KeyboardInteractiveAuthenticationMethod(string.Empty);
|
||||
Assert.ThrowsException<ArgumentException>(() => new KeyboardInteractiveAuthenticationMethod(string.Empty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-6
@@ -175,11 +175,5 @@ namespace Renci.SshNet.Tests.Classes.Messages.Connection
|
||||
Assert.AreEqual(_rows, ptyReq.Rows);
|
||||
Assert.AreSame(_terminalModeValues, ptyReq.TerminalModeValues);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void NameShouldReturnPtyReq()
|
||||
{
|
||||
Assert.AreEqual("pty-req", PseudoTerminalRequestInfo.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Renci.SshNet.Tests.Classes.Messages.Transport
|
||||
m.Load(input);
|
||||
|
||||
Assert.IsFalse(m.FirstKexPacketFollows);
|
||||
Assert.IsTrue(m.Reserved == 0);
|
||||
Assert.AreEqual(0u, m.Reserved);
|
||||
Assert.IsTrue(m.CompressionAlgorithmsClientToServer.SequenceEqual(new[] { "none", "zlib@openssh.com" }));
|
||||
Assert.IsTrue(m.CompressionAlgorithmsServerToClient.SequenceEqual(new[] { "none", "zlib@openssh.com" }));
|
||||
Assert.IsTrue(m.EncryptionAlgorithmsClientToServer.SequenceEqual(new[] { "aes128-ctr", "aes192-ctr", "aes256-ctr", "arcfour256", "arcfour128", "aes128-cbc", "3des-cbc", "blowfish-cbc", "cast128-cbc", "aes192-cbc", "aes256-cbc", "arcfour", "rijndael-cbc@lysator.liu.se" }));
|
||||
|
||||
@@ -14,17 +14,15 @@ namespace Renci.SshNet.Tests.Classes
|
||||
public class NoneAuthenticationMethodTest : TestBase
|
||||
{
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void None_Test_Pass_Null()
|
||||
{
|
||||
new NoneAuthenticationMethod(null);
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new NoneAuthenticationMethod(null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void None_Test_Pass_Whitespace()
|
||||
{
|
||||
new NoneAuthenticationMethod(string.Empty);
|
||||
Assert.ThrowsException<ArgumentException>(() => new NoneAuthenticationMethod(string.Empty));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -13,17 +13,15 @@ namespace Renci.SshNet.Tests.Classes
|
||||
public partial class PasswordAuthenticationMethodTest : TestBase
|
||||
{
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Password_Test_Pass_Null_Username()
|
||||
{
|
||||
new PasswordAuthenticationMethod(null, "valid");
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new PasswordAuthenticationMethod(null, "valid"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Password_Test_Pass_Null_Password()
|
||||
{
|
||||
new PasswordAuthenticationMethod("valid", (string)null);
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new PasswordAuthenticationMethod("valid", (string)null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
@@ -33,10 +31,9 @@ namespace Renci.SshNet.Tests.Classes
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void Password_Test_Pass_Whitespace()
|
||||
{
|
||||
new PasswordAuthenticationMethod(string.Empty, "valid");
|
||||
Assert.ThrowsException<ArgumentException>(() => new PasswordAuthenticationMethod(string.Empty, "valid"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -31,38 +31,36 @@ namespace Renci.SshNet.Tests.Classes
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_ConnectionInfo_Username_Is_Null()
|
||||
{
|
||||
_ = new PasswordConnectionInfo(Resources.HOST, null, Resources.PASSWORD);
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new PasswordConnectionInfo(Resources.HOST, null, Resources.PASSWORD));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_ConnectionInfo_Password_Is_Null()
|
||||
{
|
||||
_ = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, (string)null);
|
||||
Assert.ThrowsException<ArgumentNullException>(
|
||||
() => new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, (string)null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void Test_ConnectionInfo_Username_Is_Whitespace()
|
||||
{
|
||||
_ = new PasswordConnectionInfo(Resources.HOST, " ", Resources.PASSWORD);
|
||||
Assert.ThrowsException<ArgumentException>(() => new PasswordConnectionInfo(Resources.HOST, " ", Resources.PASSWORD));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void Test_ConnectionInfo_SmallPortNumber()
|
||||
{
|
||||
_ = new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MinPort - 1, Resources.USERNAME, Resources.PASSWORD);
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(
|
||||
() => new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MinPort - 1, Resources.USERNAME, Resources.PASSWORD));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentOutOfRangeException))]
|
||||
public void Test_ConnectionInfo_BigPortNumber()
|
||||
{
|
||||
_ = new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MaxPort + 1, Resources.USERNAME, Resources.PASSWORD);
|
||||
Assert.ThrowsException<ArgumentOutOfRangeException>(
|
||||
() => new PasswordConnectionInfo(Resources.HOST, IPEndPoint.MaxPort + 1, Resources.USERNAME, Resources.PASSWORD));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,24 +13,21 @@ namespace Renci.SshNet.Tests.Classes
|
||||
public class PrivateKeyAuthenticationMethodTest : TestBase
|
||||
{
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void PrivateKey_Test_Pass_Null()
|
||||
{
|
||||
new PrivateKeyAuthenticationMethod(null, null);
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new PrivateKeyAuthenticationMethod(null, null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void PrivateKey_Test_Pass_PrivateKey_Null()
|
||||
{
|
||||
new PrivateKeyAuthenticationMethod("username", null);
|
||||
Assert.ThrowsException<ArgumentNullException>(() => new PrivateKeyAuthenticationMethod("username", null));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentException))]
|
||||
public void PrivateKey_Test_Pass_Whitespace()
|
||||
{
|
||||
new PrivateKeyAuthenticationMethod(string.Empty, null);
|
||||
Assert.ThrowsException<ArgumentException>(() => new PrivateKeyAuthenticationMethod(string.Empty, null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public abstract class SessionTest_ConnectedBase
|
||||
{
|
||||
internal Mock<IServiceFactory> ServiceFactoryMock { get; private set; }
|
||||
|
||||
@@ -21,7 +21,6 @@ using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestClass]
|
||||
public abstract class SessionTest_ConnectingBase
|
||||
{
|
||||
internal Mock<IServiceFactory> ServiceFactoryMock { get; private set; }
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Sftp.Requests
|
||||
{
|
||||
[TestClass]
|
||||
public class SftpInitRequestTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Sftp.Responses
|
||||
{
|
||||
[TestClass]
|
||||
public class SftpNameResponseTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Sftp.Responses
|
||||
{
|
||||
[TestClass]
|
||||
public class SftpStatusResponseTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Renci.SshNet.Tests.Common;
|
||||
|
||||
namespace Renci.SshNet.Tests.Classes.Sftp.Responses
|
||||
{
|
||||
[TestClass]
|
||||
public class SftpVersionResponseTest : TestBase
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -12,12 +12,11 @@ namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SshConnectionException))]
|
||||
public void Test_Sftp_DeleteDirectory_Without_Connecting()
|
||||
{
|
||||
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
|
||||
{
|
||||
sftp.DeleteDirectory("test");
|
||||
Assert.ThrowsException<SshConnectionException>(() => sftp.DeleteDirectory("test"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,11 @@ namespace Renci.SshNet.Tests.Classes
|
||||
public partial class SftpClientTest
|
||||
{
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public void Test_Sftp_DeleteFile_Null()
|
||||
{
|
||||
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
|
||||
{
|
||||
sftp.DeleteFile(null);
|
||||
Assert.ThrowsException<ArgumentNullException>(() => sftp.DeleteFile(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,12 +13,11 @@ namespace Renci.SshNet.Tests.Classes
|
||||
public partial class SftpClientTest
|
||||
{
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(ArgumentNullException))]
|
||||
public async Task Test_Sftp_DeleteFileAsync_Null()
|
||||
{
|
||||
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
|
||||
{
|
||||
await sftp.DeleteFileAsync(null, default);
|
||||
await Assert.ThrowsExceptionAsync<ArgumentNullException>(() => sftp.DeleteFileAsync(null, default));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Tests.Properties;
|
||||
@@ -14,16 +12,11 @@ namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SshConnectionException))]
|
||||
public void Test_Sftp_ListDirectory_Without_Connecting()
|
||||
{
|
||||
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
|
||||
{
|
||||
var files = sftp.ListDirectory(".");
|
||||
foreach (var file in files)
|
||||
{
|
||||
Debug.WriteLine(file.FullName);
|
||||
}
|
||||
Assert.ThrowsException<SshConnectionException>(() => sftp.ListDirectory("."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
@@ -16,15 +15,16 @@ namespace Renci.SshNet.Tests.Classes
|
||||
{
|
||||
[TestMethod]
|
||||
[TestCategory("Sftp")]
|
||||
[ExpectedException(typeof(SshConnectionException))]
|
||||
public async Task Test_Sftp_ListDirectoryAsync_Without_ConnectingAsync()
|
||||
{
|
||||
using (var sftp = new SftpClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
|
||||
{
|
||||
await foreach (var file in sftp.ListDirectoryAsync(".", CancellationToken.None))
|
||||
await Assert.ThrowsExceptionAsync<SshConnectionException>(async () =>
|
||||
{
|
||||
Debug.WriteLine(file.FullName);
|
||||
}
|
||||
await foreach (var x in sftp.ListDirectoryAsync(".", CancellationToken.None))
|
||||
{
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
using Renci.SshNet.Common;
|
||||
using Renci.SshNet.Tests.Common;
|
||||
@@ -15,25 +13,12 @@ namespace Renci.SshNet.Tests.Classes
|
||||
public partial class SshCommandTest : TestBase
|
||||
{
|
||||
[TestMethod]
|
||||
[ExpectedException(typeof(SshConnectionException))]
|
||||
public void Test_Execute_SingleCommand_Without_Connecting()
|
||||
{
|
||||
using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
|
||||
{
|
||||
var result = ExecuteTestCommand(client);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
Assert.ThrowsException<SshConnectionException>(() => client.CreateCommand("echo Hello"));
|
||||
}
|
||||
}
|
||||
|
||||
private static bool ExecuteTestCommand(SshClient s)
|
||||
{
|
||||
var testValue = Guid.NewGuid().ToString();
|
||||
var command = string.Format("echo {0}", testValue);
|
||||
var cmd = s.CreateCommand(command);
|
||||
var result = cmd.Execute();
|
||||
result = result.Substring(0, result.Length - 1); // Remove \n character returned by command
|
||||
return result.Equals(testValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
@@ -393,31 +392,11 @@ namespace Renci.SshNet.Tests.Classes
|
||||
[TestMethod]
|
||||
public void EnableActivatedMessagesShouldLeaveMessagesEnabledThatWereEnabledAfterInvokingDisableNonKeyExchangeMessages()
|
||||
{
|
||||
const byte messageNumber = 60;
|
||||
|
||||
_sshMessageFactory.DisableNonKeyExchangeMessages(strict: false);
|
||||
_sshMessageFactory.EnableAndActivateMessage("SSH_MSG_USERAUTH_PASSWD_CHANGEREQ");
|
||||
_sshMessageFactory.EnableActivatedMessages();
|
||||
|
||||
var actual = _sshMessageFactory.Create(messageNumber);
|
||||
Assert.IsNotNull(actual);
|
||||
Assert.AreEqual(typeof(PasswordChangeRequiredMessage), actual.GetType());
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void HighestMessageNumberShouldCorrespondWithHighestSupportedMessageNumber()
|
||||
{
|
||||
var highestSupportMessageNumber = SshMessageFactory.AllMessages.Max(m => m.Number);
|
||||
|
||||
Assert.AreEqual(highestSupportMessageNumber, SshMessageFactory.HighestMessageNumber);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TotalMessageCountShouldBeTotalNumberOfSupportedMessages()
|
||||
{
|
||||
var totalNumberOfSupportedMessages = SshMessageFactory.AllMessages.Length;
|
||||
|
||||
Assert.AreEqual(totalNumberOfSupportedMessages, SshMessageFactory.TotalMessageCount);
|
||||
Assert.IsInstanceOfType<PasswordChangeRequiredMessage>(_sshMessageFactory.Create(60));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace Renci.SshNet.Tests.Common
|
||||
{
|
||||
[TestClass]
|
||||
public abstract class TestBase
|
||||
{
|
||||
private static readonly Assembly ExecutingAssembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
Reference in New Issue
Block a user