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

Side by Side Diff: net/socket/ssl_client_socket_unittest.cc

Issue 1371263002: Refactor SSLClientSocket::SerializeNextProtos(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/ssl_client_socket.h" 5 #include "net/socket/ssl_client_socket.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 2350 matching lines...) Expand 10 before | Expand all | Expand 10 after
2361 EXPECT_EQ(rv, OK); 2361 EXPECT_EQ(rv, OK);
2362 EXPECT_NE(memcmp(client_out1, client_out2, kKeyingMaterialSize), 0); 2362 EXPECT_NE(memcmp(client_out1, client_out2, kKeyingMaterialSize), 0);
2363 } 2363 }
2364 2364
2365 // Verifies that SSLClientSocket::ClearSessionCache can be called without 2365 // Verifies that SSLClientSocket::ClearSessionCache can be called without
2366 // explicit NSS initialization. 2366 // explicit NSS initialization.
2367 TEST(SSLClientSocket, ClearSessionCache) { 2367 TEST(SSLClientSocket, ClearSessionCache) {
2368 SSLClientSocket::ClearSessionCache(); 2368 SSLClientSocket::ClearSessionCache();
2369 } 2369 }
2370 2370
2371 TEST(SSLClientSocket, DisableHTTP2) {
2372 NextProtoVector next_protos;
2373 next_protos.push_back(kProtoHTTP11);
2374 next_protos.push_back(kProtoHTTP2);
2375 next_protos.push_back(kProtoSPDY31);
2376 SSLClientSocket::DisableHTTP2(&next_protos);
2377 ASSERT_EQ(2u, next_protos.size());
2378 EXPECT_EQ(kProtoHTTP11, next_protos[0]);
2379 EXPECT_EQ(kProtoSPDY31, next_protos[1]);
2380 }
2381
2371 TEST(SSLClientSocket, SerializeNextProtos) { 2382 TEST(SSLClientSocket, SerializeNextProtos) {
2372 NextProtoVector next_protos; 2383 NextProtoVector next_protos;
2373 next_protos.push_back(kProtoHTTP11); 2384 next_protos.push_back(kProtoHTTP11);
2374 next_protos.push_back(kProtoSPDY31); 2385 next_protos.push_back(kProtoSPDY31);
2375 static std::vector<uint8_t> serialized = 2386 static std::vector<uint8_t> serialized =
2376 SSLClientSocket::SerializeNextProtos(next_protos, true); 2387 SSLClientSocket::SerializeNextProtos(next_protos);
2377 ASSERT_EQ(18u, serialized.size()); 2388 ASSERT_EQ(18u, serialized.size());
2378 EXPECT_EQ(8, serialized[0]); // length("http/1.1") 2389 EXPECT_EQ(8, serialized[0]); // length("http/1.1")
2379 EXPECT_EQ('h', serialized[1]); 2390 EXPECT_EQ('h', serialized[1]);
2380 EXPECT_EQ('t', serialized[2]); 2391 EXPECT_EQ('t', serialized[2]);
2381 EXPECT_EQ('t', serialized[3]); 2392 EXPECT_EQ('t', serialized[3]);
2382 EXPECT_EQ('p', serialized[4]); 2393 EXPECT_EQ('p', serialized[4]);
2383 EXPECT_EQ('/', serialized[5]); 2394 EXPECT_EQ('/', serialized[5]);
2384 EXPECT_EQ('1', serialized[6]); 2395 EXPECT_EQ('1', serialized[6]);
2385 EXPECT_EQ('.', serialized[7]); 2396 EXPECT_EQ('.', serialized[7]);
2386 EXPECT_EQ('1', serialized[8]); 2397 EXPECT_EQ('1', serialized[8]);
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
3474 ssl_config.channel_id_enabled = true; 3485 ssl_config.channel_id_enabled = true;
3475 3486
3476 int rv; 3487 int rv;
3477 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); 3488 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv));
3478 3489
3479 EXPECT_EQ(ERR_UNEXPECTED, rv); 3490 EXPECT_EQ(ERR_UNEXPECTED, rv);
3480 EXPECT_FALSE(sock_->IsConnected()); 3491 EXPECT_FALSE(sock_->IsConnected());
3481 } 3492 }
3482 3493
3483 } // namespace net 3494 } // namespace net
OLDNEW
« net/socket/ssl_client_socket_nss.cc ('K') | « net/socket/ssl_client_socket_openssl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698