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 "remoting/protocol/ssl_hmac_channel_authenticator.h" | 5 #include "remoting/protocol/ssl_hmac_channel_authenticator.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 scoped_ptr<ChannelAuthenticator> client_auth_; | 130 scoped_ptr<ChannelAuthenticator> client_auth_; |
131 scoped_ptr<ChannelAuthenticator> host_auth_; | 131 scoped_ptr<ChannelAuthenticator> host_auth_; |
132 MockChannelDoneCallback client_callback_; | 132 MockChannelDoneCallback client_callback_; |
133 MockChannelDoneCallback host_callback_; | 133 MockChannelDoneCallback host_callback_; |
134 scoped_ptr<net::StreamSocket> client_socket_; | 134 scoped_ptr<net::StreamSocket> client_socket_; |
135 scoped_ptr<net::StreamSocket> host_socket_; | 135 scoped_ptr<net::StreamSocket> host_socket_; |
136 | 136 |
137 DISALLOW_COPY_AND_ASSIGN(SslHmacChannelAuthenticatorTest); | 137 DISALLOW_COPY_AND_ASSIGN(SslHmacChannelAuthenticatorTest); |
138 }; | 138 }; |
139 | 139 |
140 // These tests use net::SSLServerSocket which is not implemented for OpenSSL. | |
141 #if defined(USE_OPENSSL) | |
142 #define MAYBE(x) DISABLED_##x | |
143 #else | |
144 #define MAYBE(x) x | |
145 #endif | |
146 | |
147 // Verify that a channel can be connected using a valid shared secret. | 140 // Verify that a channel can be connected using a valid shared secret. |
148 TEST_F(SslHmacChannelAuthenticatorTest, MAYBE(SuccessfulAuth)) { | 141 TEST_F(SslHmacChannelAuthenticatorTest, SuccessfulAuth) { |
149 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( | 142 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( |
150 host_cert_, kTestSharedSecret); | 143 host_cert_, kTestSharedSecret); |
151 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( | 144 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( |
152 host_cert_, key_pair_, kTestSharedSecret); | 145 host_cert_, key_pair_, kTestSharedSecret); |
153 | 146 |
154 RunChannelAuth(false); | 147 RunChannelAuth(false); |
155 | 148 |
156 ASSERT_TRUE(client_socket_.get() != NULL); | 149 ASSERT_TRUE(client_socket_.get() != NULL); |
157 ASSERT_TRUE(host_socket_.get() != NULL); | 150 ASSERT_TRUE(host_socket_.get() != NULL); |
158 | 151 |
159 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), | 152 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), |
160 100, 2); | 153 100, 2); |
161 | 154 |
162 tester.Start(); | 155 tester.Start(); |
163 message_loop_.Run(); | 156 message_loop_.Run(); |
164 tester.CheckResults(); | 157 tester.CheckResults(); |
165 } | 158 } |
166 | 159 |
167 // Verify that channels cannot be using invalid shared secret. | 160 // Verify that channels cannot be using invalid shared secret. |
168 TEST_F(SslHmacChannelAuthenticatorTest, MAYBE(InvalidChannelSecret)) { | 161 TEST_F(SslHmacChannelAuthenticatorTest, InvalidChannelSecret) { |
169 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( | 162 client_auth_ = SslHmacChannelAuthenticator::CreateForClient( |
170 host_cert_, kTestSharedSecretBad); | 163 host_cert_, kTestSharedSecretBad); |
171 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( | 164 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( |
172 host_cert_, key_pair_, kTestSharedSecret); | 165 host_cert_, key_pair_, kTestSharedSecret); |
173 | 166 |
174 RunChannelAuth(true); | 167 RunChannelAuth(true); |
175 | 168 |
176 ASSERT_TRUE(host_socket_.get() == NULL); | 169 ASSERT_TRUE(host_socket_.get() == NULL); |
177 } | 170 } |
178 | 171 |
179 } // namespace protocol | 172 } // namespace protocol |
180 } // namespace remoting | 173 } // namespace remoting |
OLD | NEW |