Skip to content

Commit

Permalink
testcase to check http2 set (#836)
Browse files Browse the repository at this point in the history
* add test to ensure http2 ver set

* remove comment
  • Loading branch information
tg123 authored Apr 22, 2022
1 parent f9985ed commit 262e166
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/KubernetesClient.Tests/WatchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -701,5 +701,43 @@ public void ReadError()
Assert.Equal("too old resource version: 44982(53593)", k8sException.Status.Message);
}
}

private class CheckHeaderDelegatingHandler : DelegatingHandler
{
public Version Version { get; private set; }

public CheckHeaderDelegatingHandler()
: base()
{
}

public CheckHeaderDelegatingHandler(HttpMessageHandler innerHandler)
: base(innerHandler)
{
}

protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
Version = request.Version;
return base.SendAsync(request, cancellationToken);
}
}

[Fact]
public async Task MustHttp2VersionSet()
{
var server = new MockKubeApiServer(testOutput, async httpContext =>
{
await WriteStreamLine(httpContext, MockAddedEventStreamLine).ConfigureAwait(false);
return false;
});

var h = new CheckHeaderDelegatingHandler();
var client = new Kubernetes(new KubernetesClientConfiguration { Host = server.Uri.ToString() }, h);

Assert.Null(h.Version);
await client.ListNamespacedPodWithHttpMessagesAsync("default", watch: true).ConfigureAwait(false);
Assert.Equal(HttpVersion.Version20, h.Version);
}
}
}

0 comments on commit 262e166

Please sign in to comment.