Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: remoting/protocol/spake2_authenticator_unittest.cc

Issue 1778223003: Revert of Implement authenticator based on SPAKE2 implementation in boringssl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « remoting/protocol/spake2_authenticator.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #include "remoting/protocol/spake2_authenticator.h"
6
7 #include "base/bind.h"
8 #include "base/macros.h"
9 #include "remoting/base/rsa_key_pair.h"
10 #include "remoting/protocol/authenticator_test_base.h"
11 #include "remoting/protocol/channel_authenticator.h"
12 #include "remoting/protocol/connection_tester.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h"
16
17 using testing::_;
18 using testing::DeleteArg;
19 using testing::SaveArg;
20
21 namespace remoting {
22 namespace protocol {
23
24 namespace {
25
26 const int kMessageSize = 100;
27 const int kMessages = 1;
28
29 const char kClientId[] = "alice@gmail.com/abc";
30 const char kHostId[] = "alice@gmail.com/123";
31
32 const char kTestSharedSecret[] = "1234-1234-5678";
33 const char kTestSharedSecretBad[] = "0000-0000-0001";
34
35 } // namespace
36
37 class Spake2AuthenticatorTest : public AuthenticatorTestBase {
38 public:
39 Spake2AuthenticatorTest() {}
40 ~Spake2AuthenticatorTest() override {}
41
42 protected:
43 void InitAuthenticators(const std::string& client_secret,
44 const std::string& host_secret) {
45 host_ = Spake2Authenticator::CreateForHost(kHostId, kClientId, host_secret,
46 host_cert_, key_pair_,
47 Authenticator::WAITING_MESSAGE);
48 client_ = Spake2Authenticator::CreateForClient(
49 kClientId, kHostId, client_secret, Authenticator::MESSAGE_READY);
50 }
51
52 DISALLOW_COPY_AND_ASSIGN(Spake2AuthenticatorTest);
53 };
54
55 TEST_F(Spake2AuthenticatorTest, SuccessfulAuth) {
56 ASSERT_NO_FATAL_FAILURE(
57 InitAuthenticators(kTestSharedSecret, kTestSharedSecret));
58 ASSERT_NO_FATAL_FAILURE(RunAuthExchange());
59
60 ASSERT_EQ(Authenticator::ACCEPTED, host_->state());
61 ASSERT_EQ(Authenticator::ACCEPTED, client_->state());
62
63 client_auth_ = client_->CreateChannelAuthenticator();
64 host_auth_ = host_->CreateChannelAuthenticator();
65 RunChannelAuth(false);
66
67 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
68 kMessageSize, kMessages);
69
70 tester.Start();
71 message_loop_.Run();
72 tester.CheckResults();
73 }
74
75 // Verify that connection is rejected when secrets don't match.
76 TEST_F(Spake2AuthenticatorTest, InvalidSecret) {
77 ASSERT_NO_FATAL_FAILURE(
78 InitAuthenticators(kTestSharedSecretBad, kTestSharedSecret));
79 ASSERT_NO_FATAL_FAILURE(RunAuthExchange());
80
81 ASSERT_EQ(Authenticator::REJECTED, client_->state());
82 ASSERT_EQ(Authenticator::INVALID_CREDENTIALS, client_->rejection_reason());
83
84 // Change |client_| so that we can get the last message.
85 reinterpret_cast<Spake2Authenticator*>(client_.get())->state_ =
86 Authenticator::MESSAGE_READY;
87
88 scoped_ptr<buzz::XmlElement> message(client_->GetNextMessage());
89 ASSERT_TRUE(message.get());
90
91 ASSERT_EQ(Authenticator::WAITING_MESSAGE, client_->state());
92 host_->ProcessMessage(message.get(), base::Bind(&base::DoNothing));
93 // This assumes that Spake2Authenticator::ProcessMessage runs synchronously.
94 ASSERT_EQ(Authenticator::REJECTED, host_->state());
95 }
96
97 } // namespace protocol
98 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/spake2_authenticator.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698