Skip to content

Commit 70218fd

Browse files
committed
Cleanup, remove unnecessary methods
Signed-off-by: currantw <[email protected]>
1 parent 418ab3a commit 70218fd

File tree

3 files changed

+6
-40
lines changed

3 files changed

+6
-40
lines changed

sources/Valkey.Glide/ConnectionConfiguration.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -522,21 +522,6 @@ public T WithAuthentication(string username, IamAuthConfig iamConfig)
522522
{
523523
return WithCredentials(new ServerCredentials(username, iamConfig));
524524
}
525-
526-
/// <summary>
527-
/// Configure server credentials for IAM authentication.
528-
/// </summary>
529-
/// <param name="username">The username for authentication.</param>
530-
/// <param name="clusterName">The name of the ElastiCache or MemoryDB cluster.</param>
531-
/// <param name="serviceType">The AWS service type (ElastiCache or MemoryDB).</param>
532-
/// <param name="region">The AWS region where the cluster is located.</param>
533-
/// <param name="refreshIntervalSeconds">Optional refresh interval in seconds.</param>
534-
/// <returns>The builder instance for method chaining.</returns>
535-
public T WithAuthentication(string username, string clusterName, ServiceType serviceType, string region, uint? refreshIntervalSeconds = null)
536-
{
537-
var iamConfig = new IamAuthConfig(clusterName, serviceType, region, refreshIntervalSeconds);
538-
return WithCredentials(new ServerCredentials(username, iamConfig));
539-
}
540525
#endregion
541526
#region Protocol
542527
/// <summary>

tests/Valkey.Glide.UnitTests/ConnectionConfigurationTests.cs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -72,35 +72,13 @@ public void WithAuthentication_UsernameIamAuthConfig_ConfiguresCorrectly()
7272
Assert.Throws<ArgumentNullException>(() => builder.WithAuthentication(Username, (IamAuthConfig)null!));
7373
}
7474

75-
[Fact]
76-
public void WithAuthentication_UsernameClusterServiceRegionRefreshInterval()
77-
{
78-
var builder = new StandaloneClientConfigurationBuilder();
79-
builder.WithAuthentication(Username, ClusterName, ServiceType.MemoryDB, Region, RefreshIntervalSeconds);
80-
81-
var config = builder.Build();
82-
var authenticationInfo = config!.Request.AuthenticationInfo!.Value;
83-
var iamCredentials = authenticationInfo.IamCredentials!.Value;
84-
85-
Assert.Equal(Username, authenticationInfo.Username);
86-
Assert.Null(authenticationInfo.Password);
87-
Assert.Equal(ClusterName, iamCredentials.ClusterName);
88-
Assert.Equal(Region, iamCredentials.Region);
89-
Assert.Equal(FFI.ServiceType.MemoryDB, iamCredentials.ServiceType);
90-
Assert.Equal(RefreshIntervalSeconds, iamCredentials.RefreshIntervalSeconds);
91-
92-
// Username, cluster name, and region cannot be null.
93-
Assert.Throws<ArgumentNullException>(() => builder.WithAuthentication(null!, ClusterName, ServiceType.ElastiCache, Region, RefreshIntervalSeconds));
94-
Assert.Throws<ArgumentNullException>(() => builder.WithAuthentication(Username, null!, ServiceType.ElastiCache, Region, RefreshIntervalSeconds));
95-
Assert.Throws<ArgumentNullException>(() => builder.WithAuthentication(Username, ClusterName, ServiceType.ElastiCache, null!, RefreshIntervalSeconds));
96-
}
97-
9875
[Fact]
9976
public void WithAuthentication_MultipleCalls_LastWins()
10077
{
10178
// Password-based authentication last.
10279
var builder = new StandaloneClientConfigurationBuilder();
103-
builder.WithAuthentication(Username, ClusterName, ServiceType.MemoryDB, Region);
80+
var iamConfig = new IamAuthConfig(ClusterName, ServiceType.ElastiCache, Region, RefreshIntervalSeconds);
81+
builder.WithAuthentication(Username, iamConfig);
10482
builder.WithAuthentication(Username, Password);
10583

10684
var config = builder.Build();
@@ -113,7 +91,7 @@ public void WithAuthentication_MultipleCalls_LastWins()
11391
// IAM authentication last.
11492
builder = new StandaloneClientConfigurationBuilder();
11593
builder.WithAuthentication(Username, Password);
116-
builder.WithAuthentication(Username, ClusterName, ServiceType.MemoryDB, Region, RefreshIntervalSeconds);
94+
builder.WithAuthentication(Username, iamConfig);
11795

11896
config = builder.Build();
11997
authenticationInfo = config!.Request.AuthenticationInfo!.Value;

tests/Valkey.Glide.UnitTests/ServerCredentialsTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,13 @@ public void ServerCredentials_UsernameIamAuthConfigWithCustomRefresh()
6161
[Fact]
6262
public void ServerCredentials_ThrowsArgumentNullException()
6363
{
64+
// Password-based authentication.
6465
Assert.Throws<ArgumentNullException>(() => new ServerCredentials(null!));
6566
Assert.Throws<ArgumentNullException>(() => new ServerCredentials(Username, (string)null!));
6667

68+
// IAM authentication.
6769
var iamConfig = new IamAuthConfig(ClusterName, ServiceType.ElastiCache, Region);
6870
Assert.Throws<ArgumentNullException>(() => new ServerCredentials(null!, iamConfig));
71+
Assert.Throws<ArgumentNullException>(() => new ServerCredentials(Username, (IamAuthConfig)null!));
6972
}
7073
}

0 commit comments

Comments
 (0)