Skip to content

Commit

Permalink
Merge pull request #1347 from WhitWaldo/additional-secrets-testing
Browse files Browse the repository at this point in the history
Added unit test to Secrets API test suite
  • Loading branch information
WhitWaldo authored Oct 11, 2024
2 parents 8948dd8 + 72c53d8 commit 4d78706
Showing 1 changed file with 27 additions and 1 deletion.
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");

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

0 comments on commit 4d78706

Please sign in to comment.