Skip to content
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

Added unit test to Secrets API test suite #1347

Merged
merged 7 commits into from
Oct 11, 2024
28 changes: 27 additions & 1 deletion test/Dapr.Client.Test/SecretApiTest.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -93,6 +93,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<Autogenerated.GetSecretRequest>();
envelope.StoreName.Should().Be("testStore");
envelope.Key.Should().Be("us-west-1/org/xpto/secretabc");

WhitWaldo marked this conversation as resolved.
Show resolved Hide resolved
var secrets = new Dictionary<string, string> { { "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()
{
Expand Down
Loading