OLD | NEW |
---|---|
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/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 2333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2344 EXPECT_EQ(rv, OK); | 2344 EXPECT_EQ(rv, OK); |
2345 EXPECT_NE(memcmp(client_out1, client_out2, kKeyingMaterialSize), 0); | 2345 EXPECT_NE(memcmp(client_out1, client_out2, kKeyingMaterialSize), 0); |
2346 } | 2346 } |
2347 | 2347 |
2348 // Verifies that SSLClientSocket::ClearSessionCache can be called without | 2348 // Verifies that SSLClientSocket::ClearSessionCache can be called without |
2349 // explicit NSS initialization. | 2349 // explicit NSS initialization. |
2350 TEST(SSLClientSocket, ClearSessionCache) { | 2350 TEST(SSLClientSocket, ClearSessionCache) { |
2351 SSLClientSocket::ClearSessionCache(); | 2351 SSLClientSocket::ClearSessionCache(); |
2352 } | 2352 } |
2353 | 2353 |
2354 TEST(SSLClientSocket, SerializeNextProtos) { | |
2355 NextProtoVector next_protos; | |
2356 next_protos.push_back(kProtoHTTP11); | |
2357 next_protos.push_back(kProtoSPDY31); | |
2358 static std::vector<uint8_t> serialized = | |
2359 SSLClientSocket::SerializeNextProtos(next_protos); | |
2360 ASSERT_EQ(18u, serialized.size()); | |
2361 EXPECT_EQ(8, serialized[0]); // length("http/1.1") | |
2362 EXPECT_EQ('h', serialized[1]); | |
2363 EXPECT_EQ('t', serialized[2]); | |
2364 EXPECT_EQ('t', serialized[3]); | |
2365 EXPECT_EQ('p', serialized[4]); | |
2366 EXPECT_EQ('/', serialized[5]); | |
2367 EXPECT_EQ('1', serialized[6]); | |
2368 EXPECT_EQ('.', serialized[7]); | |
2369 EXPECT_EQ('1', serialized[8]); | |
2370 EXPECT_EQ(8, serialized[9]); // length("spdy/3.1") | |
2371 EXPECT_EQ('s', serialized[10]); | |
2372 EXPECT_EQ('p', serialized[11]); | |
2373 EXPECT_EQ('d', serialized[12]); | |
2374 EXPECT_EQ('y', serialized[13]); | |
2375 EXPECT_EQ('/', serialized[14]); | |
2376 EXPECT_EQ('3', serialized[15]); | |
2377 EXPECT_EQ('.', serialized[16]); | |
2378 EXPECT_EQ('1', serialized[17]); | |
Ryan Hamilton
2014/12/12 15:12:12
Could you do something like EXPECT_EQ("\x08http/1.
Bence
2014/12/12 15:40:16
I couldn't quite do this, since one is a vector, t
| |
2379 } | |
2380 | |
2354 // Test that the server certificates are properly retrieved from the underlying | 2381 // Test that the server certificates are properly retrieved from the underlying |
2355 // SSL stack. | 2382 // SSL stack. |
2356 TEST_F(SSLClientSocketTest, VerifyServerChainProperlyOrdered) { | 2383 TEST_F(SSLClientSocketTest, VerifyServerChainProperlyOrdered) { |
2357 // The connection does not have to be successful. | 2384 // The connection does not have to be successful. |
2358 cert_verifier_->set_default_result(ERR_CERT_INVALID); | 2385 cert_verifier_->set_default_result(ERR_CERT_INVALID); |
2359 | 2386 |
2360 // Set up a test server with CERT_CHAIN_WRONG_ROOT. | 2387 // Set up a test server with CERT_CHAIN_WRONG_ROOT. |
2361 // This makes the server present redundant-server-chain.pem, which contains | 2388 // This makes the server present redundant-server-chain.pem, which contains |
2362 // intermediate certificates. | 2389 // intermediate certificates. |
2363 SpawnedTestServer::SSLOptions ssl_options( | 2390 SpawnedTestServer::SSLOptions ssl_options( |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3073 ssl_config.channel_id_enabled = true; | 3100 ssl_config.channel_id_enabled = true; |
3074 | 3101 |
3075 int rv; | 3102 int rv; |
3076 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); | 3103 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
3077 | 3104 |
3078 EXPECT_EQ(ERR_UNEXPECTED, rv); | 3105 EXPECT_EQ(ERR_UNEXPECTED, rv); |
3079 EXPECT_FALSE(sock_->IsConnected()); | 3106 EXPECT_FALSE(sock_->IsConnected()); |
3080 } | 3107 } |
3081 | 3108 |
3082 } // namespace net | 3109 } // namespace net |
OLD | NEW |