diff --git a/test/Worker.Extensions.DurableTask.Tests/FunctionsDurableTaskClientTests.cs b/test/Worker.Extensions.DurableTask.Tests/FunctionsDurableTaskClientTests.cs
index 34548a384..296cfc28c 100644
--- a/test/Worker.Extensions.DurableTask.Tests/FunctionsDurableTaskClientTests.cs
+++ b/test/Worker.Extensions.DurableTask.Tests/FunctionsDurableTaskClientTests.cs
@@ -1,3 +1,4 @@
+using System.Security.Claims;
using Microsoft.Azure.Functions.Worker.Http;
using Microsoft.DurableTask.Client;
using Microsoft.DurableTask.Client.Grpc;
@@ -10,7 +11,7 @@ namespace Microsoft.Azure.Functions.Worker.Tests
///
public class FunctionsDurableTaskClientTests
{
- private FunctionsDurableTaskClient GetTestFunctionsDurableTaskClient(string baseUrl = null)
+ private FunctionsDurableTaskClient GetTestFunctionsDurableTaskClient(string? baseUrl = null)
{
// construct mock client
@@ -59,17 +60,34 @@ public async void TerminateDoesNotThrow()
/// Test that the `CreateHttpManagementPayload` method returns the expected payload structure without HttpRequestData.
///
[Fact]
- public void CreateHttpManagementPayload_WithBaseUrl_ReturnsExpectedStructure()
+ public void CreateHttpManagementPayload_WithBaseUrl()
{
string BaseUrl = "http://localhost:7071/runtime/webhooks/durabletask";
FunctionsDurableTaskClient client = this.GetTestFunctionsDurableTaskClient(BaseUrl);
- string instanceId = "testInstanceId";
+ string instanceId = "testInstanceIdWithHostBaseUrl";
dynamic payload = client.CreateHttpManagementPayload(instanceId);
AssertHttpManagementPayload(payload, BaseUrl, instanceId);
}
+ ///
+ /// Test that the `CreateHttpManagementPayload` method returns the expected payload structure with HttpRequestData.
+ ///
+ [Fact]
+ public void CreateHttpManagementPayload_WithHttpRequestData()
+ {
+ string requestUrl = "http://localhost:7075/orchestrators/E1_HelloSequence";
+ FunctionsDurableTaskClient client = this.GetTestFunctionsDurableTaskClient();
+ string instanceId = "testInstanceIdWithRequest";
+ var context = new TestFunctionContext();
+ var request = new TestHttpRequestData(context, new Uri(requestUrl));
+
+ dynamic payload = client.CreateHttpManagementPayload(instanceId, request);
+
+ AssertHttpManagementPayload(payload, "http://localhost:7075/runtime/webhooks/durabletask", instanceId);
+ }
+
private static void AssertHttpManagementPayload(dynamic payload, string BaseUrl, string instanceId)
{
Assert.Equal(instanceId, payload.id);
@@ -81,4 +99,49 @@ private static void AssertHttpManagementPayload(dynamic payload, string BaseUrl,
Assert.Equal($"{BaseUrl}/instances/{instanceId}/resume?reason={{{{text}}}}", payload.resumePostUri);
}
}
+
+ ///
+ /// A minimal implementation of FunctionContext for testing purposes.
+ /// It's used to create a TestHttpRequestData instance, which requires a FunctionContext.
+ ///
+ public class TestFunctionContext : FunctionContext
+ {
+ public override string InvocationId => throw new NotImplementedException();
+ public override string FunctionId => throw new NotImplementedException();
+ public override TraceContext TraceContext => throw new NotImplementedException();
+ public override BindingContext BindingContext => throw new NotImplementedException();
+ public override RetryContext RetryContext => throw new NotImplementedException();
+ public override IServiceProvider InstanceServices { get; set; } = new EmptyServiceProvider();
+ public override FunctionDefinition FunctionDefinition => throw new NotImplementedException();
+ public override IDictionary