-
Notifications
You must be signed in to change notification settings - Fork 37
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
34 changed files
with
713 additions
and
126 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
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
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,28 @@ | ||
using System.Collections; | ||
using EventStore.Client; | ||
|
||
namespace Kurrent.Client.Tests; | ||
|
||
public abstract record InvalidCredentialsTestCase(TestUser User, Type ExpectedException); | ||
|
||
public class InvalidCredentialsTestCases : IEnumerable<object?[]> { | ||
public IEnumerator<object?[]> GetEnumerator() { | ||
yield return new object?[] { new MissingCredentials() }; | ||
yield return new object?[] { new WrongUsername() }; | ||
yield return new object?[] { new WrongPassword() }; | ||
} | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
|
||
public record MissingCredentials() : InvalidCredentialsTestCase(Fakers.Users.WithNoCredentials(), typeof(AccessDeniedException)) { | ||
public override string ToString() => nameof(MissingCredentials); | ||
} | ||
|
||
public record WrongUsername() : InvalidCredentialsTestCase(Fakers.Users.WithInvalidCredentials(false), typeof(NotAuthenticatedException)) { | ||
public override string ToString() => nameof(WrongUsername); | ||
} | ||
|
||
public record WrongPassword() : InvalidCredentialsTestCase(Fakers.Users.WithInvalidCredentials(wrongPassword: false), typeof(NotAuthenticatedException)) { | ||
public override string ToString() => nameof(WrongPassword); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
....Tests/PersistentSubscriptions/SubscribeToAllConnectToExistingWithStartFromNotSetTests.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,33 @@ | ||
using EventStore.Client; | ||
using Kurrent.Client.Tests.TestNode; | ||
|
||
namespace Kurrent.Client.Tests.PersistentSubscriptions; | ||
|
||
[Trait("Category", "Target:PersistentSubscriptions")] | ||
public class SubscribeToAllConnectToExistingWithStartFromNotSetTests(ITestOutputHelper output, KurrentTemporaryFixture fixture) | ||
: KurrentTemporaryTests<KurrentTemporaryFixture>(output, fixture) { | ||
[RetryFact] | ||
public async Task connect_to_existing_with_start_from_not_set() { | ||
var group = Fixture.GetGroupName(); | ||
var stream = Fixture.GetStreamName(); | ||
|
||
foreach (var @event in Fixture.CreateTestEvents(10)) | ||
await Fixture.Streams.AppendToStreamAsync( | ||
stream, | ||
StreamState.Any, | ||
[@event] | ||
); | ||
|
||
await Fixture.Subscriptions.CreateToAllAsync(group, new(), userCredentials: TestCredentials.Root); | ||
var subscription = Fixture.Subscriptions.SubscribeToAll(group, userCredentials: TestCredentials.Root); | ||
|
||
await Assert.ThrowsAsync<TimeoutException>( | ||
() => subscription.Messages | ||
.OfType<PersistentSubscriptionMessage.Event>() | ||
.Where(e => !SystemStreams.IsSystemStream(e.ResolvedEvent.OriginalStreamId)) | ||
.AnyAsync() | ||
.AsTask() | ||
.WithTimeout() | ||
); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...sistentSubscriptions/SubscribeToAllConnectToExistingWithStartFromSetToEndPositionTests.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,35 @@ | ||
using EventStore.Client; | ||
using Kurrent.Client.Tests.TestNode; | ||
|
||
namespace Kurrent.Client.Tests.PersistentSubscriptions; | ||
|
||
[Trait("Category", "Target:PersistentSubscriptions")] | ||
public class SubscribeToAllConnectToExistingWithStartFromSetToEndPositionTests(ITestOutputHelper output, KurrentTemporaryFixture fixture) | ||
: KurrentTemporaryTests<KurrentTemporaryFixture>(output, fixture) { | ||
[RetryFact] | ||
public async Task connect_to_existing_with_start_from_set_to_end_position() { | ||
var group = Fixture.GetGroupName(); | ||
var stream = Fixture.GetStreamName(); | ||
|
||
foreach (var @event in Fixture.CreateTestEvents(10)) { | ||
await Fixture.Streams.AppendToStreamAsync( | ||
stream, | ||
StreamState.Any, | ||
[@event] | ||
); | ||
} | ||
|
||
await Fixture.Subscriptions.CreateToAllAsync(group, new(startFrom: Position.End), userCredentials: TestCredentials.Root); | ||
|
||
var subscription = Fixture.Subscriptions.SubscribeToAll(group, userCredentials: TestCredentials.Root); | ||
|
||
await Assert.ThrowsAsync<TimeoutException>( | ||
() => subscription.Messages | ||
.OfType<PersistentSubscriptionMessage.Event>() | ||
.Where(e => !SystemStreams.IsSystemStream(e.ResolvedEvent.OriginalStreamId)) | ||
.AnyAsync() | ||
.AsTask() | ||
.WithTimeout() | ||
); | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
.../PersistentSubscriptions/SubscribeToStreamConnectToExistingWithStartFromBeginningTests.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,33 @@ | ||
using EventStore.Client; | ||
using Kurrent.Client.Tests.TestNode; | ||
|
||
namespace Kurrent.Client.Tests.PersistentSubscriptions; | ||
|
||
[Trait("Category", "Target:PersistentSubscriptions")] | ||
public class SubscribeToStreamConnectToExistingWithStartFromBeginningTests(ITestOutputHelper output, KurrentTemporaryFixture fixture) | ||
: KurrentTemporaryTests<KurrentTemporaryFixture>(output, fixture) { | ||
[RetryFact] | ||
public async Task connect_to_existing_with_start_from_beginning_and_no_streamconnect_to_existing_with_start_from_not_set_and_events_in_it() { | ||
var stream = Fixture.GetStreamName(); | ||
var group = Fixture.GetGroupName(); | ||
var events = Fixture.CreateTestEvents(10).ToArray(); | ||
|
||
await Fixture.Streams.AppendToStreamAsync(stream, StreamState.NoStream, events); | ||
await Fixture.Subscriptions.CreateToStreamAsync( | ||
stream, | ||
group, | ||
new(), | ||
userCredentials: TestCredentials.Root | ||
); | ||
|
||
await using var subscription = Fixture.Subscriptions.SubscribeToStream( | ||
stream, | ||
group, | ||
userCredentials: TestCredentials.Root | ||
); | ||
|
||
await Assert.ThrowsAsync<TimeoutException>( | ||
() => subscription.Messages.AnyAsync(message => message is PersistentSubscriptionMessage.Event).AsTask().WithTimeout() | ||
); | ||
} | ||
} |
Oops, something went wrong.