Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: webrtc/rtc_base/openssladapter_unittest.cc

Issue 2993403002: Support a user-provided string for the TLS ALPN extension.
Patch Set: Fix previous commit Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/rtc_base/openssladapter.cc ('k') | webrtc/rtc_base/ssladapter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2017 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include <sstream>
12 #include <string>
13 #include <vector>
14
15 #include "webrtc/rtc_base/gunit.h"
16 #include "webrtc/rtc_base/openssladapter.h"
17
18 namespace rtc {
19
20 TEST(OpenSSLAdapterTest, TestTransformAlpnProtocols) {
21 EXPECT_EQ("", TransformAlpnProtocols(std::vector<std::string>()));
22
23 // Protocols larger than 255 characters (whose size can't be fit in a byte),
24 // can't be converted, and an empty string will be returned.
25 std::string large_protocol(256, 'a');
26 EXPECT_EQ("", TransformAlpnProtocols(
27 std::vector<std::string>{large_protocol}));
28
29 // One protocol test.
30 std::vector<std::string> alpn_protos{"h2"};
31 std::stringstream expected_response;
32 expected_response << static_cast<char>(2) << "h2";
33 EXPECT_EQ(expected_response.str(), TransformAlpnProtocols(alpn_protos));
34
35 // Standard protocols test (h2,http/1.1).
36 alpn_protos.push_back("http/1.1");
37 expected_response << static_cast<char>(8) << "http/1.1";
38 EXPECT_EQ(expected_response.str(), TransformAlpnProtocols(alpn_protos));
39 }
40
41 } // namespace rtc
42
OLDNEW
« no previous file with comments | « webrtc/rtc_base/openssladapter.cc ('k') | webrtc/rtc_base/ssladapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698