Skip to content

Commit 16d84d0

Browse files
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](coverlet-coverage/coverlet@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] <[email protected]> * 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] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Robert Hague <[email protected]> Co-authored-by: Rob Hague <[email protected]>
1 parent 7a599e2 commit 16d84d0

File tree

50 files changed

+192
-500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+192
-500
lines changed

.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,17 @@ MA0053.class_with_virtual_member_shoud_be_sealed = true
610610
# This rule is disabled by default, hence we need to explicitly enable it.
611611
dotnet_diagnostic.MA0112.severity = error
612612

613+
# MA0165: Make interpolated string
614+
dotnet_diagnostic.MA0165.severity = none
615+
616+
#### MSTest rules ####
617+
618+
# MSTEST0015: Test method should not be ignored
619+
dotnet_diagnostic.MSTEST0015.severity = suggestion
620+
621+
# MSTEST0032: Assertion condition is always true
622+
dotnet_diagnostic.MSTEST0032.severity = suggestion
623+
613624
#### .NET Compiler Platform code quality rules ####
614625

615626
# CA1002: Do not expose generic lists

.github/dependabot.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,26 @@ updates:
88
- package-ecosystem: "docker"
99
directory: "/test/Renci.SshNet.IntegrationTests/"
1010
schedule:
11-
interval: "weekly"
11+
interval: "monthly"
1212

1313
- package-ecosystem: "nuget"
1414
directory: "/"
1515
schedule:
16-
interval: "weekly"
17-
ignore:
18-
# AsyncInterface must stay at 1.0.0 because of https://github.com/sshnet/SSH.NET/pull/1288
16+
interval: "monthly"
17+
ignore: # See justifications in Directory.Packages.props
1918
- dependency-name: "Microsoft.Bcl.AsyncInterfaces"
20-
# These should stay on LTS .NET Releases
19+
2120
- dependency-name: "System.Formats.Asn1"
2221
update-types: ["version-update:semver-major"]
23-
- dependency-name: "Microsoft.Extensions.Logging.*"
22+
23+
- dependency-name: "Microsoft.Extensions.Logging.Abstractions"
2424
update-types: ["version-update:semver-major"]
25+
groups:
26+
dependencies:
27+
patterns:
28+
- "*"
2529

2630
- package-ecosystem: "github-actions"
2731
directory: "/"
2832
schedule:
29-
interval: "weekly"
33+
interval: "monthly"

Directory.Packages.props

+16-12
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,31 @@
66
<ItemGroup>
77
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
88
<PackageVersion Include="BouncyCastle.Cryptography" Version="2.5.0" />
9-
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
10-
<PackageVersion Include="coverlet.msbuild" Version="6.0.2" />
9+
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
10+
<PackageVersion Include="coverlet.msbuild" Version="6.0.4" />
1111
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1">
1212
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
<PrivateAssets>all</PrivateAssets>
1414
</PackageVersion>
15-
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.163" />
16-
<!-- Must be kept at version 1.0.0 or higher, see https://github.com/sshnet/SSH.NET/pull/1288 for details. -->
15+
<PackageVersion Include="Meziantou.Analyzer" Version="2.0.186" />
16+
17+
<!-- Must be kept at version 1.0.0, see https://github.com/sshnet/SSH.NET/pull/1288 for details. -->
1718
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="1.0.0" />
18-
<PackageVersion Include="Microsoft.Extensions.Logging" Version="8.0.0" />
19+
20+
<!-- No reason to require later than 6.0.0 at this time. -->
1921
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
20-
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
22+
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" />
2123
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
22-
<PackageVersion Include="MSTest.TestAdapter" Version="3.6.2" />
23-
<PackageVersion Include="MSTest.TestFramework" Version="3.6.2" />
24+
<PackageVersion Include="MSTest.TestAdapter" Version="3.7.3" />
25+
<PackageVersion Include="MSTest.TestFramework" Version="3.7.3" />
2426
<PackageVersion Include="Moq" Version="4.20.72" />
25-
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.77-alpha" /> <!-- can use stable once 3.7 is released -->
26-
<PackageVersion Include="PolySharp" Version="1.14.1" />
27-
<PackageVersion Include="SonarAnalyzer.CSharp" Version="9.32.0.97167" />
27+
<PackageVersion Include="Nerdbank.GitVersioning" Version="3.7.115" />
28+
<PackageVersion Include="PolySharp" Version="1.15.0" />
29+
<PackageVersion Include="SonarAnalyzer.CSharp" Version="10.6.0.109712" />
2830
<PackageVersion Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
31+
32+
<!-- Should stay on LTS .NET releases. -->
2933
<PackageVersion Include="System.Formats.Asn1" Version="8.0.1" />
30-
<PackageVersion Include="Testcontainers" Version="4.0.0" />
34+
<PackageVersion Include="Testcontainers" Version="4.1.0" />
3135
</ItemGroup>
3236
</Project>

Renci.SshNet.sln

+3
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ EndProject
8383
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Renci.SshNet.AotCompatibilityTestApp", "test\Renci.SshNet.AotCompatibilityTestApp\Renci.SshNet.AotCompatibilityTestApp.csproj", "{F2E3FC50-4EF4-488C-B3D2-C45E99898D8B}"
8484
EndProject
8585
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{05229079-6738-42CE-8F73-F4E182929B03}"
86+
ProjectSection(SolutionItems) = preProject
87+
.github\dependabot.yml = .github\dependabot.yml
88+
EndProjectSection
8689
EndProject
8790
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{95F25B1A-2B14-4745-9087-43C00CD90EE0}"
8891
ProjectSection(SolutionItems) = preProject

src/Renci.SshNet/SshMessageFactory.cs

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.Globalization;
5+
using System.Linq;
6+
47
#if NET9_0_OR_GREATER
58
using System.Threading;
69
#endif
@@ -19,7 +22,7 @@ internal sealed class SshMessageFactory
1922
private readonly bool[] _activatedMessagesById;
2023
private readonly Lock _lock = new Lock();
2124

22-
internal static readonly MessageMetadata[] AllMessages = new MessageMetadata[]
25+
private static readonly MessageMetadata[] AllMessages = new MessageMetadata[]
2326
{
2427
new MessageMetadata<KeyExchangeInitMessage>(0, "SSH_MSG_KEXINIT", 20),
2528
new MessageMetadata<NewKeysMessage>(1, "SSH_MSG_NEWKEYS", 21),
@@ -55,24 +58,22 @@ internal sealed class SshMessageFactory
5558
new MessageMetadata<KeyExchangeEcdhReplyMessage>(31, "SSH_MSG_KEX_ECDH_REPLY", 31),
5659
new MessageMetadata<KeyExchangeHybridReplyMessage>(32, "SSH_MSG_KEX_HYBRID_REPLY", 31)
5760
};
61+
5862
private static readonly Dictionary<string, MessageMetadata> MessagesByName = CreateMessagesByNameMapping();
5963

6064
/// <summary>
6165
/// Defines the highest message number that is currently supported.
6266
/// </summary>
6367
internal const byte HighestMessageNumber = 100;
6468

65-
/// <summary>
66-
/// Defines the total number of supported messages.
67-
/// </summary>
68-
internal const int TotalMessageCount = 33;
69-
7069
/// <summary>
7170
/// Initializes a new instance of the <see cref="SshMessageFactory"/> class.
7271
/// </summary>
7372
public SshMessageFactory()
7473
{
75-
_activatedMessagesById = new bool[TotalMessageCount];
74+
Debug.Assert(AllMessages.Max(m => m.Number) == HighestMessageNumber);
75+
76+
_activatedMessagesById = new bool[AllMessages.Length];
7677
_enabledMessagesByNumber = new MessageMetadata[HighestMessageNumber + 1];
7778
}
7879

@@ -289,7 +290,9 @@ public MessageMetadata(byte id, string name, byte number)
289290

290291
public override Message Create()
291292
{
292-
return new T();
293+
var message = new T();
294+
Debug.Assert(message.MessageNumber == Number);
295+
return message;
293296
}
294297
}
295298
}

test/Renci.SshNet.IntegrationTests/AuthenticationTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ public void KeyboardInteractive_PasswordExpired()
352352
// Password expired, retype new password
353353
authenticationPrompt.Response = Users.Regular.Password;
354354
break;
355+
default:
356+
break;
355357
}
356358

357359
authenticationPromptCount++;

test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ForwardedPortLocalTest.cs

+1-50
Original file line numberDiff line numberDiff line change
@@ -100,61 +100,12 @@ public void Test_PortForwarding_Local_Stop_Hangs_On_Wait()
100100
}
101101

102102
[TestMethod]
103-
[ExpectedException(typeof(SshConnectionException))]
104103
public void Test_PortForwarding_Local_Without_Connecting()
105104
{
106105
using (var client = new SshClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
107106
{
108107
using var port1 = new ForwardedPortLocal("localhost", 8084, "www.renci.org", 80);
109-
client.AddForwardedPort(port1);
110-
port1.Exception += delegate (object sender, ExceptionEventArgs e)
111-
{
112-
Assert.Fail(e.Exception.ToString());
113-
};
114-
port1.Start();
115-
116-
var test = Parallel.For(0,
117-
100,
118-
counter =>
119-
{
120-
var start = DateTime.Now;
121-
122-
#if NET6_0_OR_GREATER
123-
var httpClient = new HttpClient();
124-
using (var response = httpClient.GetAsync("http://localhost:8084").GetAwaiter().GetResult())
125-
{
126-
var data = ReadStream(response.Content.ReadAsStream());
127-
#else
128-
var request = (HttpWebRequest)WebRequest.Create("http://localhost:8084");
129-
using (var response = (HttpWebResponse)request.GetResponse())
130-
{
131-
var data = ReadStream(response.GetResponseStream());
132-
#endif // NET6_0_OR_GREATER
133-
var end = DateTime.Now;
134-
135-
Debug.WriteLine(string.Format("Request# {2}: Lenght: {0} Time: {1}", data.Length, end - start, counter));
136-
}
137-
});
138-
}
139-
}
140-
141-
private static byte[] ReadStream(Stream stream)
142-
{
143-
var buffer = new byte[1024];
144-
using (var ms = new MemoryStream())
145-
{
146-
while (true)
147-
{
148-
var read = stream.Read(buffer, 0, buffer.Length);
149-
if (read > 0)
150-
{
151-
ms.Write(buffer, 0, read);
152-
}
153-
else
154-
{
155-
return ms.ToArray();
156-
}
157-
}
108+
Assert.ThrowsException<SshConnectionException>(() => client.AddForwardedPort(port1));
158109
}
159110
}
160111
}

test/Renci.SshNet.IntegrationTests/OldIntegrationTests/ScpClientTest.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ where CalculateMD5(file) == CalculateMD5(string.Format("{0}.down", file))
240240

241241
scp.Disconnect();
242242

243-
Assert.IsTrue(result.Count() == uploadFilenames.Length);
243+
Assert.AreEqual(uploadFilenames.Length, result.Count());
244244
}
245245
}
246246

test/Renci.SshNet.IntegrationTests/OldIntegrationTests/SftpClientTest.ChangeDirectory.cs

+16-16
Original file line numberDiff line numberDiff line change
@@ -9,97 +9,97 @@ public partial class SftpClientTest : IntegrationTestBase
99
{
1010
[TestMethod]
1111
[TestCategory("Sftp")]
12-
[ExpectedException(typeof(SftpPathNotFoundException))]
1312
public void Test_Sftp_ChangeDirectory_Root_Dont_Exists()
1413
{
1514
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
1615
{
1716
sftp.Connect();
18-
sftp.ChangeDirectory("/asdasd");
17+
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd"));
1918
}
2019
}
2120

2221
[TestMethod]
2322
[TestCategory("Sftp")]
24-
[ExpectedException(typeof(SftpPathNotFoundException))]
2523
public async Task Test_Sftp_ChangeDirectory_Root_Dont_ExistsAsync()
2624
{
2725
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
2826
{
2927
await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
30-
await sftp.ChangeDirectoryAsync("/asdasd", CancellationToken.None).ConfigureAwait(false);
28+
29+
await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
30+
() => sftp.ChangeDirectoryAsync("/asdasd", CancellationToken.None));
3131
}
3232
}
3333

3434
[TestMethod]
3535
[TestCategory("Sftp")]
36-
[ExpectedException(typeof(SftpPathNotFoundException))]
3736
public void Test_Sftp_ChangeDirectory_Root_With_Slash_Dont_Exists()
3837
{
3938
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
4039
{
4140
sftp.Connect();
42-
sftp.ChangeDirectory("/asdasd/");
41+
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/"));
4342
}
4443
}
4544

4645
[TestMethod]
4746
[TestCategory("Sftp")]
48-
[ExpectedException(typeof(SftpPathNotFoundException))]
4947
public async Task Test_Sftp_ChangeDirectory_Root_With_Slash_Dont_ExistsAsync()
5048
{
5149
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
5250
{
5351
await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
54-
await sftp.ChangeDirectoryAsync("/asdasd/", CancellationToken.None).ConfigureAwait(false);
52+
53+
await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
54+
() => sftp.ChangeDirectoryAsync("/asdasd/", CancellationToken.None));
5555
}
5656
}
5757

5858
[TestMethod]
5959
[TestCategory("Sftp")]
60-
[ExpectedException(typeof(SftpPathNotFoundException))]
6160
public void Test_Sftp_ChangeDirectory_Subfolder_Dont_Exists()
6261
{
6362
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
6463
{
6564
sftp.Connect();
66-
sftp.ChangeDirectory("/asdasd/sssddds");
65+
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/sssddds"));
6766
}
6867
}
6968

7069
[TestMethod]
7170
[TestCategory("Sftp")]
72-
[ExpectedException(typeof(SftpPathNotFoundException))]
7371
public async Task Test_Sftp_ChangeDirectory_Subfolder_Dont_ExistsAsync()
7472
{
7573
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
7674
{
7775
await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
78-
await sftp.ChangeDirectoryAsync("/asdasd/sssddds", CancellationToken.None).ConfigureAwait(false);
76+
77+
await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
78+
() => sftp.ChangeDirectoryAsync("/asdasd/sssddds", CancellationToken.None));
7979
}
8080
}
8181

8282
[TestMethod]
8383
[TestCategory("Sftp")]
84-
[ExpectedException(typeof(SftpPathNotFoundException))]
8584
public void Test_Sftp_ChangeDirectory_Subfolder_With_Slash_Dont_Exists()
8685
{
8786
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
8887
{
8988
sftp.Connect();
90-
sftp.ChangeDirectory("/asdasd/sssddds/");
89+
Assert.ThrowsException<SftpPathNotFoundException>(() => sftp.ChangeDirectory("/asdasd/sssddds/"));
9190
}
9291
}
9392

9493
[TestMethod]
9594
[TestCategory("Sftp")]
96-
[ExpectedException(typeof(SftpPathNotFoundException))]
9795
public async Task Test_Sftp_ChangeDirectory_Subfolder_With_Slash_Dont_ExistsAsync()
9896
{
9997
using (var sftp = new SftpClient(SshServerHostName, SshServerPort, User.UserName, User.Password))
10098
{
10199
await sftp.ConnectAsync(CancellationToken.None).ConfigureAwait(false);
102-
await sftp.ChangeDirectoryAsync("/asdasd/sssddds/", CancellationToken.None).ConfigureAwait(false);
100+
101+
await Assert.ThrowsExceptionAsync<SftpPathNotFoundException>(
102+
() => sftp.ChangeDirectoryAsync("/asdasd/sssddds/", CancellationToken.None));
103103
}
104104
}
105105

0 commit comments

Comments
 (0)