Skip to content

Commit c731036

Browse files
committed
Add test
1 parent 27192c6 commit c731036

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/Servers/HttpSys/test/FunctionalTests/DelegateTests.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,38 @@ public async Task DelegationFeaturesAreNull()
161161
_ = await SendRequestAsync(delegatorAddress);
162162
}
163163

164+
[ConditionalFact]
165+
[DelegateSupportedCondition(true)]
166+
public async Task UpdateDelegationRuleTest()
167+
{
168+
var queueName = Guid.NewGuid().ToString();
169+
using var receiver = Utilities.CreateHttpServer(out var receiverAddress, async httpContext =>
170+
{
171+
await httpContext.Response.WriteAsync(_expectedResponseString);
172+
},
173+
options =>
174+
{
175+
options.RequestQueueName = queueName;
176+
});
177+
178+
DelegationRule destination = default;
179+
180+
using var delegator = Utilities.CreateHttpServer(out var delegatorAddress, httpContext =>
181+
{
182+
var delegateFeature = httpContext.Features.Get<IHttpSysRequestDelegationFeature>();
183+
delegateFeature.DelegateRequest(destination);
184+
return Task.CompletedTask;
185+
});
186+
187+
var delegationProperty = delegator.Features.Get<IServerDelegationFeature>();
188+
destination = delegationProperty.CreateDelegationRule(queueName, receiverAddress);
189+
destination?.Dispose();
190+
destination = delegationProperty.CreateDelegationRule(queueName, receiverAddress);
191+
var responseString = await SendRequestAsync(delegatorAddress);
192+
Assert.Equal(_expectedResponseString, responseString);
193+
destination?.Dispose();
194+
}
195+
164196
private async Task<string> SendRequestAsync(string uri)
165197
{
166198
using var client = new HttpClient();

0 commit comments

Comments
 (0)