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
csharp_style_namespace_declarations = file_scoped: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]
indent_size = 2

View file

@ -34,10 +34,10 @@ test:
done;
after_script:
- docker stop inetmock
variables:
variables:
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/docker
INETMOCK_SOCKET: http://docker:6767
script:
script:
- dotnet tool restore
- dotnet nuke Test
@ -45,7 +45,7 @@ protobuf-lint:
stage: test
image:
name: docker.io/bufbuild/buf:latest
entrypoint: [""]
entrypoint: [ "" ]
script:
- cd api/proto/
- buf ls-files
@ -56,6 +56,6 @@ nuget-publish:
only:
refs:
- tags
script:
script:
- dotnet tool restore
- dotnet nuke NuGetPush

View file

@ -2,7 +2,6 @@ using NuGet.Versioning;
using Nuke.Common;
using Nuke.Common.CI;
using Nuke.Common.CI.GitLab;
using Nuke.Common.Execution;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
@ -13,20 +12,19 @@ using Nuke.Common.Utilities.Collections;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
[CheckBuildProjectConfigurations]
[ShutdownDotNetAfterServerBuild]
class Build : NukeBuild
{
private const string NuGetSourceName = "GitLab";
public static int Main() => Execute<Build>(x => x.Test);
const string NuGetSourceName = "GitLab";
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
[Solution] readonly Solution? Solution;
[GitRepository] readonly GitRepository? GitRepository;
[GitVersion(Framework = "net6.0", NoFetch = true)] readonly GitVersion? GitVersion;
[Solution] readonly Solution? Solution;
GitLab? CI => GitLab.Instance;
@ -90,7 +88,8 @@ class Build : NukeBuild
.SetProject(csproj)
.SetConfiguration(Configuration)
.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()
.EnableIncludeSymbols()
.EnableNoRestore()
@ -117,4 +116,6 @@ class Build : NukeBuild
.SetSource(NuGetSourceName)
.SetTargetPath(nupkg)
.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 Release = new() { Value = nameof(Release) };
public static implicit operator string(Configuration configuration)
{
return configuration.Value;
}
public static implicit operator string(Configuration configuration) => configuration.Value;
}

View file

@ -1,20 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nuke.Common" Version="6.2.1" />
<PackageDownload Include="GitVersion.Tool" Version="[5.8.0]" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Nuke.Common" Version="7.0.5"/>
<PackageDownload Include="GitVersion.Tool" Version="[5.8.0]"/>
</ItemGroup>
</Project>

View file

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

View file

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

View file

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

View file

@ -9,9 +9,9 @@ namespace INetMock.Client.Audit.Serialization;
public sealed class ProtoReader : IProtoEventReader
{
private readonly bool _keepStreamOpen;
private readonly MemoryPool<byte> _memoryPool;
private readonly Stream _sourceStream;
private readonly bool _keepStreamOpen;
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()
{
private readonly IProtoEventReader _reader;
private readonly DropMode _dropMode;
private readonly IProtoEventReader _reader;
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);
}
public void Dispose() => _reader.Dispose();
public void Dispose()
{
_reader.Dispose();
}
public ValueTask DisposeAsync() => _reader.DisposeAsync();
public ValueTask DisposeAsync()
{
return _reader.DisposeAsync();
}
}

View file

@ -5,20 +5,20 @@
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<Using Include="Inetmock.Audit.V1" />
<Using Include="Inetmock.Rpc.V1" />
<Using Include="Inetmock.Audit.V1"/>
<Using Include="Inetmock.Rpc.V1"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.6" />
<PackageReference Include="Grpc.Net.Client" Version="2.49.0" />
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.49.0" />
<PackageReference Include="Grpc.Tools" Version="2.49.0">
<PackageReference Include="Google.Protobuf" Version="3.24.3"/>
<PackageReference Include="Grpc.Net.Client" Version="2.57.0"/>
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.57.0"/>
<PackageReference Include="Grpc.Tools" Version="2.58.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Protobuf Include="proto/audit/v1/*.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" />
<Protobuf Include="proto/rpc/v1/*.proto" GrpcServices="Client" AdditionalImportDirs="./proto/" />
<Protobuf Include="proto/audit/v1/*.proto" GrpcServices="Client" AdditionalImportDirs="./proto/"/>
<Protobuf Include="proto/rpc/v1/*.proto" GrpcServices="Client" AdditionalImportDirs="./proto/"/>
</ItemGroup>
</Project>

View file

@ -7,7 +7,7 @@ using System.Threading.Tasks;
using Google.Protobuf.WellKnownTypes;
using Grpc.Core;
using Grpc.Net.Client;
using ChannelFactory = INetMock.Client.Grpc.ChannelFactory;
using INetMock.Client.Grpc;
namespace INetMock.Client.PCAP.Client;
@ -32,7 +32,13 @@ public class PcapApiClient : IPcapApiClient
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
.Select(d => new RecordingDevice(
d.Name,
@ -46,7 +52,13 @@ public class PcapApiClient : IPcapApiClient
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
.Select(consumerKey => new Subscription(consumerKey))
.ToList();

View file

@ -20,6 +20,7 @@ public class TypedReaderTest
Assert.NotNull(ev);
count++;
}
Assert.True(count > 0);
}
@ -27,7 +28,8 @@ public class TypedReaderTest
public async Task Test_ReadAllAsync_DropEntity_AuditFile_HTTPEvents()
{
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;
await foreach (var ev in httpReader.ReadAllAsync())
@ -36,6 +38,7 @@ public class TypedReaderTest
Assert.NotNull(ev.Details);
count++;
}
Assert.True(count > 0);
}
@ -51,6 +54,7 @@ public class TypedReaderTest
Assert.NotNull(ev);
count++;
}
Assert.True(count > 0);
}
@ -58,7 +62,8 @@ public class TypedReaderTest
public async Task Test_ReadAllAsync_DropEntity_AuditFile_DNSEvents()
{
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;
await foreach (var ev in httpReader.ReadAllAsync())
@ -66,6 +71,7 @@ public class TypedReaderTest
Assert.NotNull(ev);
count++;
}
Assert.True(count > 0);
}
}

View file

@ -11,27 +11,27 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="Testcontainers" Version="2.1.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2"/>
<PackageReference Include="Testcontainers" Version="3.5.0"/>
<PackageReference Include="xunit" Version="2.5.0"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</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>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\INetMock.Client\INetMock.Client.csproj" />
<ProjectReference Include="..\..\src\INetMock.Client\INetMock.Client.csproj"/>
</ItemGroup>
<ItemGroup>
<None Update="testdata\*.ima">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="testdata\*.ima">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View file

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

View file

@ -8,8 +8,8 @@ namespace INetMock.Client.IntegrationTest.PCAP.Client;
public class PcapApiClientTests : IClassFixture<INetMockFixture>
{
private readonly ITestOutputHelper _outputHelper;
private readonly IPcapApiClient _apiClient;
private readonly ITestOutputHelper _outputHelper;
public PcapApiClientTests(ITestOutputHelper testOutputHelper, INetMockFixture inetMockFixture)
{
@ -48,7 +48,7 @@ public class PcapApiClientTests : IClassFixture<INetMockFixture>
}
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();
Assert.Contains(subscriptions, subscription =>

View file

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

View file

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

View file

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