fix(test): preserve OpenClaw create payload
CI - Build & Test / Backend (.NET) (push) Successful in 50s
CI - Build & Test / Backend integration (PostgreSQL/Toxiproxy) (push) Successful in 57s
CI - Build & Test / Frontend (Vue/TS) (push) Successful in 2m53s
CI - Build & Test / Security Check (push) Successful in 7s
CI - Build & Test / Deploy Nexus (push) Successful in 1m3s
CI - Build & Test / Backend (.NET) (push) Successful in 50s
CI - Build & Test / Backend integration (PostgreSQL/Toxiproxy) (push) Successful in 57s
CI - Build & Test / Frontend (Vue/TS) (push) Successful in 2m53s
CI - Build & Test / Security Check (push) Successful in 7s
CI - Build & Test / Deploy Nexus (push) Successful in 1m3s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Net.Http.Json;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Nodes;
|
||||
using DotNet.Testcontainers.Builders;
|
||||
@@ -17,6 +18,23 @@ public sealed class ToxiproxyAgentProvisioningIntegrationTests
|
||||
private const ushort ToxiproxyAdminPort = 8474;
|
||||
private const ushort OpenClawProxyPort = 8666;
|
||||
|
||||
[Fact]
|
||||
public void Http_fixture_preserves_json_node_request_payload()
|
||||
{
|
||||
var payload = ToxiproxyHttpGatewayConnector.SerializeParameters(
|
||||
new JsonObject
|
||||
{
|
||||
["name"] = "Release Analyst",
|
||||
["workspace"] = "/tmp/workspace-release-analyst"
|
||||
});
|
||||
var json = JsonNode.Parse(payload)!.AsObject();
|
||||
|
||||
Assert.Equal("Release Analyst", json["name"]!.GetValue<string>());
|
||||
Assert.Equal(
|
||||
"/tmp/workspace-release-analyst",
|
||||
json["workspace"]!.GetValue<string>());
|
||||
}
|
||||
|
||||
[ToxiproxyIntegrationFact]
|
||||
[Trait("Category", "DockerIntegration")]
|
||||
[Trait("Category", "ToxiproxyIntegration")]
|
||||
@@ -292,12 +310,19 @@ internal sealed class ToxiproxyHttpGatewayConnector(Uri endpoint)
|
||||
timeoutSource.Token);
|
||||
break;
|
||||
case "agents.create":
|
||||
{
|
||||
Interlocked.Increment(ref createCalls);
|
||||
response = await client.PostAsJsonAsync(
|
||||
var body = SerializeParameters(parameters);
|
||||
using var content = new StringContent(
|
||||
body,
|
||||
Encoding.UTF8,
|
||||
"application/json");
|
||||
response = await client.PostAsync(
|
||||
"/agents/create",
|
||||
JsonSerializer.SerializeToNode(parameters),
|
||||
content,
|
||||
timeoutSource.Token);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new OpenClawGatewayRpcException(
|
||||
"METHOD_NOT_FOUND",
|
||||
@@ -334,5 +359,12 @@ internal sealed class ToxiproxyHttpGatewayConnector(Uri endpoint)
|
||||
public IReadOnlyList<GatewayEventEnvelope> GetRecentEvents(int limit = 100)
|
||||
=> [];
|
||||
|
||||
internal static string SerializeParameters(object? parameters)
|
||||
=> parameters is JsonNode jsonNode
|
||||
? jsonNode.ToJsonString()
|
||||
: JsonSerializer.Serialize(
|
||||
parameters,
|
||||
parameters?.GetType() ?? typeof(object));
|
||||
|
||||
public void Dispose() => client.Dispose();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user