chore: update deps

This commit is contained in:
Peter 2023-09-15 19:01:48 +02:00
parent 222715b077
commit 2061f6f684
No known key found for this signature in database
19 changed files with 116 additions and 81 deletions

View file

@ -14,6 +14,16 @@ indent_size = 4
indent_size = 4 indent_size = 4
csharp_style_namespace_declarations = file_scoped:warning csharp_style_namespace_declarations = file_scoped:warning
csharp_prefer_braces = true:warning csharp_prefer_braces = true:warning
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
dotnet_style_require_accessibility_modifiers = never:warning
csharp_style_expression_bodied_methods = true:silent
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_accessors = true:warning
[*.json] [*.json]
indent_size = 2 indent_size = 2

View file

@ -2,7 +2,6 @@ using NuGet.Versioning;
using Nuke.Common; using Nuke.Common;
using Nuke.Common.CI; using Nuke.Common.CI;
using Nuke.Common.CI.GitLab; using Nuke.Common.CI.GitLab;
using Nuke.Common.Execution;
using Nuke.Common.Git; using Nuke.Common.Git;
using Nuke.Common.IO; using Nuke.Common.IO;
using Nuke.Common.ProjectModel; using Nuke.Common.ProjectModel;
@ -13,20 +12,19 @@ using Nuke.Common.Utilities.Collections;
using static Nuke.Common.IO.FileSystemTasks; using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks; using static Nuke.Common.Tools.DotNet.DotNetTasks;
[CheckBuildProjectConfigurations]
[ShutdownDotNetAfterServerBuild] [ShutdownDotNetAfterServerBuild]
class Build : NukeBuild class Build : NukeBuild
{ {
private const string NuGetSourceName = "GitLab"; const string NuGetSourceName = "GitLab";
public static int Main() => Execute<Build>(x => x.Test);
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
[Solution] readonly Solution? Solution;
[GitRepository] readonly GitRepository? GitRepository; [GitRepository] readonly GitRepository? GitRepository;
[GitVersion(Framework = "net6.0", NoFetch = true)] readonly GitVersion? GitVersion; [GitVersion(Framework = "net6.0", NoFetch = true)] readonly GitVersion? GitVersion;
[Solution] readonly Solution? Solution;
GitLab? CI => GitLab.Instance; GitLab? CI => GitLab.Instance;
@ -90,7 +88,8 @@ class Build : NukeBuild
.SetProject(csproj) .SetProject(csproj)
.SetConfiguration(Configuration) .SetConfiguration(Configuration)
.SetOutputDirectory(ArtifactsDirectory) .SetOutputDirectory(ArtifactsDirectory)
.SetVersion(GitVersion?.NuGetVersionV2 ?? SemanticVersion.Parse(CI?.CommitTag?.TrimStart('v') ?? "0.0.1").ToNormalizedString()) .SetVersion(GitVersion?.NuGetVersionV2 ??
SemanticVersion.Parse(CI?.CommitTag?.TrimStart('v') ?? "0.0.1").ToNormalizedString())
.EnableIncludeSource() .EnableIncludeSource()
.EnableIncludeSymbols() .EnableIncludeSymbols()
.EnableNoRestore() .EnableNoRestore()
@ -117,4 +116,6 @@ class Build : NukeBuild
.SetSource(NuGetSourceName) .SetSource(NuGetSourceName)
.SetTargetPath(nupkg) .SetTargetPath(nupkg)
.EnableProcessLogOutput()))); .EnableProcessLogOutput())));
public static int Main() => Execute<Build>(x => x.Test);
} }

View file

@ -7,8 +7,5 @@ public class Configuration : Enumeration
public static Configuration Debug = new() { Value = nameof(Debug) }; public static Configuration Debug = new() { Value = nameof(Debug) };
public static Configuration Release = new() { Value = nameof(Release) }; public static Configuration Release = new() { Value = nameof(Release) };
public static implicit operator string(Configuration configuration) public static implicit operator string(Configuration configuration) => configuration.Value;
{
return configuration.Value;
}
} }

View file

@ -13,7 +13,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Nuke.Common" Version="6.2.1" /> <PackageReference Include="Nuke.Common" Version="7.0.5"/>
<PackageDownload Include="GitVersion.Tool" Version="[5.8.0]"/> <PackageDownload Include="GitVersion.Tool" Version="[5.8.0]"/>
</ItemGroup> </ItemGroup>

View file

@ -71,7 +71,6 @@ public record Event<T> : EventBase where T : EventDetails, new()
{ {
public Event() public Event()
{ {
} }
public Event(EventEntity entity) : base(entity) public Event(EventEntity entity) : base(entity)

View file

@ -10,7 +10,6 @@ public interface IEventReader : IDisposable, IAsyncDisposable
IAsyncEnumerable<Event> ReadAllAsync(CancellationToken token = default); IAsyncEnumerable<Event> ReadAllAsync(CancellationToken token = default);
/// <summary> /// <summary>
///
/// </summary> /// </summary>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns> /// <returns>
@ -25,7 +24,6 @@ public interface IEventReader<T> : IDisposable, IAsyncDisposable where T : Event
IAsyncEnumerable<Event<T>> ReadAllAsync(CancellationToken token = default); IAsyncEnumerable<Event<T>> ReadAllAsync(CancellationToken token = default);
/// <summary> /// <summary>
///
/// </summary> /// </summary>
/// <param name="token"></param> /// <param name="token"></param>
/// <returns> /// <returns>

View file

@ -1,7 +1,6 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Inetmock.Audit.V1;
namespace INetMock.Client.Audit; namespace INetMock.Client.Audit;

View file

@ -9,9 +9,9 @@ namespace INetMock.Client.Audit.Serialization;
public sealed class ProtoReader : IProtoEventReader public sealed class ProtoReader : IProtoEventReader
{ {
private readonly bool _keepStreamOpen;
private readonly MemoryPool<byte> _memoryPool; private readonly MemoryPool<byte> _memoryPool;
private readonly Stream _sourceStream; private readonly Stream _sourceStream;
private readonly bool _keepStreamOpen;
public ProtoReader(Stream sourceStream, bool keepStreamOpen = false) public ProtoReader(Stream sourceStream, bool keepStreamOpen = false)
{ {

View file

@ -27,8 +27,8 @@ public enum DropMode
public sealed class TypedReader<T> : IEventReader<T> where T : EventDetails, new() public sealed class TypedReader<T> : IEventReader<T> where T : EventDetails, new()
{ {
private readonly IProtoEventReader _reader;
private readonly DropMode _dropMode; private readonly DropMode _dropMode;
private readonly IProtoEventReader _reader;
public TypedReader(IProtoEventReader reader, DropMode dropMode = DropMode.DropDetails) public TypedReader(IProtoEventReader reader, DropMode dropMode = DropMode.DropDetails)
{ {
@ -76,7 +76,13 @@ public sealed class TypedReader<T> : IEventReader<T> where T : EventDetails, new
} while (true); } while (true);
} }
public void Dispose() => _reader.Dispose(); public void Dispose()
{
public ValueTask DisposeAsync() => _reader.DisposeAsync(); _reader.Dispose();
}
public ValueTask DisposeAsync()
{
return _reader.DisposeAsync();
}
} }

View file

@ -9,10 +9,10 @@
<Using Include="Inetmock.Rpc.V1"/> <Using Include="Inetmock.Rpc.V1"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.6" /> <PackageReference Include="Google.Protobuf" Version="3.24.3"/>
<PackageReference Include="Grpc.Net.Client" Version="2.49.0" /> <PackageReference Include="Grpc.Net.Client" Version="2.57.0"/>
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.49.0" /> <PackageReference Include="Grpc.Net.ClientFactory" Version="2.57.0"/>
<PackageReference Include="Grpc.Tools" Version="2.49.0"> <PackageReference Include="Grpc.Tools" Version="2.58.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View file

@ -7,7 +7,7 @@ using System.Threading.Tasks;
using Google.Protobuf.WellKnownTypes; using Google.Protobuf.WellKnownTypes;
using Grpc.Core; using Grpc.Core;
using Grpc.Net.Client; using Grpc.Net.Client;
using ChannelFactory = INetMock.Client.Grpc.ChannelFactory; using INetMock.Client.Grpc;
namespace INetMock.Client.PCAP.Client; namespace INetMock.Client.PCAP.Client;
@ -32,7 +32,13 @@ public class PcapApiClient : IPcapApiClient
public async Task<IReadOnlyList<RecordingDevice>> ListAvailableDevicesAsync(CancellationToken token = default) public async Task<IReadOnlyList<RecordingDevice>> ListAvailableDevicesAsync(CancellationToken token = default)
{ {
var devices = await _pcapServiceClient.ListAvailableDevicesAsync(new(), Metadata.Empty, null, token); var devices = await _pcapServiceClient.ListAvailableDevicesAsync(
new ListAvailableDevicesRequest(),
Metadata.Empty,
null,
token
);
return devices.AvailableDevices return devices.AvailableDevices
.Select(d => new RecordingDevice( .Select(d => new RecordingDevice(
d.Name, d.Name,
@ -46,7 +52,13 @@ public class PcapApiClient : IPcapApiClient
public async Task<IReadOnlyList<Subscription>> ListActiveRecordingsAsync(CancellationToken token = default) public async Task<IReadOnlyList<Subscription>> ListActiveRecordingsAsync(CancellationToken token = default)
{ {
var recordings = await _pcapServiceClient.ListActiveRecordingsAsync(new(), Metadata.Empty, null, token); var recordings = await _pcapServiceClient.ListActiveRecordingsAsync(
new ListActiveRecordingsRequest(),
Metadata.Empty,
null,
token
);
return recordings.Subscriptions return recordings.Subscriptions
.Select(consumerKey => new Subscription(consumerKey)) .Select(consumerKey => new Subscription(consumerKey))
.ToList(); .ToList();

View file

@ -20,6 +20,7 @@ public class TypedReaderTest
Assert.NotNull(ev); Assert.NotNull(ev);
count++; count++;
} }
Assert.True(count > 0); Assert.True(count > 0);
} }
@ -27,7 +28,8 @@ public class TypedReaderTest
public async Task Test_ReadAllAsync_DropEntity_AuditFile_HTTPEvents() public async Task Test_ReadAllAsync_DropEntity_AuditFile_HTTPEvents()
{ {
await using var fileStream = File.OpenRead(Path.Join("testdata", "test.ima")); await using var fileStream = File.OpenRead(Path.Join("testdata", "test.ima"));
await using IEventReader<HttpDetails> httpReader = new TypedReader<HttpDetails>(new ProtoReader(fileStream), DropMode.DropEntity); await using IEventReader<HttpDetails> httpReader =
new TypedReader<HttpDetails>(new ProtoReader(fileStream), DropMode.DropEntity);
var count = 0; var count = 0;
await foreach (var ev in httpReader.ReadAllAsync()) await foreach (var ev in httpReader.ReadAllAsync())
@ -36,6 +38,7 @@ public class TypedReaderTest
Assert.NotNull(ev.Details); Assert.NotNull(ev.Details);
count++; count++;
} }
Assert.True(count > 0); Assert.True(count > 0);
} }
@ -51,6 +54,7 @@ public class TypedReaderTest
Assert.NotNull(ev); Assert.NotNull(ev);
count++; count++;
} }
Assert.True(count > 0); Assert.True(count > 0);
} }
@ -58,7 +62,8 @@ public class TypedReaderTest
public async Task Test_ReadAllAsync_DropEntity_AuditFile_DNSEvents() public async Task Test_ReadAllAsync_DropEntity_AuditFile_DNSEvents()
{ {
await using var fileStream = File.OpenRead(Path.Join("testdata", "test.ima")); await using var fileStream = File.OpenRead(Path.Join("testdata", "test.ima"));
await using IEventReader<DnsDetails> httpReader = new TypedReader<DnsDetails>(new ProtoReader(fileStream), DropMode.DropEntity); await using IEventReader<DnsDetails> httpReader =
new TypedReader<DnsDetails>(new ProtoReader(fileStream), DropMode.DropEntity);
var count = 0; var count = 0;
await foreach (var ev in httpReader.ReadAllAsync()) await foreach (var ev in httpReader.ReadAllAsync())
@ -66,6 +71,7 @@ public class TypedReaderTest
Assert.NotNull(ev); Assert.NotNull(ev);
count++; count++;
} }
Assert.True(count > 0); Assert.True(count > 0);
} }
} }

View file

@ -11,14 +11,14 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/>
<PackageReference Include="Testcontainers" Version="2.1.0" /> <PackageReference Include="Testcontainers" Version="3.5.0"/>
<PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit" Version="2.5.0"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> <PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2"> <PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
</PackageReference> </PackageReference>

View file

@ -11,7 +11,7 @@ namespace INetMock.Client.IntegrationTest;
public class INetMockFixture : IAsyncLifetime public class INetMockFixture : IAsyncLifetime
{ {
private const string DefaultINetMockSocketPath = "unix:///var/run/inetmock/inetmock.sock"; private const string DefaultINetMockSocketPath = "unix:///var/run/inetmock/inetmock.sock";
private readonly ITestcontainersContainer _inetmockContainer; private readonly IContainer _inetmockContainer;
private readonly Stream _memStream = new MemoryStream(); private readonly Stream _memStream = new MemoryStream();
@ -20,12 +20,11 @@ public class INetMockFixture : IAsyncLifetime
{ {
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true); AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
_inetmockContainer = new ContainerBuilder()
_inetmockContainer = new TestcontainersBuilder<TestcontainersContainer>()
.WithPrivileged(true) .WithPrivileged(true)
.WithExposedPort(6767) .WithExposedPort(6767)
.WithPortBinding(6767, true) .WithPortBinding(6767, true)
.WithCreateContainerParametersModifier(parameters => { parameters.User = "root"; }) .WithCreateParameterModifier(parameters => { parameters.User = "root"; })
.WithEnvironment("INETMOCK_API_LISTEN", "tcp://0.0.0.0:6767") .WithEnvironment("INETMOCK_API_LISTEN", "tcp://0.0.0.0:6767")
.WithImage("registry.gitlab.com/inetmock/inetmock:latest") .WithImage("registry.gitlab.com/inetmock/inetmock:latest")
.WithName("inetmock") .WithName("inetmock")

View file

@ -8,8 +8,8 @@ namespace INetMock.Client.IntegrationTest.PCAP.Client;
public class PcapApiClientTests : IClassFixture<INetMockFixture> public class PcapApiClientTests : IClassFixture<INetMockFixture>
{ {
private readonly ITestOutputHelper _outputHelper;
private readonly IPcapApiClient _apiClient; private readonly IPcapApiClient _apiClient;
private readonly ITestOutputHelper _outputHelper;
public PcapApiClientTests(ITestOutputHelper testOutputHelper, INetMockFixture inetMockFixture) public PcapApiClientTests(ITestOutputHelper testOutputHelper, INetMockFixture inetMockFixture)
{ {
@ -48,7 +48,7 @@ public class PcapApiClientTests : IClassFixture<INetMockFixture>
} }
var targetPath = $"/tmp/{recordingDevice.Name}_record.pcap"; var targetPath = $"/tmp/{recordingDevice.Name}_record.pcap";
await _apiClient.StartPcapFileRecordingAsync(new(recordingDevice.Name, targetPath)); await _apiClient.StartPcapFileRecordingAsync(new RecordingRequest(recordingDevice.Name, targetPath));
var subscriptions = await _apiClient.ListActiveRecordingsAsync(); var subscriptions = await _apiClient.ListActiveRecordingsAsync();
Assert.Contains(subscriptions, subscription => Assert.Contains(subscriptions, subscription =>

View file

@ -8,11 +8,15 @@ namespace INetMock.Client.Test.Audit.Serialization;
public class GenericReaderTest public class GenericReaderTest
{ {
private const string HttpEventPayload = "000000a7120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374a2014c080112096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e"; private const string HttpEventPayload =
private const string DnsEventPayload = "0000004e120b088092b8c398feffffff01180220012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050aa0110120e0801120a6769746c61622e636f6d"; "000000a7120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374a2014c080112096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e";
private const string DnsEventPayload =
"0000004e120b088092b8c398feffffff01180220012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050aa0110120e0801120a6769746c61622e636f6d";
private readonly byte[] _dnsEventPayloadBytes;
private readonly byte[] _httpEventPayloadBytes; private readonly byte[] _httpEventPayloadBytes;
private readonly byte[] _dnsEventPayloadBytes;
public GenericReaderTest() public GenericReaderTest()
{ {

View file

@ -8,11 +8,15 @@ namespace INetMock.Client.Test.Audit.Serialization;
public class TypedReaderTest public class TypedReaderTest
{ {
private const string HttpEventPayload = "000000e5120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374528a010a3c747970652e676f6f676c65617069732e636f6d2f696e65746d6f636b2e61756469742e64657461696c732e4854545044657461696c73456e74697479124a12096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e"; private const string HttpEventPayload =
private const string DnsEventPayload = "0000003b120b088092b8c398feffffff01180120012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050"; "000000e5120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374528a010a3c747970652e676f6f676c65617069732e636f6d2f696e65746d6f636b2e61756469742e64657461696c732e4854545044657461696c73456e74697479124a12096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e";
private const string DnsEventPayload =
"0000003b120b088092b8c398feffffff01180120012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050";
private readonly byte[] _dnsEventPayloadBytes;
private readonly byte[] _httpEventPayloadBytes; private readonly byte[] _httpEventPayloadBytes;
private readonly byte[] _dnsEventPayloadBytes;
public TypedReaderTest() public TypedReaderTest()
{ {

View file

@ -8,13 +8,13 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/>
<PackageReference Include="xunit" Version="2.4.2" /> <PackageReference Include="xunit" Version="2.5.0"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> <PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2"> <PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>