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 #ifndef REMOTING_PROTOCOL_AUTHENTICATOR_TEST_BASE_H_ | 5 #ifndef REMOTING_PROTOCOL_AUTHENTICATOR_TEST_BASE_H_ |
6 #define REMOTING_PROTOCOL_AUTHENTICATOR_TEST_BASE_H_ | 6 #define REMOTING_PROTOCOL_AUTHENTICATOR_TEST_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "net/base/net_errors.h" | |
13 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
15 | 14 |
16 namespace net { | 15 namespace net { |
17 class StreamSocket; | 16 class StreamSocket; |
18 } // namespace net | 17 } // namespace net |
19 | 18 |
20 namespace remoting { | 19 namespace remoting { |
21 | 20 |
22 class RsaKeyPair; | 21 class RsaKeyPair; |
23 | 22 |
24 namespace protocol { | 23 namespace protocol { |
25 | 24 |
26 class Authenticator; | 25 class Authenticator; |
27 class ChannelAuthenticator; | 26 class ChannelAuthenticator; |
28 class FakeSocket; | 27 class FakeSocket; |
29 | 28 |
30 class AuthenticatorTestBase : public testing::Test { | 29 class AuthenticatorTestBase : public testing::Test { |
31 public: | 30 public: |
32 AuthenticatorTestBase(); | 31 AuthenticatorTestBase(); |
33 virtual ~AuthenticatorTestBase(); | 32 virtual ~AuthenticatorTestBase(); |
34 | 33 |
35 protected: | 34 protected: |
36 class MockChannelDoneCallback { | 35 class MockChannelDoneCallback { |
37 public: | 36 public: |
38 MockChannelDoneCallback(); | 37 MockChannelDoneCallback(); |
39 ~MockChannelDoneCallback(); | 38 ~MockChannelDoneCallback(); |
40 MOCK_METHOD1(OnDone, void(net::Error error)); | 39 MOCK_METHOD1(OnDone, void(int error)); |
41 }; | 40 }; |
42 | 41 |
43 static void ContinueAuthExchangeWith(Authenticator* sender, | 42 static void ContinueAuthExchangeWith(Authenticator* sender, |
44 Authenticator* receiver, | 43 Authenticator* receiver, |
45 bool sender_started, | 44 bool sender_started, |
46 bool receiver_srated); | 45 bool receiver_srated); |
47 virtual void SetUp() OVERRIDE; | 46 virtual void SetUp() OVERRIDE; |
48 void RunAuthExchange(); | 47 void RunAuthExchange(); |
49 void RunHostInitiatedAuthExchange(); | 48 void RunHostInitiatedAuthExchange(); |
50 void RunChannelAuth(bool expected_fail); | 49 void RunChannelAuth(bool expected_fail); |
51 | 50 |
52 void OnHostConnected(net::Error error, | 51 void OnHostConnected(int error, |
53 scoped_ptr<net::StreamSocket> socket); | 52 scoped_ptr<net::StreamSocket> socket); |
54 void OnClientConnected(net::Error error, | 53 void OnClientConnected(int error, |
55 scoped_ptr<net::StreamSocket> socket); | 54 scoped_ptr<net::StreamSocket> socket); |
56 | 55 |
57 base::MessageLoop message_loop_; | 56 base::MessageLoop message_loop_; |
58 | 57 |
59 scoped_refptr<RsaKeyPair> key_pair_; | 58 scoped_refptr<RsaKeyPair> key_pair_; |
60 std::string host_public_key_; | 59 std::string host_public_key_; |
61 std::string host_cert_; | 60 std::string host_cert_; |
62 scoped_ptr<Authenticator> host_; | 61 scoped_ptr<Authenticator> host_; |
63 scoped_ptr<Authenticator> client_; | 62 scoped_ptr<Authenticator> client_; |
64 scoped_ptr<FakeSocket> client_fake_socket_; | 63 scoped_ptr<FakeSocket> client_fake_socket_; |
65 scoped_ptr<FakeSocket> host_fake_socket_; | 64 scoped_ptr<FakeSocket> host_fake_socket_; |
66 scoped_ptr<ChannelAuthenticator> client_auth_; | 65 scoped_ptr<ChannelAuthenticator> client_auth_; |
67 scoped_ptr<ChannelAuthenticator> host_auth_; | 66 scoped_ptr<ChannelAuthenticator> host_auth_; |
68 MockChannelDoneCallback client_callback_; | 67 MockChannelDoneCallback client_callback_; |
69 MockChannelDoneCallback host_callback_; | 68 MockChannelDoneCallback host_callback_; |
70 scoped_ptr<net::StreamSocket> client_socket_; | 69 scoped_ptr<net::StreamSocket> client_socket_; |
71 scoped_ptr<net::StreamSocket> host_socket_; | 70 scoped_ptr<net::StreamSocket> host_socket_; |
72 | 71 |
73 DISALLOW_COPY_AND_ASSIGN(AuthenticatorTestBase); | 72 DISALLOW_COPY_AND_ASSIGN(AuthenticatorTestBase); |
74 }; | 73 }; |
75 | 74 |
76 } // namespace protocol | 75 } // namespace protocol |
77 } // namespace remoting | 76 } // namespace remoting |
78 | 77 |
79 #endif // REMOTING_PROTOCOL_AUTHENTICATOR_TEST_BASE_H_ | 78 #endif // REMOTING_PROTOCOL_AUTHENTICATOR_TEST_BASE_H_ |
OLD | NEW |