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