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

Side by Side Diff: webrtc/base/sslstreamadapter_unittest.cc

Issue 1380603005: Revert of Change WebRTC SslCipher to be exposed as number only. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@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
« no previous file with comments | « webrtc/base/sslstreamadapter.cc ('k') | webrtc/p2p/base/dtlstransportchannel.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 return server_ssl_->GetDtlsSrtpCipher(retval); 403 return server_ssl_->GetDtlsSrtpCipher(retval);
404 } 404 }
405 405
406 bool GetPeerCertificate(bool client, rtc::SSLCertificate** cert) { 406 bool GetPeerCertificate(bool client, rtc::SSLCertificate** cert) {
407 if (client) 407 if (client)
408 return client_ssl_->GetPeerCertificate(cert); 408 return client_ssl_->GetPeerCertificate(cert);
409 else 409 else
410 return server_ssl_->GetPeerCertificate(cert); 410 return server_ssl_->GetPeerCertificate(cert);
411 } 411 }
412 412
413 bool GetSslCipherSuite(bool client, uint16_t* retval) { 413 bool GetSslCipher(bool client, std::string *retval) {
414 if (client) 414 if (client)
415 return client_ssl_->GetSslCipherSuite(retval); 415 return client_ssl_->GetSslCipher(retval);
416 else 416 else
417 return server_ssl_->GetSslCipherSuite(retval); 417 return server_ssl_->GetSslCipher(retval);
418 } 418 }
419 419
420 bool ExportKeyingMaterial(const char *label, 420 bool ExportKeyingMaterial(const char *label,
421 const unsigned char *context, 421 const unsigned char *context,
422 size_t context_len, 422 size_t context_len,
423 bool use_context, 423 bool use_context,
424 bool client, 424 bool client,
425 unsigned char *result, 425 unsigned char *result,
426 size_t result_len) { 426 size_t result_len) {
427 if (client) 427 if (client)
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 // It's kCERT_PEM 960 // It's kCERT_PEM
961 ASSERT_EQ(kCERT_PEM, server_peer_cert->ToPEMString()); 961 ASSERT_EQ(kCERT_PEM, server_peer_cert->ToPEMString());
962 962
963 // It must not have a chain, because the test certs are self-signed. 963 // It must not have a chain, because the test certs are self-signed.
964 rtc::SSLCertChain* server_peer_chain; 964 rtc::SSLCertChain* server_peer_chain;
965 ASSERT_FALSE(server_peer_cert->GetChain(&server_peer_chain)); 965 ASSERT_FALSE(server_peer_cert->GetChain(&server_peer_chain));
966 } 966 }
967 967
968 // Test getting the used DTLS ciphers. 968 // Test getting the used DTLS ciphers.
969 // DTLS 1.2 enabled for neither client nor server -> DTLS 1.0 will be used. 969 // DTLS 1.2 enabled for neither client nor server -> DTLS 1.0 will be used.
970 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherSuite) { 970 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipher) {
971 MAYBE_SKIP_TEST(HaveDtls); 971 MAYBE_SKIP_TEST(HaveDtls);
972 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10); 972 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_10);
973 TestHandshake(); 973 TestHandshake();
974 974
975 uint16_t client_cipher; 975 std::string client_cipher;
976 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); 976 ASSERT_TRUE(GetSslCipher(true, &client_cipher));
977 uint16_t server_cipher; 977 std::string server_cipher;
978 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); 978 ASSERT_TRUE(GetSslCipher(false, &server_cipher));
979 979
980 ASSERT_EQ(client_cipher, server_cipher); 980 ASSERT_EQ(client_cipher, server_cipher);
981 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( 981 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher(
982 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), 982 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())),
983 server_cipher); 983 server_cipher);
984 } 984 }
985 985
986 // Test getting the used DTLS 1.2 ciphers. 986 // Test getting the used DTLS 1.2 ciphers.
987 // DTLS 1.2 enabled for client and server -> DTLS 1.2 will be used. 987 // DTLS 1.2 enabled for client and server -> DTLS 1.2 will be used.
988 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherSuiteDtls12Both) { 988 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Both) {
989 MAYBE_SKIP_TEST(HaveDtls); 989 MAYBE_SKIP_TEST(HaveDtls);
990 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12); 990 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_12);
991 TestHandshake(); 991 TestHandshake();
992 992
993 uint16_t client_cipher; 993 std::string client_cipher;
994 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); 994 ASSERT_TRUE(GetSslCipher(true, &client_cipher));
995 uint16_t server_cipher; 995 std::string server_cipher;
996 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); 996 ASSERT_TRUE(GetSslCipher(false, &server_cipher));
997 997
998 ASSERT_EQ(client_cipher, server_cipher); 998 ASSERT_EQ(client_cipher, server_cipher);
999 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( 999 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher(
1000 rtc::SSL_PROTOCOL_DTLS_12, ::testing::get<1>(GetParam())), 1000 rtc::SSL_PROTOCOL_DTLS_12, ::testing::get<1>(GetParam())),
1001 server_cipher); 1001 server_cipher);
1002 } 1002 }
1003 1003
1004 // DTLS 1.2 enabled for client only -> DTLS 1.0 will be used. 1004 // DTLS 1.2 enabled for client only -> DTLS 1.0 will be used.
1005 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherSuiteDtls12Client) { 1005 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Client) {
1006 MAYBE_SKIP_TEST(HaveDtls); 1006 MAYBE_SKIP_TEST(HaveDtls);
1007 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12); 1007 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_10, rtc::SSL_PROTOCOL_DTLS_12);
1008 TestHandshake(); 1008 TestHandshake();
1009 1009
1010 uint16_t client_cipher; 1010 std::string client_cipher;
1011 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); 1011 ASSERT_TRUE(GetSslCipher(true, &client_cipher));
1012 uint16_t server_cipher; 1012 std::string server_cipher;
1013 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); 1013 ASSERT_TRUE(GetSslCipher(false, &server_cipher));
1014 1014
1015 ASSERT_EQ(client_cipher, server_cipher); 1015 ASSERT_EQ(client_cipher, server_cipher);
1016 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( 1016 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher(
1017 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), 1017 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())),
1018 server_cipher); 1018 server_cipher);
1019 } 1019 }
1020 1020
1021 // DTLS 1.2 enabled for server only -> DTLS 1.0 will be used. 1021 // DTLS 1.2 enabled for server only -> DTLS 1.0 will be used.
1022 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherSuiteDtls12Server) { 1022 TEST_P(SSLStreamAdapterTestDTLS, TestGetSslCipherDtls12Server) {
1023 MAYBE_SKIP_TEST(HaveDtls); 1023 MAYBE_SKIP_TEST(HaveDtls);
1024 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10); 1024 SetupProtocolVersions(rtc::SSL_PROTOCOL_DTLS_12, rtc::SSL_PROTOCOL_DTLS_10);
1025 TestHandshake(); 1025 TestHandshake();
1026 1026
1027 uint16_t client_cipher; 1027 std::string client_cipher;
1028 ASSERT_TRUE(GetSslCipherSuite(true, &client_cipher)); 1028 ASSERT_TRUE(GetSslCipher(true, &client_cipher));
1029 uint16_t server_cipher; 1029 std::string server_cipher;
1030 ASSERT_TRUE(GetSslCipherSuite(false, &server_cipher)); 1030 ASSERT_TRUE(GetSslCipher(false, &server_cipher));
1031 1031
1032 ASSERT_EQ(client_cipher, server_cipher); 1032 ASSERT_EQ(client_cipher, server_cipher);
1033 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipherForTest( 1033 ASSERT_EQ(rtc::SSLStreamAdapter::GetDefaultSslCipher(
1034 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())), 1034 rtc::SSL_PROTOCOL_DTLS_10, ::testing::get<1>(GetParam())),
1035 server_cipher); 1035 server_cipher);
1036 } 1036 }
1037 1037
1038 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsTLS, 1038 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsTLS,
1039 SSLStreamAdapterTestTLS, 1039 SSLStreamAdapterTestTLS,
1040 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA), 1040 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA),
1041 Values(rtc::KT_RSA, rtc::KT_ECDSA))); 1041 Values(rtc::KT_RSA, rtc::KT_ECDSA)));
1042 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsDTLS, 1042 INSTANTIATE_TEST_CASE_P(SSLStreamAdapterTestsDTLS,
1043 SSLStreamAdapterTestDTLS, 1043 SSLStreamAdapterTestDTLS,
1044 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA), 1044 Combine(Values(rtc::KT_RSA, rtc::KT_ECDSA),
1045 Values(rtc::KT_RSA, rtc::KT_ECDSA))); 1045 Values(rtc::KT_RSA, rtc::KT_ECDSA)));
OLDNEW
« no previous file with comments | « webrtc/base/sslstreamadapter.cc ('k') | webrtc/p2p/base/dtlstransportchannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698