Index: remoting/protocol/ssl_hmac_channel_authenticator_unittest.cc |
diff --git a/remoting/protocol/ssl_hmac_channel_authenticator_unittest.cc b/remoting/protocol/ssl_hmac_channel_authenticator_unittest.cc |
index 49e4c1e34bc74a33657869f441a39718919ec6cf..f74bc6e181e3fde31f14aadf7dce9d6a43ef1ff5 100644 |
--- a/remoting/protocol/ssl_hmac_channel_authenticator_unittest.cc |
+++ b/remoting/protocol/ssl_hmac_channel_authenticator_unittest.cc |
@@ -12,6 +12,7 @@ |
#include "crypto/rsa_private_key.h" |
#include "net/base/cert_test_util.h" |
#include "net/base/net_errors.h" |
+#include "remoting/protocol/authenticator_test_base.h" |
#include "remoting/protocol/connection_tester.h" |
#include "remoting/protocol/fake_session.h" |
#include "testing/gmock/include/gmock/gmock.h" |
@@ -37,82 +38,12 @@ class MockChannelDoneCallback { |
} // namespace |
-class SslHmacChannelAuthenticatorTest : public testing::Test { |
+class SslHmacChannelAuthenticatorTest : public AuthenticatorTestBase { |
Sergey Ulanov
2012/06/05 04:29:46
AuthenticatorTestBase was supposed to be a base cl
|
public: |
- SslHmacChannelAuthenticatorTest() { |
- } |
- virtual ~SslHmacChannelAuthenticatorTest() { |
- } |
- |
- protected: |
- virtual void SetUp() OVERRIDE { |
- FilePath certs_dir(net::GetTestCertsDirectory()); |
- |
- FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der"); |
- ASSERT_TRUE(file_util::ReadFileToString(cert_path, &host_cert_)); |
- |
- FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); |
- std::string key_string; |
- ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string)); |
- std::vector<uint8> key_vector( |
- reinterpret_cast<const uint8*>(key_string.data()), |
- reinterpret_cast<const uint8*>(key_string.data() + |
- key_string.length())); |
- private_key_.reset( |
- crypto::RSAPrivateKey::CreateFromPrivateKeyInfo(key_vector)); |
- } |
- |
- void RunChannelAuth(bool expected_fail) { |
- client_fake_socket_.reset(new FakeSocket()); |
- host_fake_socket_.reset(new FakeSocket()); |
- client_fake_socket_->PairWith(host_fake_socket_.get()); |
- |
- client_auth_->SecureAndAuthenticate( |
- client_fake_socket_.PassAs<net::StreamSocket>(), |
- base::Bind(&SslHmacChannelAuthenticatorTest::OnClientConnected, |
- base::Unretained(this))); |
- |
- host_auth_->SecureAndAuthenticate( |
- host_fake_socket_.PassAs<net::StreamSocket>(), |
- base::Bind(&SslHmacChannelAuthenticatorTest::OnHostConnected, |
- base::Unretained(this))); |
- |
- if (expected_fail) { |
- EXPECT_CALL(client_callback_, OnDone(net::ERR_FAILED, NULL)); |
- EXPECT_CALL(host_callback_, OnDone(net::ERR_FAILED, NULL)); |
- } else { |
- EXPECT_CALL(client_callback_, OnDone(net::OK, NotNull())); |
- EXPECT_CALL(host_callback_, OnDone(net::OK, NotNull())); |
- } |
- |
- message_loop_.RunAllPending(); |
- } |
- |
- void OnHostConnected(net::Error error, |
- scoped_ptr<net::StreamSocket> socket) { |
- host_callback_.OnDone(error, socket.get()); |
- host_socket_ = socket.Pass(); |
- } |
- |
- void OnClientConnected(net::Error error, |
- scoped_ptr<net::StreamSocket> socket) { |
- client_callback_.OnDone(error, socket.get()); |
- client_socket_ = socket.Pass(); |
- } |
- |
- MessageLoop message_loop_; |
- |
- scoped_ptr<crypto::RSAPrivateKey> private_key_; |
- std::string host_cert_; |
- scoped_ptr<FakeSocket> client_fake_socket_; |
- scoped_ptr<FakeSocket> host_fake_socket_; |
- scoped_ptr<ChannelAuthenticator> client_auth_; |
- scoped_ptr<ChannelAuthenticator> host_auth_; |
- MockChannelDoneCallback client_callback_; |
- MockChannelDoneCallback host_callback_; |
- scoped_ptr<net::StreamSocket> client_socket_; |
- scoped_ptr<net::StreamSocket> host_socket_; |
+ SslHmacChannelAuthenticatorTest() {} |
+ virtual ~SslHmacChannelAuthenticatorTest() {} |
+ private: |
DISALLOW_COPY_AND_ASSIGN(SslHmacChannelAuthenticatorTest); |
}; |
@@ -125,9 +56,6 @@ TEST_F(SslHmacChannelAuthenticatorTest, SuccessfulAuth) { |
RunChannelAuth(false); |
- EXPECT_TRUE(client_socket_.get() != NULL); |
- EXPECT_TRUE(host_socket_.get() != NULL); |
- |
StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), |
100, 2); |