SavedHttpRequest GetSingleGetSecretRequest()
        {
            SavedHttpRequest[] requests = this.GetDaprRequests();
            SavedHttpRequest   req      = Assert.Single(requests);

            Assert.Equal("GET", req.Method);
            return(req);
        }
        public async Task GetSecret_ExplicitSettings_NoMetadata()
        {
            await this.CallFunctionAsync(nameof(Functions.GetSecret_ExplicitSettings_NoMetadata));

            SavedHttpRequest req = this.GetSingleGetSecretRequest();

            Assert.Equal("/v1.0/secrets/store1/key1", req.Path);
            Assert.Equal(QueryString.Empty, req.Query);

            IEnumerable <string> functionLogs = this.GetFunctionLogs(nameof(Functions.GetSecret_ExplicitSettings_NoMetadata));

            Assert.Contains("secret!", functionLogs);
        }
        public async Task GetSecret_BindToJObject()
        {
            await this.CallFunctionAsync(nameof(Functions.GetSecret_BindToJObject));

            SavedHttpRequest req = this.GetSingleGetSecretRequest();

            Assert.Equal("/v1.0/secrets/store1/key1", req.Path);
            Assert.Equal(QueryString.Empty, req.Query);

            IEnumerable <string> functionLogs = this.GetFunctionLogs(nameof(Functions.GetSecret_BindToJObject));

            Assert.Contains(@"{""key1"":""secret!""}", functionLogs);
        }
        public async Task GetSecret_BindToKeyName()
        {
            string keyName = "key1";

            await this.CallFunctionAsync(nameof(Functions.GetSecret_BindToKeyName), "key", keyName);

            SavedHttpRequest req = this.GetSingleGetSecretRequest();

            Assert.Equal($"/v1.0/secrets/store1/{keyName}", req.Path);
            Assert.Equal(QueryString.Empty, req.Query);

            IEnumerable <string> functionLogs = this.GetFunctionLogs(nameof(Functions.GetSecret_BindToKeyName));

            Assert.Contains("secret!", functionLogs);
        }
        public async Task GetSecret_BindToMetadata()
        {
            JObject metadata = JObject.FromObject(
                new
            {
                version_id    = 3,
                version_stage = 4,
            });

            await this.CallFunctionAsync(nameof(Functions.GetSecret_BindToMetadata), "metadata", metadata);

            SavedHttpRequest req = this.GetSingleGetSecretRequest();

            Assert.Equal("/v1.0/secrets/store1/key1", req.Path);
            Assert.Equal("?metadata.version_id=3&metadata.version_stage=4", req.Query.ToString());

            IEnumerable <string> functionLogs = this.GetFunctionLogs(nameof(Functions.GetSecret_BindToMetadata));

            Assert.Contains("secret!", functionLogs);
        }