| Index: webrtc/base/ssladapter_unittest.cc
|
| diff --git a/webrtc/base/ssladapter_unittest.cc b/webrtc/base/ssladapter_unittest.cc
|
| index 9a0548602e20eae23eb1550eaaf0c7b967052298..9b6945132ae4e9235dcce36609ca595db6f0ee9f 100644
|
| --- a/webrtc/base/ssladapter_unittest.cc
|
| +++ b/webrtc/base/ssladapter_unittest.cc
|
| @@ -15,6 +15,7 @@
|
| #include "webrtc/base/socketstream.h"
|
| #include "webrtc/base/ssladapter.h"
|
| #include "webrtc/base/sslstreamadapter.h"
|
| +#include "webrtc/base/sslidentity.h"
|
| #include "webrtc/base/stream.h"
|
| #include "webrtc/base/virtualsocketserver.h"
|
|
|
| @@ -129,10 +130,11 @@ class SSLAdapterTestDummyClient : public sigslot::has_slots<> {
|
|
|
| class SSLAdapterTestDummyServer : public sigslot::has_slots<> {
|
| public:
|
| - explicit SSLAdapterTestDummyServer(const rtc::SSLMode& ssl_mode)
|
| + explicit SSLAdapterTestDummyServer(const rtc::SSLMode& ssl_mode,
|
| + const rtc::KeyType key_type)
|
| : ssl_mode_(ssl_mode) {
|
| // Generate a key pair and a certificate for this host.
|
| - ssl_identity_.reset(rtc::SSLIdentity::Generate(GetHostname()));
|
| + ssl_identity_.reset(rtc::SSLIdentity::Generate(GetHostname(), key_type));
|
|
|
| server_socket_.reset(CreateSocket(ssl_mode_));
|
|
|
| @@ -268,13 +270,13 @@ class SSLAdapterTestDummyServer : public sigslot::has_slots<> {
|
| class SSLAdapterTestBase : public testing::Test,
|
| public sigslot::has_slots<> {
|
| public:
|
| - explicit SSLAdapterTestBase(const rtc::SSLMode& ssl_mode)
|
| + explicit SSLAdapterTestBase(const rtc::SSLMode& ssl_mode,
|
| + const rtc::KeyType key_type)
|
| : ssl_mode_(ssl_mode),
|
| ss_scope_(new rtc::VirtualSocketServer(NULL)),
|
| - server_(new SSLAdapterTestDummyServer(ssl_mode_)),
|
| + server_(new SSLAdapterTestDummyServer(ssl_mode_, key_type)),
|
| client_(new SSLAdapterTestDummyClient(ssl_mode_)),
|
| - handshake_wait_(kTimeout) {
|
| - }
|
| + handshake_wait_(kTimeout) {}
|
|
|
| void SetHandshakeWait(int wait) {
|
| handshake_wait_ = wait;
|
| @@ -343,43 +345,78 @@ class SSLAdapterTestBase : public testing::Test,
|
| int handshake_wait_;
|
| };
|
|
|
| -class SSLAdapterTestTLS : public SSLAdapterTestBase {
|
| +class SSLAdapterTestTLS_RSA : public SSLAdapterTestBase {
|
| + public:
|
| + SSLAdapterTestTLS_RSA()
|
| + : SSLAdapterTestBase(rtc::SSL_MODE_TLS, rtc::KT_RSA) {}
|
| +};
|
| +
|
| +class SSLAdapterTestTLS_ECDSA : public SSLAdapterTestBase {
|
| public:
|
| - SSLAdapterTestTLS() : SSLAdapterTestBase(rtc::SSL_MODE_TLS) {}
|
| + SSLAdapterTestTLS_ECDSA()
|
| + : SSLAdapterTestBase(rtc::SSL_MODE_TLS, rtc::KT_ECDSA) {}
|
| };
|
|
|
| -class SSLAdapterTestDTLS : public SSLAdapterTestBase {
|
| +class SSLAdapterTestDTLS_RSA : public SSLAdapterTestBase {
|
| public:
|
| - SSLAdapterTestDTLS() : SSLAdapterTestBase(rtc::SSL_MODE_DTLS) {}
|
| + SSLAdapterTestDTLS_RSA()
|
| + : SSLAdapterTestBase(rtc::SSL_MODE_DTLS, rtc::KT_RSA) {}
|
| +};
|
| +
|
| +class SSLAdapterTestDTLS_ECDSA : public SSLAdapterTestBase {
|
| + public:
|
| + SSLAdapterTestDTLS_ECDSA()
|
| + : SSLAdapterTestBase(rtc::SSL_MODE_DTLS, rtc::KT_ECDSA) {}
|
| };
|
|
|
| #if SSL_USE_OPENSSL
|
|
|
| // Basic tests: TLS
|
|
|
| -// Test that handshake works
|
| -TEST_F(SSLAdapterTestTLS, TestTLSConnect) {
|
| +// Test that handshake works, using RSA
|
| +TEST_F(SSLAdapterTestTLS_RSA, TestTLSConnect) {
|
| + TestHandshake(true);
|
| +}
|
| +
|
| +// Test that handshake works, using ECDSA
|
| +TEST_F(SSLAdapterTestTLS_ECDSA, TestTLSConnect) {
|
| + TestHandshake(true);
|
| +}
|
| +
|
| +// Test transfer between client and server, using RSA
|
| +TEST_F(SSLAdapterTestTLS_RSA, TestTLSTransfer) {
|
| TestHandshake(true);
|
| + TestTransfer("Hello, world!");
|
| }
|
|
|
| -// Test transfer between client and server
|
| -TEST_F(SSLAdapterTestTLS, TestTLSTransfer) {
|
| +// Test transfer between client and server, using ECDSA
|
| +TEST_F(SSLAdapterTestTLS_ECDSA, TestTLSTransfer) {
|
| TestHandshake(true);
|
| TestTransfer("Hello, world!");
|
| }
|
|
|
| // Basic tests: DTLS
|
|
|
| -// Test that handshake works
|
| -TEST_F(SSLAdapterTestDTLS, TestDTLSConnect) {
|
| +// Test that handshake works, using RSA
|
| +TEST_F(SSLAdapterTestDTLS_RSA, TestDTLSConnect) {
|
| + TestHandshake(true);
|
| +}
|
| +
|
| +// Test that handshake works, using ECDSA
|
| +TEST_F(SSLAdapterTestDTLS_ECDSA, TestDTLSConnect) {
|
| TestHandshake(true);
|
| }
|
|
|
| -// Test transfer between client and server
|
| -TEST_F(SSLAdapterTestDTLS, TestDTLSTransfer) {
|
| +// Test transfer between client and server, using RSA
|
| +TEST_F(SSLAdapterTestDTLS_RSA, TestDTLSTransfer) {
|
| TestHandshake(true);
|
| TestTransfer("Hello, world!");
|
| }
|
|
|
| -#endif // SSL_USE_OPENSSL
|
| +// Test transfer between client and server, using ECDSA
|
| +TEST_F(SSLAdapterTestDTLS_ECDSA, TestDTLSTransfer) {
|
| + TestHandshake(true);
|
| + TestTransfer("Hello, world!");
|
| +}
|
|
|
| +#endif // SSL_USE_OPENSSL
|
|
|