-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace EventStore.Client { | ||
public class AuthenticationTests : IClassFixture<AuthenticationTests.Fixture> { | ||
private readonly Fixture _fixture; | ||
|
||
public AuthenticationTests(Fixture fixture) { | ||
_fixture = fixture; | ||
} | ||
|
||
public static IEnumerable<object?[]> AuthenticationCases() { | ||
var fails = false; | ||
var succeeds = true; | ||
|
||
// no user credentials | ||
yield return new object?[] {1, TestCredentials.Root, null, succeeds}; | ||
yield return new object?[] {2, TestCredentials.TestUser1, null, fails}; | ||
yield return new object?[] {3, null, null, fails}; | ||
|
||
// unprivileged user credentials | ||
yield return new object?[] {4, TestCredentials.Root, TestCredentials.TestUser1, fails}; | ||
yield return new object?[] {5, TestCredentials.TestUser1, TestCredentials.TestUser1, fails}; | ||
yield return new object?[] {6, null, TestCredentials.TestUser1, fails}; | ||
|
||
// root user credentials | ||
yield return new object?[] {7, TestCredentials.Root, TestCredentials.Root, succeeds}; | ||
yield return new object?[] {8, TestCredentials.TestUser1, TestCredentials.Root, succeeds}; | ||
yield return new object?[] {9, null, TestCredentials.Root, succeeds}; | ||
} | ||
|
||
[Theory, MemberData(nameof(AuthenticationCases))] | ||
public async Task system_call(int caseNr, UserCredentials? defaultCreds, UserCredentials? user, bool succeeds) { | ||
|
||
_fixture.Settings.DefaultCredentials = defaultCreds; | ||
_fixture.Settings.ConnectionName = $"Authentication case #{caseNr}"; | ||
|
||
await using var client = new EventStoreOperationsClient(_fixture.Settings); | ||
|
||
var result = await Record.ExceptionAsync(() => | ||
client.SetNodePriorityAsync(1, userCredentials: user)); | ||
|
||
if (succeeds) { | ||
Assert.Null(result); | ||
return; | ||
} | ||
|
||
Assert.NotNull(result); | ||
Check failure on line 49 in test/EventStore.Client.Operations.Tests/AuthenticationTests.cs GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net5.0/ltsEventStore.Client.AuthenticationTests.system_call
Check failure on line 49 in test/EventStore.Client.Operations.Tests/AuthenticationTests.cs GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net7.0/ciEventStore.Client.AuthenticationTests.system_call
Check failure on line 49 in test/EventStore.Client.Operations.Tests/AuthenticationTests.cs GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net5.0/previous-ltsEventStore.Client.AuthenticationTests.system_call
Check failure on line 49 in test/EventStore.Client.Operations.Tests/AuthenticationTests.cs GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net7.0/ltsEventStore.Client.AuthenticationTests.system_call
Check failure on line 49 in test/EventStore.Client.Operations.Tests/AuthenticationTests.cs GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net6.0/previous-ltsEventStore.Client.AuthenticationTests.system_call
Check failure on line 49 in test/EventStore.Client.Operations.Tests/AuthenticationTests.cs GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net6.0/ciEventStore.Client.AuthenticationTests.system_call
Check failure on line 49 in test/EventStore.Client.Operations.Tests/AuthenticationTests.cs GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net7.0/previous-ltsEventStore.Client.AuthenticationTests.system_call
Check failure on line 49 in test/EventStore.Client.Operations.Tests/AuthenticationTests.cs GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net5.0/ciEventStore.Client.AuthenticationTests.system_call
Check failure on line 49 in test/EventStore.Client.Operations.Tests/AuthenticationTests.cs GitHub Actions / test / EventStore.Client.Operations/ubuntu-latest/net6.0/ltsEventStore.Client.AuthenticationTests.system_call
|
||
} | ||
|
||
public class Fixture : EventStoreClientFixture { | ||
protected override Task Given() => Task.CompletedTask; | ||
protected override Task When() => Task.CompletedTask; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace EventStore.Client; | ||
|
||
public class AnonymousAccess { | ||
private static readonly Version LegacySince = new Version(23, 6); | ||
private static readonly string SkipMessage = | ||
"Anonymous access is turned off since v23.6.0!"; | ||
|
||
internal class FactAttribute : Deprecation.FactAttribute { | ||
public FactAttribute() : base(LegacySince, SkipMessage) { } | ||
} | ||
|
||
internal class TheoryAttribute : Deprecation.TheoryAttribute { | ||
public TheoryAttribute() : base(LegacySince, SkipMessage) { } | ||
} | ||
} |