From 167c5226a0796b38308bb3f6fd49e2716fae5daf Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Fri, 13 Sep 2024 00:38:41 -0500 Subject: [PATCH 1/2] Added unit test to prove out concern raised on Discord Signed-off-by: Whit Waldo --- test/Dapr.Client.Test/SecretApiTest.cs | 30 +++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/test/Dapr.Client.Test/SecretApiTest.cs b/test/Dapr.Client.Test/SecretApiTest.cs index c94c82844..3e21440e3 100644 --- a/test/Dapr.Client.Test/SecretApiTest.cs +++ b/test/Dapr.Client.Test/SecretApiTest.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------ +// ------------------------------------------------------------------------ // Copyright 2021 The Dapr Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,6 +11,8 @@ // limitations under the License. // ------------------------------------------------------------------------ +using FluentAssertions.Equivalency; + namespace Dapr.Client.Test { using System; @@ -93,6 +95,32 @@ public async Task GetSecretAsync_ReturnSingleSecret() secretsResponse["redis_secret"].Should().Be("Guess_Redis"); } + [Fact] + public async Task GetSecretAsync_WithSlashesInName() + { + await using var client = TestClient.CreateForDaprClient(); + + var request = await client.CaptureGrpcRequestAsync(async DaprClient => + { + return await DaprClient.GetSecretAsync("testStore", "us-west-1/org/xpto/secretabc"); + }); + + request.Dismiss(); + + //Get Request and validate + var envelope = await request.GetRequestEnvelopeAsync(); + envelope.StoreName.Should().Be("testStore"); + envelope.Key.Should().Be("us-west-1/org/xpto/secretabc"); + + var secrets = new Dictionary { { "us-west-1/org/xpto/secretabc", "abc123" } }; + var secretsResponse = await SendResponseWithSecrets(secrets, request); + + //Get response and validate + secretsResponse.Count.Should().Be(1); + secretsResponse.ContainsKey("us-west-1/org/xpto/secretabc").Should().BeTrue(); + secretsResponse["us-west-1/org/xpto/secretabc"].Should().Be("abc123"); + } + [Fact] public async Task GetSecretAsync_ReturnMultipleSecrets() { From 70d092ea79461835848d7b8b04fe86cc3ac7bdd8 Mon Sep 17 00:00:00 2001 From: Whit Waldo Date: Thu, 19 Sep 2024 08:28:04 -0500 Subject: [PATCH 2/2] Removed unused using Signed-off-by: Whit Waldo --- test/Dapr.Client.Test/SecretApiTest.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/Dapr.Client.Test/SecretApiTest.cs b/test/Dapr.Client.Test/SecretApiTest.cs index 3e21440e3..26048e2a4 100644 --- a/test/Dapr.Client.Test/SecretApiTest.cs +++ b/test/Dapr.Client.Test/SecretApiTest.cs @@ -11,8 +11,6 @@ // limitations under the License. // ------------------------------------------------------------------------ -using FluentAssertions.Equivalency; - namespace Dapr.Client.Test { using System;