| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "remoting/protocol/ssl_hmac_channel_authenticator.h" | 5 #include "remoting/protocol/ssl_hmac_channel_authenticator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 MockChannelDoneCallback client_callback_; | 110 MockChannelDoneCallback client_callback_; |
| 111 MockChannelDoneCallback host_callback_; | 111 MockChannelDoneCallback host_callback_; |
| 112 scoped_ptr<net::StreamSocket> client_socket_; | 112 scoped_ptr<net::StreamSocket> client_socket_; |
| 113 scoped_ptr<net::StreamSocket> host_socket_; | 113 scoped_ptr<net::StreamSocket> host_socket_; |
| 114 | 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(SslHmacChannelAuthenticatorTest); | 115 DISALLOW_COPY_AND_ASSIGN(SslHmacChannelAuthenticatorTest); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 // Verify that a channel can be connected using a valid shared secret. | 118 // Verify that a channel can be connected using a valid shared secret. |
| 119 TEST_F(SslHmacChannelAuthenticatorTest, SuccessfulAuth) { | 119 TEST_F(SslHmacChannelAuthenticatorTest, SuccessfulAuth) { |
| 120 client_auth_.reset(SslHmacChannelAuthenticator::CreateForClient( | 120 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( |
| 121 host_cert_, kTestSharedSecret)); | 121 host_cert_, kTestSharedSecret); |
| 122 host_auth_.reset(SslHmacChannelAuthenticator::CreateForHost( | 122 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( |
| 123 host_cert_, private_key_.get(), kTestSharedSecret)); | 123 host_cert_, private_key_.get(), kTestSharedSecret); |
| 124 | 124 |
| 125 RunChannelAuth(false); | 125 RunChannelAuth(false); |
| 126 | 126 |
| 127 EXPECT_TRUE(client_socket_.get() != NULL); | 127 EXPECT_TRUE(client_socket_.get() != NULL); |
| 128 EXPECT_TRUE(host_socket_.get() != NULL); | 128 EXPECT_TRUE(host_socket_.get() != NULL); |
| 129 | 129 |
| 130 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), | 130 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), |
| 131 100, 2); | 131 100, 2); |
| 132 | 132 |
| 133 tester.Start(); | 133 tester.Start(); |
| 134 message_loop_.Run(); | 134 message_loop_.Run(); |
| 135 tester.CheckResults(); | 135 tester.CheckResults(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 // Verify that channels cannot be using invalid shared secret. | 138 // Verify that channels cannot be using invalid shared secret. |
| 139 TEST_F(SslHmacChannelAuthenticatorTest, InvalidChannelSecret) { | 139 TEST_F(SslHmacChannelAuthenticatorTest, InvalidChannelSecret) { |
| 140 client_auth_.reset(SslHmacChannelAuthenticator::CreateForClient( | 140 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( |
| 141 host_cert_, kTestSharedSecretBad)); | 141 host_cert_, kTestSharedSecretBad); |
| 142 host_auth_.reset(SslHmacChannelAuthenticator::CreateForHost( | 142 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( |
| 143 host_cert_, private_key_.get(), kTestSharedSecret)); | 143 host_cert_, private_key_.get(), kTestSharedSecret); |
| 144 | 144 |
| 145 RunChannelAuth(true); | 145 RunChannelAuth(true); |
| 146 | 146 |
| 147 EXPECT_TRUE(host_socket_.get() == NULL); | 147 EXPECT_TRUE(host_socket_.get() == NULL); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace protocol | 150 } // namespace protocol |
| 151 } // namespace remoting | 151 } // namespace remoting |
| OLD | NEW |