-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
218 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: Test EE | ||
|
||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
tags: | ||
- v* | ||
|
||
env: | ||
ES_VERSION: 24.2.0-jammy | ||
ES_DOCKER_REGISTRY: docker.eventstore.com/eventstore-ee/eventstoredb-commercial | ||
|
||
jobs: | ||
test: | ||
timeout-minutes: 20 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
framework: [ net6.0, net7.0, net8.0 ] | ||
os: [ ubuntu-latest ] | ||
build: [ Streams, PersistentSubscriptions, Operations, UserManagement, ProjectionManagement ] | ||
test: [ Plugins ] | ||
configuration: [ release ] | ||
runs-on: ${{ matrix.os }} | ||
name: EventStore.Client.${{ matrix.test }}/${{ matrix.os }}/${{ matrix.framework }}/${{ env.ES_VERSION }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- shell: bash | ||
run: | | ||
git fetch --prune --unshallow | ||
- name: Login to Cloudsmith | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: docker.eventstore.com | ||
username: ${{ secrets.CLOUDSMITH_CICD_USER }} | ||
password: ${{ secrets.CLOUDSMITH_CICD_TOKEN }} | ||
- name: Pull EventStore Image | ||
shell: bash | ||
run: | | ||
docker pull ${{ env.ES_DOCKER_REGISTRY }}:${{ env.ES_VERSION }} | ||
- name: Install dotnet SDKs | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: | | ||
6.0.x | ||
7.0.x | ||
8.0.x | ||
- name: Compile | ||
shell: bash | ||
run: | | ||
dotnet build --configuration ${{ matrix.configuration }} --framework ${{ matrix.framework }} src/EventStore.Client.${{ matrix.build }} | ||
- name: Run Tests | ||
shell: bash | ||
env: | ||
ES_DOCKER_TAG: ${{ env.ES_VERSION }} | ||
ES_DOCKER_REGISTRY: ${{ env.ES_DOCKER_REGISTRY }} | ||
run: | | ||
sudo ./gencert.sh | ||
dotnet test --configuration ${{ matrix.configuration }} --blame \ | ||
--logger:"GitHubActions;report-warnings=false" --logger:"console;verbosity=normal" \ | ||
--framework ${{ matrix.framework }} \ | ||
test/EventStore.Client.${{ matrix.test }}.Tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
test/EventStore.Client.Plugins.Tests/EventStore.Client.Plugins.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<ItemGroup> | ||
<ProjectReference Include="..\EventStore.Client.Tests.Common\EventStore.Client.Tests.Common.csproj"/> | ||
</ItemGroup> | ||
</Project> |
88 changes: 88 additions & 0 deletions
88
test/EventStore.Client.Plugins.Tests/client_certificate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
namespace EventStore.Client.Plugins.Tests; | ||
|
||
[Trait("Category", "Target:Plugins")] | ||
[Trait("Category", "Type:UserCertificate")] | ||
public class client_certificate(ITestOutputHelper output, EventStoreFixture fixture) | ||
: EventStoreTests<EventStoreFixture>(output, fixture) { | ||
public static IEnumerable<object[]> TlsCertPaths => | ||
new List<object[]> { | ||
new object[] { Path.Combine("certs", "ca", "ca.crt") }, | ||
new object[] { Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "certs", "ca", "ca.crt") }, | ||
}; | ||
|
||
public static IEnumerable<object[]> AdminClientCertPaths => | ||
new List<object[]> { | ||
new object[] { | ||
Path.Combine(Environment.CurrentDirectory, "certs", "user-admin", "user-admin.crt"), | ||
Path.Combine(Environment.CurrentDirectory, "certs", "user-admin", "user-admin.key") | ||
}, | ||
new object[] { | ||
Path.Combine("certs", "user-admin", "user-admin.crt"), | ||
Path.Combine("certs", "user-admin", "user-admin.key") | ||
} | ||
}; | ||
|
||
public static IEnumerable<object[]> BadClientCertPaths => | ||
new List<object[]> { | ||
new object[] { | ||
Path.Combine("certs", "user-invalid", "user-invalid.crt"), | ||
Path.Combine("certs", "user-invalid", "user-invalid.key") | ||
}, | ||
new object[] { | ||
Path.Combine(Environment.CurrentDirectory, "certs", "user-invalid", "user-invalid.crt"), | ||
Path.Combine(Environment.CurrentDirectory, "certs", "user-invalid", "user-invalid.key") | ||
} | ||
}; | ||
|
||
[Theory] | ||
[MemberData(nameof(TlsCertPaths))] | ||
private async Task append_with_different_tls_cert_path(string certificateFilePath) { | ||
await AppendWithCertificate($"esdb://admin:changeit@localhost:2113/?tls=true&tlsVerifyCert=true&tlsCAFile={certificateFilePath}"); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(AdminClientCertPaths))] | ||
private async Task append_with_admin_client_certificate(string certPath, string certKeyPath) { | ||
await AppendWithCertificate($"esdb://localhost:2113/?tls=true&tlsVerifyCert=true&certPath={certPath}&certKeyPath={certKeyPath}"); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(BadClientCertPaths))] | ||
private async Task append_with_bad_client_certificate(string certPath, string certKeyPath) { | ||
await AssertAppendFailsWithCertificate($"esdb://localhost:2113/?tls=true&tlsVerifyCert=true&certPath={certPath}&certKeyPath={certKeyPath}", typeof(NotAuthenticatedException)); | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(BadClientCertPaths))] | ||
private async Task user_credentials_takes_precedence_over_client_certificates(string certPath, string certKeyPath) { | ||
await AppendWithCertificate($"esdb://admin:changeit@localhost:2113/?tls=true&tlsVerifyCert=true&certPath={certPath}&certKeyPath={certKeyPath}"); | ||
} | ||
|
||
private async Task AppendWithCertificate(string connectionString) { | ||
var settings = EventStoreClientSettings.Create(connectionString); | ||
var client = new EventStoreClient(settings); | ||
|
||
var appendResult = await client.AppendToStreamAsync( | ||
Fixture.GetStreamName(), | ||
StreamState.Any, | ||
Fixture.CreateTestEvents(1) | ||
); | ||
|
||
appendResult.ShouldNotBeNull(); | ||
|
||
await client.DisposeAsync(); | ||
} | ||
|
||
private async Task AssertAppendFailsWithCertificate(string connectionString, Type expectedExceptionType) { | ||
var settings = EventStoreClientSettings.Create(connectionString); | ||
var client = new EventStoreClient(settings); | ||
|
||
await client.AppendToStreamAsync( | ||
Fixture.GetStreamName(), | ||
StreamState.Any, | ||
Fixture.CreateTestEvents(1) | ||
).ShouldThrowAsync(expectedExceptionType); | ||
|
||
await client.DisposeAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters