Compare commits
1 commit
main
...
renovate/g
Author | SHA1 | Date | |
---|---|---|---|
a49b5b1290 |
30 changed files with 186 additions and 308 deletions
|
@ -1,53 +0,0 @@
|
|||
version: v0
|
||||
runs:
|
||||
- name: Lint
|
||||
tasks:
|
||||
- name: Checkout code
|
||||
runtime:
|
||||
containers:
|
||||
- image: docker.io/alpine/git
|
||||
steps:
|
||||
- clone:
|
||||
- save_to_workspace:
|
||||
contents:
|
||||
- source_dir: .
|
||||
dest_dir: .
|
||||
paths:
|
||||
- '**'
|
||||
|
||||
- name: Run .NET tests
|
||||
runtime:
|
||||
containers:
|
||||
- image: mcr.microsoft.com/dotnet/sdk:6.0
|
||||
environment:
|
||||
DOCKER_HOST: tcp://127.0.0.1:2375
|
||||
INETMOCK_SOCKET: http://127.0.0.1:6767
|
||||
TESTCONTAINERS_RYUK_DISABLED: "true"
|
||||
- image: code.icb4dc0.de/prskr/ci-images/dind:latest
|
||||
privileged: true
|
||||
steps:
|
||||
- restore_workspace:
|
||||
dest_dir: .
|
||||
- run:
|
||||
name: .NET tests
|
||||
command: |-
|
||||
dotnet tool restore
|
||||
dotnet nuke Test
|
||||
depends:
|
||||
- Checkout code
|
||||
|
||||
- name: Lint protobuf
|
||||
runtime:
|
||||
containers:
|
||||
- image: docker.io/bufbuild/buf:latest
|
||||
steps:
|
||||
- restore_workspace:
|
||||
dest_dir: .
|
||||
- run:
|
||||
name: buf lint
|
||||
command: |-
|
||||
buf ls-files
|
||||
buf lint
|
||||
working_dir: ~/project/api/proto
|
||||
depends:
|
||||
- Checkout code
|
|
@ -3,34 +3,16 @@
|
|||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-grpc": {
|
||||
"version": "2.57.0",
|
||||
"version": "2.46.0",
|
||||
"commands": [
|
||||
"dotnet-grpc"
|
||||
]
|
||||
},
|
||||
"nuke.globaltool": {
|
||||
"version": "7.0.5",
|
||||
"version": "6.0.3",
|
||||
"commands": [
|
||||
"nuke"
|
||||
]
|
||||
},
|
||||
"gitversion.tool": {
|
||||
"version": "5.12.0",
|
||||
"commands": [
|
||||
"dotnet-gitversion"
|
||||
]
|
||||
},
|
||||
"husky": {
|
||||
"version": "0.6.1",
|
||||
"commands": [
|
||||
"husky"
|
||||
]
|
||||
},
|
||||
"jetbrains.resharper.globaltools": {
|
||||
"version": "2023.2.1",
|
||||
"commands": [
|
||||
"jb"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
24
.drone.yml
24
.drone.yml
|
@ -1,24 +0,0 @@
|
|||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
name: default
|
||||
|
||||
platform:
|
||||
os: linux
|
||||
arch: arm64
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
event:
|
||||
- push
|
||||
- pull_request
|
||||
- tag
|
||||
|
||||
steps:
|
||||
- name: Test
|
||||
image: mcr.microsoft.com/dotnet/sdk:6.0
|
||||
commands:
|
||||
- dotnet tool restore
|
||||
- dotnet restore
|
||||
- dotnet nuke test
|
|
@ -6,7 +6,6 @@ end_of_line = lf
|
|||
charset = utf-8
|
||||
insert_final_newline = true
|
||||
max_line_length = 120
|
||||
indent_size = 4
|
||||
|
||||
[*.xml]
|
||||
indent_size = 4
|
||||
|
@ -15,16 +14,6 @@ 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 = omit_if_default: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
|
||||
|
|
61
.gitlab-ci.yml
Normal file
61
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,61 @@
|
|||
image: mcr.microsoft.com/dotnet/sdk:6.0
|
||||
|
||||
stages:
|
||||
- test
|
||||
- release
|
||||
|
||||
variables:
|
||||
DOCKER_TLS_CERTDIR: "/certs"
|
||||
DOCKER_CERT_PATH: "/certs/client"
|
||||
DOCKER_TLS_VERIFY: 1
|
||||
DOCKER_HOST: 'tcp://docker:2376'
|
||||
|
||||
test:
|
||||
stage: test
|
||||
services:
|
||||
- docker:dind
|
||||
before_script:
|
||||
- |
|
||||
curl https://download.docker.com/linux/static/stable/x86_64/docker-20.10.14.tgz | tar -xzv -C /usr/local/
|
||||
|
||||
docker run --rm -d \
|
||||
--cap-add CAP_NET_RAW \
|
||||
--cap-add CAP_NET_ADMIN \
|
||||
--cap-add CAP_NET_BIND_SERVICE \
|
||||
-u root \
|
||||
-p 6767:6767 \
|
||||
-e INETMOCK_API_LISTEN=tcp://0.0.0.0:6767 \
|
||||
--name inetmock \
|
||||
registry.gitlab.com/inetmock/inetmock:latest
|
||||
|
||||
for i in `seq 1 10`
|
||||
do
|
||||
docker exec -i inetmock /usr/lib/inetmock/bin/imctl health container 2>&1 > /dev/null || sleep 1;
|
||||
done;
|
||||
after_script:
|
||||
- docker stop inetmock
|
||||
variables:
|
||||
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/docker
|
||||
INETMOCK_SOCKET: http://docker:6767
|
||||
script:
|
||||
- dotnet tool restore
|
||||
- dotnet nuke Test
|
||||
|
||||
protobuf-lint:
|
||||
stage: test
|
||||
image:
|
||||
name: docker.io/bufbuild/buf:latest
|
||||
entrypoint: [""]
|
||||
script:
|
||||
- cd api/proto/
|
||||
- buf ls-files
|
||||
- buf lint
|
||||
|
||||
nuget-publish:
|
||||
stage: release
|
||||
only:
|
||||
refs:
|
||||
- tags
|
||||
script:
|
||||
- dotnet tool restore
|
||||
- dotnet nuke NuGetPush
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
dotnet husky run --group pre-commit
|
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
"tasks": [
|
||||
{
|
||||
"name": "dotnet-format",
|
||||
"group": "pre-commit",
|
||||
"command": "dotnet",
|
||||
"args": [
|
||||
"dotnet-format",
|
||||
"--include",
|
||||
"${staged}"
|
||||
],
|
||||
"include": [
|
||||
"**/*.cs",
|
||||
"**/*.vb"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Run JB Clean Up Code",
|
||||
"group": "pre-commit",
|
||||
"command": "dotnet",
|
||||
"pathMode": "relative",
|
||||
"args": [
|
||||
"jb",
|
||||
"cleanupcode",
|
||||
"INetMock.sln",
|
||||
"--telemetry-optout"
|
||||
],
|
||||
"include": [
|
||||
"**/*.cs",
|
||||
"**/*.vb"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"$ref": "#/definitions/build",
|
||||
"title": "Build Schema",
|
||||
"$ref": "#/definitions/build",
|
||||
"definitions": {
|
||||
"build": {
|
||||
"type": "object",
|
||||
|
@ -29,7 +29,6 @@
|
|||
"AppVeyor",
|
||||
"AzurePipelines",
|
||||
"Bamboo",
|
||||
"Bitbucket",
|
||||
"Bitrise",
|
||||
"GitHubActions",
|
||||
"GitLab",
|
||||
|
@ -39,8 +38,8 @@
|
|||
"TeamCity",
|
||||
"Terminal",
|
||||
"TravisCI",
|
||||
"VSCode",
|
||||
"VisualStudio"
|
||||
"VisualStudio",
|
||||
"VSCode"
|
||||
]
|
||||
},
|
||||
"NoLogo": {
|
||||
|
@ -117,4 +116,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
13
.pre-commit-config.yaml
Normal file
13
.pre-commit-config.yaml
Normal file
|
@ -0,0 +1,13 @@
|
|||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/dotnet/format
|
||||
rev: "v5.1.225507" # Specify a tag or sha here, or run "pre-commit autoupdate"
|
||||
hooks:
|
||||
- id: dotnet-format
|
||||
args:
|
||||
- ""
|
||||
- --folder
|
||||
- --check
|
||||
- --verbosity=detailed
|
||||
- --include
|
|
@ -7,6 +7,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SolutionItems", "SolutionIt
|
|||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
.gitignore = .gitignore
|
||||
.gitlab-ci.yml = .gitlab-ci.yml
|
||||
.pre-commit-config.yaml = .pre-commit-config.yaml
|
||||
README.md = README.md
|
||||
global.json = global.json
|
||||
EndProjectSection
|
||||
|
|
|
@ -2,6 +2,7 @@ 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;
|
||||
|
@ -12,18 +13,19 @@ using Nuke.Common.Utilities.Collections;
|
|||
using static Nuke.Common.IO.FileSystemTasks;
|
||||
using static Nuke.Common.Tools.DotNet.DotNetTasks;
|
||||
|
||||
[CheckBuildProjectConfigurations]
|
||||
[ShutdownDotNetAfterServerBuild]
|
||||
class Build : NukeBuild
|
||||
{
|
||||
const string NuGetSourceName = "GitLab";
|
||||
private const string NuGetSourceName = "GitLab";
|
||||
public static int Main() => Execute<Build>(x => x.Test);
|
||||
|
||||
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
|
||||
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
|
||||
|
||||
[GitRepository] readonly GitRepository? GitRepository;
|
||||
[GitVersion(Framework = "net6.0", NoFetch = true)] readonly GitVersion? GitVersion;
|
||||
|
||||
[Solution] readonly Solution? Solution;
|
||||
[GitRepository] readonly GitRepository? GitRepository;
|
||||
[GitVersion(NoFetch = true, Framework = "net6.0")] readonly GitVersion? GitVersion;
|
||||
|
||||
|
||||
GitLab? CI => GitLab.Instance;
|
||||
|
@ -88,8 +90,7 @@ class Build : NukeBuild
|
|||
.SetProject(csproj)
|
||||
.SetConfiguration(Configuration)
|
||||
.SetOutputDirectory(ArtifactsDirectory)
|
||||
.SetVersion(GitVersion?.NuGetVersionV2 ??
|
||||
SemanticVersion.Parse(CI?.CommitTag?.TrimStart('v') ?? "0.0.1").ToNormalizedString())
|
||||
.SetVersion(GitVersion?.FullSemVer ?? SemanticVersion.Parse(CI?.CommitTag?.TrimStart('v') ?? "0.0.1").ToNormalizedString())
|
||||
.EnableIncludeSource()
|
||||
.EnableIncludeSymbols()
|
||||
.EnableNoRestore()
|
||||
|
@ -116,6 +117,4 @@ class Build : NukeBuild
|
|||
.SetSource(NuGetSourceName)
|
||||
.SetTargetPath(nupkg)
|
||||
.EnableProcessLogOutput())));
|
||||
|
||||
public static int Main() => Execute<Build>(x => x.Test);
|
||||
}
|
||||
|
|
|
@ -7,5 +7,8 @@ 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) => configuration.Value;
|
||||
public static implicit operator string(Configuration configuration)
|
||||
{
|
||||
return configuration.Value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +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="7.0.5"/>
|
||||
<PackageDownload Include="GitVersion.Tool" Version="[5.8.0]"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="ci\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Nuke.Common" Version="6.0.3" />
|
||||
<PackageDownload Include="GitVersion.Tool" Version="[5.8.0]" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -48,9 +48,9 @@ public class AuditApiClient : IAuditApiClient
|
|||
public async Task<bool> RemoveFileSinkAsync(string targetPath, CancellationToken token = default)
|
||||
{
|
||||
var resp = await _auditClient.RemoveFileSinkAsync(new RemoveFileSinkRequest
|
||||
{
|
||||
TargetPath = targetPath
|
||||
},
|
||||
{
|
||||
TargetPath = targetPath
|
||||
},
|
||||
Metadata.Empty,
|
||||
null,
|
||||
token
|
||||
|
|
|
@ -71,6 +71,7 @@ public record Event<T> : EventBase where T : EventDetails, new()
|
|||
{
|
||||
public Event()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Event(EventEntity entity) : base(entity)
|
||||
|
|
|
@ -10,6 +10,7 @@ public interface IEventReader : IDisposable, IAsyncDisposable
|
|||
IAsyncEnumerable<Event> ReadAllAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="token"></param>
|
||||
/// <returns>
|
||||
|
@ -24,6 +25,7 @@ public interface IEventReader<T> : IDisposable, IAsyncDisposable where T : Event
|
|||
IAsyncEnumerable<Event<T>> ReadAllAsync(CancellationToken token = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="token"></param>
|
||||
/// <returns>
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Inetmock.Audit.V1;
|
||||
|
||||
namespace INetMock.Client.Audit;
|
||||
|
||||
|
|
|
@ -37,5 +37,8 @@ public sealed class GenericReader : IEventReader
|
|||
|
||||
public ValueTask DisposeAsync() => _reader.DisposeAsync();
|
||||
|
||||
public void Dispose() => _reader.Dispose();
|
||||
public void Dispose()
|
||||
{
|
||||
_reader.Dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -27,8 +27,8 @@ public enum DropMode
|
|||
|
||||
public sealed class TypedReader<T> : IEventReader<T> where T : EventDetails, new()
|
||||
{
|
||||
private readonly DropMode _dropMode;
|
||||
private readonly IProtoEventReader _reader;
|
||||
private readonly DropMode _dropMode;
|
||||
|
||||
public TypedReader(IProtoEventReader reader, DropMode dropMode = DropMode.DropDetails)
|
||||
{
|
||||
|
|
|
@ -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.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">
|
||||
<PackageReference Include="Google.Protobuf" Version="3.21.2" />
|
||||
<PackageReference Include="Grpc.Net.Client" Version="2.46.0" />
|
||||
<PackageReference Include="Grpc.Net.ClientFactory" Version="2.46.0" />
|
||||
<PackageReference Include="Grpc.Tools" Version="2.46.3">
|
||||
<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>
|
||||
|
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
|||
using Google.Protobuf.WellKnownTypes;
|
||||
using Grpc.Core;
|
||||
using Grpc.Net.Client;
|
||||
using INetMock.Client.Grpc;
|
||||
using ChannelFactory = INetMock.Client.Grpc.ChannelFactory;
|
||||
|
||||
namespace INetMock.Client.PCAP.Client;
|
||||
|
||||
|
@ -32,13 +32,7 @@ public class PcapApiClient : IPcapApiClient
|
|||
|
||||
public async Task<IReadOnlyList<RecordingDevice>> ListAvailableDevicesAsync(CancellationToken token = default)
|
||||
{
|
||||
var devices = await _pcapServiceClient.ListAvailableDevicesAsync(
|
||||
new ListAvailableDevicesRequest(),
|
||||
Metadata.Empty,
|
||||
null,
|
||||
token
|
||||
);
|
||||
|
||||
var devices = await _pcapServiceClient.ListAvailableDevicesAsync(new(), Metadata.Empty, null, token);
|
||||
return devices.AvailableDevices
|
||||
.Select(d => new RecordingDevice(
|
||||
d.Name,
|
||||
|
@ -52,13 +46,7 @@ public class PcapApiClient : IPcapApiClient
|
|||
|
||||
public async Task<IReadOnlyList<Subscription>> ListActiveRecordingsAsync(CancellationToken token = default)
|
||||
{
|
||||
var recordings = await _pcapServiceClient.ListActiveRecordingsAsync(
|
||||
new ListActiveRecordingsRequest(),
|
||||
Metadata.Empty,
|
||||
null,
|
||||
token
|
||||
);
|
||||
|
||||
var recordings = await _pcapServiceClient.ListActiveRecordingsAsync(new(), Metadata.Empty, null, token);
|
||||
return recordings.Subscriptions
|
||||
.Select(consumerKey => new Subscription(consumerKey))
|
||||
.ToList();
|
||||
|
|
|
@ -20,7 +20,6 @@ public class TypedReaderTest
|
|||
Assert.NotNull(ev);
|
||||
count++;
|
||||
}
|
||||
|
||||
Assert.True(count > 0);
|
||||
}
|
||||
|
||||
|
@ -28,8 +27,7 @@ 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())
|
||||
|
@ -38,7 +36,6 @@ public class TypedReaderTest
|
|||
Assert.NotNull(ev.Details);
|
||||
count++;
|
||||
}
|
||||
|
||||
Assert.True(count > 0);
|
||||
}
|
||||
|
||||
|
@ -54,7 +51,6 @@ public class TypedReaderTest
|
|||
Assert.NotNull(ev);
|
||||
count++;
|
||||
}
|
||||
|
||||
Assert.True(count > 0);
|
||||
}
|
||||
|
||||
|
@ -62,8 +58,7 @@ 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())
|
||||
|
@ -71,7 +66,6 @@ public class TypedReaderTest
|
|||
Assert.NotNull(ev);
|
||||
count++;
|
||||
}
|
||||
|
||||
Assert.True(count > 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,27 +11,26 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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">
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0">
|
||||
<PackageReference Include="coverlet.collector" Version="3.1.2">
|
||||
<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>
|
||||
|
|
|
@ -1,52 +1,19 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DotNet.Testcontainers.Builders;
|
||||
using DotNet.Testcontainers.Containers;
|
||||
using Xunit;
|
||||
|
||||
namespace INetMock.Client.IntegrationTest;
|
||||
|
||||
public class INetMockFixture : IAsyncLifetime
|
||||
public class INetMockFixture
|
||||
{
|
||||
private const string DefaultINetMockSocketPath = "unix:///var/run/inetmock/inetmock.sock";
|
||||
private readonly IContainer _inetmockContainer;
|
||||
|
||||
private readonly Stream _memStream = new MemoryStream();
|
||||
|
||||
|
||||
public INetMockFixture()
|
||||
{
|
||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
||||
|
||||
_inetmockContainer = new ContainerBuilder()
|
||||
.WithPrivileged(true)
|
||||
.WithExposedPort(6767)
|
||||
.WithPortBinding(6767, true)
|
||||
.WithCreateParameterModifier(parameters => { parameters.User = "root"; })
|
||||
.WithEnvironment("INETMOCK_API_LISTEN", "tcp://0.0.0.0:6767")
|
||||
.WithImage("registry.gitlab.com/inetmock/inetmock:latest")
|
||||
.WithName("inetmock")
|
||||
.WithWaitStrategy(Wait.ForUnixContainer().UntilOperationIsSucceeded(() =>
|
||||
{
|
||||
Thread.Sleep(5000);
|
||||
return true;
|
||||
}, 1))
|
||||
.Build();
|
||||
}
|
||||
|
||||
public string INetMockSocketPath { get; private set; } = DefaultINetMockSocketPath;
|
||||
|
||||
public async Task InitializeAsync()
|
||||
{
|
||||
await using (_memStream)
|
||||
INetMockSocketPath = Environment.GetEnvironmentVariable("INETMOCK_SOCKET") ?? DefaultINetMockSocketPath;
|
||||
if (INetMockSocketPath.StartsWith("http:"))
|
||||
{
|
||||
await _inetmockContainer.StartAsync();
|
||||
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
|
||||
}
|
||||
|
||||
INetMockSocketPath = $"http://{_inetmockContainer.Hostname}:{_inetmockContainer.GetMappedPublicPort(6767)}";
|
||||
}
|
||||
|
||||
public async Task DisposeAsync() => await _inetmockContainer.StopAsync();
|
||||
public string INetMockSocketPath { get; }
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ namespace INetMock.Client.IntegrationTest.PCAP.Client;
|
|||
|
||||
public class PcapApiClientTests : IClassFixture<INetMockFixture>
|
||||
{
|
||||
private readonly IPcapApiClient _apiClient;
|
||||
private readonly ITestOutputHelper _outputHelper;
|
||||
private readonly IPcapApiClient _apiClient;
|
||||
|
||||
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 RecordingRequest(recordingDevice.Name, targetPath));
|
||||
await _apiClient.StartPcapFileRecordingAsync(new(recordingDevice.Name, targetPath));
|
||||
|
||||
var subscriptions = await _apiClient.ListActiveRecordingsAsync();
|
||||
Assert.Contains(subscriptions, subscription =>
|
||||
|
|
|
@ -8,15 +8,11 @@ namespace INetMock.Client.Test.Audit.Serialization;
|
|||
|
||||
public class GenericReaderTest
|
||||
{
|
||||
private const string HttpEventPayload =
|
||||
"000000a7120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374a2014c080112096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e";
|
||||
|
||||
private const string DnsEventPayload =
|
||||
"0000004e120b088092b8c398feffffff01180220012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050aa0110120e0801120a6769746c61622e636f6d";
|
||||
|
||||
private readonly byte[] _dnsEventPayloadBytes;
|
||||
private const string HttpEventPayload = "000000a7120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374a2014c080112096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e";
|
||||
private const string DnsEventPayload = "0000004e120b088092b8c398feffffff01180220012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050aa0110120e0801120a6769746c61622e636f6d";
|
||||
|
||||
private readonly byte[] _httpEventPayloadBytes;
|
||||
private readonly byte[] _dnsEventPayloadBytes;
|
||||
|
||||
public GenericReaderTest()
|
||||
{
|
||||
|
|
|
@ -8,15 +8,11 @@ namespace INetMock.Client.Test.Audit.Serialization;
|
|||
|
||||
public class TypedReaderTest
|
||||
{
|
||||
private const string HttpEventPayload =
|
||||
"000000e5120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374528a010a3c747970652e676f6f676c65617069732e636f6d2f696e65746d6f636b2e61756469742e64657461696c732e4854545044657461696c73456e74697479124a12096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e";
|
||||
|
||||
private const string DnsEventPayload =
|
||||
"0000003b120b088092b8c398feffffff01180120012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050";
|
||||
|
||||
private readonly byte[] _dnsEventPayloadBytes;
|
||||
private const string HttpEventPayload = "000000e5120b088092b8c398feffffff01180120022a047f00000132047f00000138d8fc0140504a3308041224544c535f45434448455f45434453415f574954485f4145535f3235365f4342435f5348411a096c6f63616c686f7374528a010a3c747970652e676f6f676c65617069732e636f6d2f696e65746d6f636b2e61756469742e64657461696c732e4854545044657461696c73456e74697479124a12096c6f63616c686f73741a15687474703a2f2f6c6f63616c686f73742f6173646622084854545020312e312a1c0a0641636365707412120a106170706c69636174696f6e2f6a736f6e";
|
||||
private const string DnsEventPayload = "0000003b120b088092b8c398feffffff01180120012a100000000000000000000000000000000132100000000000000000000000000000000138d8fc014050";
|
||||
|
||||
private readonly byte[] _httpEventPayloadBytes;
|
||||
private readonly byte[] _dnsEventPayloadBytes;
|
||||
|
||||
public TypedReaderTest()
|
||||
{
|
||||
|
|
|
@ -5,9 +5,11 @@ namespace INetMock.Client.Test.Hex;
|
|||
|
||||
public static class Converter
|
||||
{
|
||||
public static byte[] HexToByteArray(this string hex) =>
|
||||
Enumerable.Range(0, hex.Length)
|
||||
public static byte[] HexToByteArray(this string hex)
|
||||
{
|
||||
return Enumerable.Range(0, hex.Length)
|
||||
.Where(x => x % 2 == 0)
|
||||
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<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="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" />
|
||||
</ItemGroup>
|
||||
<Target Name="Husky" BeforeTargets="Restore;CollectPackageReferences" Condition="'$(HUSKY)' != 0">
|
||||
<Exec Command="dotnet tool restore" StandardOutputImportance="Low" StandardErrorImportance="High" />
|
||||
<Exec Command="dotnet husky install" StandardOutputImportance="Low" StandardErrorImportance="High" WorkingDirectory="../.." />
|
||||
</Target>
|
||||
</Project>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||
<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>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\INetMock.Client\INetMock.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
Loading…
Reference in a new issue