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/v2_authenticator.h" | 5 #include "remoting/protocol/v2_authenticator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "net/base/net_errors.h" | 8 #include "net/base/net_errors.h" |
9 #include "remoting/protocol/authenticator_test_base.h" | 9 #include "remoting/protocol/authenticator_test_base.h" |
10 #include "remoting/protocol/channel_authenticator.h" | 10 #include "remoting/protocol/channel_authenticator.h" |
11 #include "remoting/protocol/connection_tester.h" | 11 #include "remoting/protocol/connection_tester.h" |
| 12 #include "remoting/protocol/key_pair.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" | 15 #include "third_party/libjingle/source/talk/xmllite/xmlelement.h" |
15 | 16 |
16 using testing::_; | 17 using testing::_; |
17 using testing::DeleteArg; | 18 using testing::DeleteArg; |
18 using testing::SaveArg; | 19 using testing::SaveArg; |
19 | 20 |
20 namespace remoting { | 21 namespace remoting { |
21 namespace protocol { | 22 namespace protocol { |
(...skipping 12 matching lines...) Expand all Loading... |
34 public: | 35 public: |
35 V2AuthenticatorTest() { | 36 V2AuthenticatorTest() { |
36 } | 37 } |
37 virtual ~V2AuthenticatorTest() { | 38 virtual ~V2AuthenticatorTest() { |
38 } | 39 } |
39 | 40 |
40 protected: | 41 protected: |
41 void InitAuthenticators(const std::string& client_secret, | 42 void InitAuthenticators(const std::string& client_secret, |
42 const std::string& host_secret) { | 43 const std::string& host_secret) { |
43 host_ = V2Authenticator::CreateForHost( | 44 host_ = V2Authenticator::CreateForHost( |
44 host_cert_, *private_key_, host_secret, Authenticator::WAITING_MESSAGE); | 45 host_cert_, key_pair_->Copy(), host_secret, |
| 46 Authenticator::WAITING_MESSAGE); |
45 client_ = V2Authenticator::CreateForClient( | 47 client_ = V2Authenticator::CreateForClient( |
46 client_secret, Authenticator::MESSAGE_READY); | 48 client_secret, Authenticator::MESSAGE_READY); |
47 } | 49 } |
48 | 50 |
49 DISALLOW_COPY_AND_ASSIGN(V2AuthenticatorTest); | 51 DISALLOW_COPY_AND_ASSIGN(V2AuthenticatorTest); |
50 }; | 52 }; |
51 | 53 |
52 TEST_F(V2AuthenticatorTest, SuccessfulAuth) { | 54 TEST_F(V2AuthenticatorTest, SuccessfulAuth) { |
53 ASSERT_NO_FATAL_FAILURE( | 55 ASSERT_NO_FATAL_FAILURE( |
54 InitAuthenticators(kTestSharedSecret, kTestSharedSecret)); | 56 InitAuthenticators(kTestSharedSecret, kTestSharedSecret)); |
(...skipping 29 matching lines...) Expand all Loading... |
84 scoped_ptr<buzz::XmlElement> message(client_->GetNextMessage()); | 86 scoped_ptr<buzz::XmlElement> message(client_->GetNextMessage()); |
85 ASSERT_TRUE(message.get()); | 87 ASSERT_TRUE(message.get()); |
86 | 88 |
87 ASSERT_EQ(Authenticator::WAITING_MESSAGE, client_->state()); | 89 ASSERT_EQ(Authenticator::WAITING_MESSAGE, client_->state()); |
88 host_->ProcessMessage(message.get()); | 90 host_->ProcessMessage(message.get()); |
89 ASSERT_EQ(Authenticator::REJECTED, host_->state()); | 91 ASSERT_EQ(Authenticator::REJECTED, host_->state()); |
90 } | 92 } |
91 | 93 |
92 } // namespace protocol | 94 } // namespace protocol |
93 } // namespace remoting | 95 } // namespace remoting |
OLD | NEW |