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
3 // found in the LICENSE file.
5 #ifndef REMOTING_PROTOCOL_AUTHENTICATOR_TEST_BASE_H_
6 #define REMOTING_PROTOCOL_AUTHENTICATOR_TEST_BASE_H_
10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop/message_loop.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h"
22 class ChannelAuthenticator
;
23 class FakeStreamSocket
;
24 class P2PStreamSocket
;
26 class AuthenticatorTestBase
: public testing::Test
{
28 AuthenticatorTestBase();
29 ~AuthenticatorTestBase() override
;
32 class MockChannelDoneCallback
{
34 MockChannelDoneCallback();
35 ~MockChannelDoneCallback();
36 MOCK_METHOD1(OnDone
, void(int error
));
39 static void ContinueAuthExchangeWith(Authenticator
* sender
,
40 Authenticator
* receiver
,
42 bool receiver_srated
);
43 void SetUp() override
;
44 void RunAuthExchange();
45 void RunHostInitiatedAuthExchange();
46 void RunChannelAuth(bool expected_fail
);
48 void OnHostConnected(int error
,
49 scoped_ptr
<P2PStreamSocket
> socket
);
50 void OnClientConnected(int error
,
51 scoped_ptr
<P2PStreamSocket
> socket
);
53 base::MessageLoop message_loop_
;
55 scoped_refptr
<RsaKeyPair
> key_pair_
;
56 std::string host_public_key_
;
57 std::string host_cert_
;
58 scoped_ptr
<Authenticator
> host_
;
59 scoped_ptr
<Authenticator
> client_
;
60 scoped_ptr
<FakeStreamSocket
> client_fake_socket_
;
61 scoped_ptr
<FakeStreamSocket
> host_fake_socket_
;
62 scoped_ptr
<ChannelAuthenticator
> client_auth_
;
63 scoped_ptr
<ChannelAuthenticator
> host_auth_
;
64 MockChannelDoneCallback client_callback_
;
65 MockChannelDoneCallback host_callback_
;
66 scoped_ptr
<P2PStreamSocket
> client_socket_
;
67 scoped_ptr
<P2PStreamSocket
> host_socket_
;
69 DISALLOW_COPY_AND_ASSIGN(AuthenticatorTestBase
);
72 } // namespace protocol
73 } // namespace remoting
75 #endif // REMOTING_PROTOCOL_AUTHENTICATOR_TEST_BASE_H_