-
Notifications
You must be signed in to change notification settings - Fork 371
Enable vault name mapping and error suppression #1051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ | |
| using FluentAssertions; | ||
| using Grpc.Net.Client; | ||
| using Microsoft.Extensions.Configuration; | ||
| using Moq; | ||
| using Xunit; | ||
| using Autogenerated = Dapr.Client.Autogen.Grpc.v1; | ||
|
|
||
|
|
@@ -142,23 +143,23 @@ public void AddDaprSecretStore_UsingDescriptors_DuplicateSecret_ReportsError() | |
| [Fact] | ||
| public void LoadSecrets_FromSecretStoreThatReturnsOneValue() | ||
| { | ||
| // Configure Client | ||
| var httpClient = new TestHttpClient() | ||
| var storeName = "store"; | ||
| var secretKey = "secretName"; | ||
| var secretValue = "secret"; | ||
|
|
||
| var secretDescriptors = new[] | ||
| { | ||
| Handler = async (entry) => | ||
| { | ||
| var secrets = new Dictionary<string, string>() { { "secretName", "secret" } }; | ||
| await SendResponseWithSecrets(secrets, entry); | ||
| } | ||
| new DaprSecretDescriptor(secretKey), | ||
| }; | ||
|
|
||
| var daprClient = new DaprClientBuilder() | ||
| .UseHttpClientFactory(() => httpClient) | ||
| .UseGrpcChannelOptions(new GrpcChannelOptions { HttpClient = httpClient }) | ||
| .Build(); | ||
|
|
||
| var daprClient = new Mock<DaprClient>(); | ||
|
|
||
| daprClient.Setup(c => c.GetSecretAsync(storeName, secretKey, | ||
| It.IsAny<Dictionary<string, string>>(), default)) | ||
| .ReturnsAsync(new Dictionary<string, string> { { secretKey, secretValue } }); | ||
|
|
||
| var config = CreateBuilder() | ||
| .AddDaprSecretStore("store", new DaprSecretDescriptor[] { new DaprSecretDescriptor("secretName") }, daprClient) | ||
| .AddDaprSecretStore(storeName, secretDescriptors, daprClient.Object) | ||
| .Build(); | ||
|
|
||
| config["secretName"].Should().Be("secret"); | ||
|
|
@@ -167,29 +168,61 @@ public void LoadSecrets_FromSecretStoreThatReturnsOneValue() | |
| [Fact] | ||
| public void LoadSecrets_FromSecretStoreThatCanReturnsMultipleValues() | ||
| { | ||
| // Configure Client | ||
| var httpClient = new TestHttpClient() | ||
| var storeName = "store"; | ||
| var firstSecretKey = "first_secret"; | ||
| var secondSecretKey = "second_secret"; | ||
| var firstSecretValue = "secret1"; | ||
| var secondSecretValue = "secret2"; | ||
|
|
||
| var secretDescriptors = new[] | ||
| { | ||
| Handler = async (entry) => | ||
| { | ||
| var secrets = new Dictionary<string, string>() { | ||
| { "first_secret", "secret1" }, | ||
| { "second_secret", "secret2" }}; | ||
| await SendResponseWithSecrets(secrets, entry); | ||
| } | ||
| new DaprSecretDescriptor(firstSecretKey), | ||
| new DaprSecretDescriptor(secondSecretKey), | ||
| }; | ||
|
|
||
| var daprClient = new Mock<DaprClient>(); | ||
|
|
||
| daprClient.Setup(c => c.GetSecretAsync(storeName, firstSecretKey, | ||
| It.IsAny<Dictionary<string, string>>(), default)) | ||
| .ReturnsAsync(new Dictionary<string, string> { { firstSecretKey, firstSecretValue } }); | ||
|
|
||
| var daprClient = new DaprClientBuilder() | ||
| .UseHttpClientFactory(() => httpClient) | ||
| .UseGrpcChannelOptions(new GrpcChannelOptions { HttpClient = httpClient }) | ||
| daprClient.Setup(c => c.GetSecretAsync(storeName, secondSecretKey, | ||
| It.IsAny<Dictionary<string, string>>(), default)) | ||
| .ReturnsAsync(new Dictionary<string, string> { { secondSecretKey, secondSecretValue } }); | ||
|
|
||
| var config = CreateBuilder() | ||
| .AddDaprSecretStore(storeName, secretDescriptors, daprClient.Object) | ||
| .Build(); | ||
|
|
||
| config[firstSecretKey].Should().Be(firstSecretValue); | ||
| config[secondSecretKey].Should().Be(secondSecretValue); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void LoadSecrets_FromSecretStoreWithADifferentSecretKeyAndName() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should really have a test for |
||
| { | ||
| var storeName = "store"; | ||
| var secretKey = "Microsservice-DatabaseConnStr"; | ||
| var secretName = "ConnectionStrings:DatabaseConnStr"; | ||
| var secretValue = "secret1"; | ||
|
|
||
| var secretDescriptors = new[] | ||
| { | ||
| new DaprSecretDescriptor(secretName, new Dictionary<string, string>(), true, | ||
| secretKey) | ||
| }; | ||
|
|
||
| var daprClient = new Mock<DaprClient>(); | ||
|
|
||
| daprClient.Setup(c => c.GetSecretAsync(storeName, secretKey, | ||
| It.IsAny<Dictionary<string, string>>(), default)) | ||
| .ReturnsAsync(new Dictionary<string, string> { { secretKey, secretValue } }); | ||
|
|
||
| var config = CreateBuilder() | ||
| .AddDaprSecretStore("store", new DaprSecretDescriptor[] { new DaprSecretDescriptor("secretName") }, daprClient) | ||
| .Build(); | ||
| .AddDaprSecretStore(storeName, secretDescriptors, daprClient.Object) | ||
| .Build(); | ||
|
|
||
| config["first_secret"].Should().Be("secret1"); | ||
| config["second_secret"].Should().Be("secret2"); | ||
| config[secretName].Should().Be(secretValue); | ||
| } | ||
|
|
||
| //Here | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.