Exemplo n.º 1
0
        public void LoadSecrets_FromSecretStoreThatCanReturnsMultipleValues()
        {
            // Configure Client
            var httpClient = new TestHttpClient()
            {
                Handler = async(entry) =>
                {
                    var secrets = new Dictionary <string, string>()
                    {
                        { "first_secret", "secret1" },
                        { "second_secret", "secret2" }
                    };
                    var secretResponse = new Autogenerated.GetSecretResponseEnvelope();
                    secretResponse.Data.Add(secrets);

                    var streamContent = await GrpcUtils.CreateResponseContent(secretResponse);

                    var response = GrpcUtils.CreateResponse(HttpStatusCode.OK, streamContent);
                    entry.Completion.SetResult(response);
                }
            };

            var daprClient = new DaprClientBuilder()
                             .UseGrpcChannelOptions(new GrpcChannelOptions {
                HttpClient = httpClient
            })
                             .Build();

            var config = CreateBuilder()
                         .AddDaprSecretStore("store", new DaprSecretDescriptor[] { new DaprSecretDescriptor("secretName") }, daprClient)
                         .Build();

            config["first_secret"].Should().Be("secret1");
            config["second_secret"].Should().Be("secret2");
        }
Exemplo n.º 2
0
        private async Task SendResponseWithSecrets(Dictionary <string, string> secrets, TestHttpClient.Entry entry)
        {
            var secretResponse = new Autogenerated.GetSecretResponseEnvelope();

            secretResponse.Data.Add(secrets);

            var streamContent = await GrpcUtils.CreateResponseContent(secretResponse);

            var response = GrpcUtils.CreateResponse(HttpStatusCode.OK, streamContent);

            entry.Completion.SetResult(response);
        }