-
Notifications
You must be signed in to change notification settings - Fork 19
/
websocket_integration_test.h
63 lines (52 loc) · 2.21 KB
/
websocket_integration_test.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include "test/integration/http_protocol_integration.h"
#include "gtest/gtest.h"
namespace Envoy {
struct WebsocketProtocolTestParams {
Network::Address::IpVersion version;
Http::CodecClient::Type downstream_protocol;
FakeHttpConnection::Type upstream_protocol;
bool old_style;
};
class WebsocketIntegrationTest : public HttpIntegrationTest,
public testing::TestWithParam<WebsocketProtocolTestParams> {
public:
WebsocketIntegrationTest()
: HttpIntegrationTest(GetParam().downstream_protocol, GetParam().version, realTime()) {}
void initialize() override;
void SetUp() override {
setDownstreamProtocol(GetParam().downstream_protocol);
setUpstreamProtocol(GetParam().upstream_protocol);
}
protected:
void performUpgrade(const Http::TestHeaderMapImpl& upgrade_request_headers,
const Http::TestHeaderMapImpl& upgrade_response_headers);
void sendBidirectionalData();
void validateUpgradeRequestHeaders(const Http::HeaderMap& proxied_request_headers,
const Http::HeaderMap& original_request_headers);
void validateUpgradeResponseHeaders(const Http::HeaderMap& proxied_response_headers,
const Http::HeaderMap& original_response_headers);
void commonValidate(Http::HeaderMap& proxied_headers, const Http::HeaderMap& original_headers);
ABSL_MUST_USE_RESULT
testing::AssertionResult waitForUpstreamDisconnectOrReset() {
if (upstreamProtocol() != FakeHttpConnection::Type::HTTP1) {
return upstream_request_->waitForReset();
} else {
return fake_upstream_connection_->waitForDisconnect();
}
}
void waitForClientDisconnectOrReset() {
if (downstreamProtocol() != Http::CodecClient::Type::HTTP1) {
response_->waitForReset();
} else {
codec_client_->waitForDisconnect();
}
}
IntegrationStreamDecoderPtr response_;
// True if the test uses "old style" TCP proxy websockets. False to use the
// new style "HTTP filter chain" websockets.
// See
// https://github.com/envoyproxy/envoy/blob/master/docs/root/intro/arch_overview/websocket.rst
bool old_style_websockets_{GetParam().old_style};
};
} // namespace Envoy