Skip to content

Commit 7e024c9

Browse files
committed
Skip EntraId tests correctly
1 parent 25527c1 commit 7e024c9

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

tests/NRedisStack.Tests/AbstractNRedisStackTest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ protected IDatabase GetCleanDatabase(string endpointId = EndpointsFixture.Env.St
5353
return db;
5454
}
5555

56+
protected void SkipIfTargetConnectionDoesNotExist(string id)
57+
{
58+
Skip.IfNot(EndpointsFixture.IsTargetConnectionExist(id), $"The connection with id '{id}' is not configured.");
59+
}
60+
5661
private List<string> keyNames = new List<string>();
5762

5863
protected internal string CreateKeyName([CallerMemberName] string memberName = "") => CreateKeyNames(1, memberName)[0];

tests/NRedisStack.Tests/EndpointsFixture.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public class EndpointsFixture : IDisposable
4343
public static class Env
4444
{
4545
public const string Standalone = "standalone";
46+
public const string StandaloneEntraId = "standalone-entraid";
4647
public const string Cluster = "cluster";
4748

4849
public static IEnumerable<object[]> AllEnvironments()

tests/NRedisStack.Tests/TokenBasedAuthentication/AuthenticationTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ public AuthenticationTests(EndpointsFixture endpointsFixture) : base(endpointsFi
2121
[SkippableFact]
2222
public void TestTokenBasedAuthentication()
2323
{
24-
24+
// This is needed because we're constructing ConfigurationOptions in the test before calling GetConnection
25+
SkipIfTargetConnectionDoesNotExist(EndpointsFixture.Env.StandaloneEntraId);
26+
2527
var configurationOptions = new ConfigurationOptions().ConfigureForAzureWithTokenCredentialAsync(new DefaultAzureCredential()).Result!;
2628
configurationOptions.Ssl = false;
2729
configurationOptions.AbortOnConnectFail = true; // Fail fast for the purposes of this sample. In production code, this should remain false to retry connections on startup
2830

29-
ConnectionMultiplexer? connectionMultiplexer = GetConnection(configurationOptions, "standalone-entraid-acl");
31+
ConnectionMultiplexer? connectionMultiplexer = GetConnection(configurationOptions, EndpointsFixture.Env.StandaloneEntraId);
3032

3133
IDatabase db = connectionMultiplexer.GetDatabase();
3234

0 commit comments

Comments
 (0)