forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebsocket_integration_test.h
50 lines (39 loc) · 1.57 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
#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;
};
class WebsocketIntegrationTest : public HttpProtocolIntegrationTest {
public:
void initialize() override;
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_;
};
} // namespace Envoy