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

Side by Side Diff: components/proximity_auth/device_to_device_authenticator_unittest.cc

Issue 2502343003: Moved //components/proximity_auth/cryptauth to //components/cryptauth. (Closed)
Patch Set: Fixed proto #includes. Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/proximity_auth/device_to_device_authenticator.h" 5 #include "components/proximity_auth/device_to_device_authenticator.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/base64url.h" 9 #include "base/base64url.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/memory/scoped_vector.h" 13 #include "base/memory/scoped_vector.h"
14 #include "base/rand_util.h" 14 #include "base/rand_util.h"
15 #include "base/timer/mock_timer.h" 15 #include "base/timer/mock_timer.h"
16 #include "components/cryptauth/fake_secure_message_delegate.h"
16 #include "components/proximity_auth/connection.h" 17 #include "components/proximity_auth/connection.h"
17 #include "components/proximity_auth/cryptauth/fake_secure_message_delegate.h"
18 #include "components/proximity_auth/device_to_device_responder_operations.h" 18 #include "components/proximity_auth/device_to_device_responder_operations.h"
19 #include "components/proximity_auth/proximity_auth_test_util.h" 19 #include "components/proximity_auth/proximity_auth_test_util.h"
20 #include "components/proximity_auth/secure_context.h" 20 #include "components/proximity_auth/secure_context.h"
21 #include "components/proximity_auth/wire_message.h" 21 #include "components/proximity_auth/wire_message.h"
22 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 namespace proximity_auth { 25 namespace proximity_auth {
26 26
27 namespace { 27 namespace {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool connection_blocked_; 97 bool connection_blocked_;
98 98
99 DISALLOW_COPY_AND_ASSIGN(FakeConnection); 99 DISALLOW_COPY_AND_ASSIGN(FakeConnection);
100 }; 100 };
101 101
102 // Harness for testing DeviceToDeviceAuthenticator. 102 // Harness for testing DeviceToDeviceAuthenticator.
103 class DeviceToDeviceAuthenticatorForTest : public DeviceToDeviceAuthenticator { 103 class DeviceToDeviceAuthenticatorForTest : public DeviceToDeviceAuthenticator {
104 public: 104 public:
105 DeviceToDeviceAuthenticatorForTest( 105 DeviceToDeviceAuthenticatorForTest(
106 Connection* connection, 106 Connection* connection,
107 std::unique_ptr<SecureMessageDelegate> secure_message_delegate) 107 std::unique_ptr<cryptauth::SecureMessageDelegate> secure_message_delegate)
108 : DeviceToDeviceAuthenticator(connection, 108 : DeviceToDeviceAuthenticator(connection,
109 kAccountId, 109 kAccountId,
110 std::move(secure_message_delegate)), 110 std::move(secure_message_delegate)),
111 timer_(nullptr) {} 111 timer_(nullptr) {}
112 ~DeviceToDeviceAuthenticatorForTest() override {} 112 ~DeviceToDeviceAuthenticatorForTest() override {}
113 113
114 base::MockTimer* timer() { return timer_; } 114 base::MockTimer* timer() { return timer_; }
115 115
116 private: 116 private:
117 // DeviceToDeviceAuthenticator: 117 // DeviceToDeviceAuthenticator:
(...skipping 14 matching lines...) Expand all
132 DISALLOW_COPY_AND_ASSIGN(DeviceToDeviceAuthenticatorForTest); 132 DISALLOW_COPY_AND_ASSIGN(DeviceToDeviceAuthenticatorForTest);
133 }; 133 };
134 134
135 } // namespace 135 } // namespace
136 136
137 class ProximityAuthDeviceToDeviceAuthenticatorTest : public testing::Test { 137 class ProximityAuthDeviceToDeviceAuthenticatorTest : public testing::Test {
138 public: 138 public:
139 ProximityAuthDeviceToDeviceAuthenticatorTest() 139 ProximityAuthDeviceToDeviceAuthenticatorTest()
140 : remote_device_(CreateClassicRemoteDeviceForTest()), 140 : remote_device_(CreateClassicRemoteDeviceForTest()),
141 connection_(remote_device_), 141 connection_(remote_device_),
142 secure_message_delegate_(new FakeSecureMessageDelegate), 142 secure_message_delegate_(new cryptauth::FakeSecureMessageDelegate),
143 authenticator_(&connection_, 143 authenticator_(&connection_,
144 base::WrapUnique(secure_message_delegate_)) {} 144 base::WrapUnique(secure_message_delegate_)) {}
145 ~ProximityAuthDeviceToDeviceAuthenticatorTest() override {} 145 ~ProximityAuthDeviceToDeviceAuthenticatorTest() override {}
146 146
147 void SetUp() override { 147 void SetUp() override {
148 // Set up the session asymmetric keys for both the local and remote devices. 148 // Set up the session asymmetric keys for both the local and remote devices.
149 ASSERT_TRUE( 149 ASSERT_TRUE(
150 base::Base64UrlDecode(kInitiatorSessionPublicKeyBase64, 150 base::Base64UrlDecode(kInitiatorSessionPublicKeyBase64,
151 base::Base64UrlDecodePolicy::REQUIRE_PADDING, 151 base::Base64UrlDecodePolicy::REQUIRE_PADDING,
152 &local_session_public_key_)); 152 &local_session_public_key_));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 MOCK_METHOD1(OnAuthenticationResultProxy, void(Authenticator::Result result)); 222 MOCK_METHOD1(OnAuthenticationResultProxy, void(Authenticator::Result result));
223 223
224 // Contains information about the remote device. 224 // Contains information about the remote device.
225 const RemoteDevice remote_device_; 225 const RemoteDevice remote_device_;
226 226
227 // Simulates the connection to the remote device. 227 // Simulates the connection to the remote device.
228 FakeConnection connection_; 228 FakeConnection connection_;
229 229
230 // The SecureMessageDelegate used by the authenticator. 230 // The SecureMessageDelegate used by the authenticator.
231 // Owned by |authenticator_|. 231 // Owned by |authenticator_|.
232 FakeSecureMessageDelegate* secure_message_delegate_; 232 cryptauth::FakeSecureMessageDelegate* secure_message_delegate_;
233 233
234 // The DeviceToDeviceAuthenticator under test. 234 // The DeviceToDeviceAuthenticator under test.
235 DeviceToDeviceAuthenticatorForTest authenticator_; 235 DeviceToDeviceAuthenticatorForTest authenticator_;
236 236
237 // The session keys in play during authentication. 237 // The session keys in play during authentication.
238 std::string local_session_public_key_; 238 std::string local_session_public_key_;
239 std::string remote_session_public_key_; 239 std::string remote_session_public_key_;
240 std::string remote_session_private_key_; 240 std::string remote_session_private_key_;
241 std::string session_symmetric_key_; 241 std::string session_symmetric_key_;
242 242
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 WireMessage wire_message(base::RandBytesAsString(300u)); 342 WireMessage wire_message(base::RandBytesAsString(300u));
343 connection_.SendMessage( 343 connection_.SendMessage(
344 base::MakeUnique<WireMessage>(base::RandBytesAsString(300u))); 344 base::MakeUnique<WireMessage>(base::RandBytesAsString(300u)));
345 connection_.OnBytesReceived(wire_message.Serialize()); 345 connection_.OnBytesReceived(wire_message.Serialize());
346 connection_.SendMessage( 346 connection_.SendMessage(
347 base::MakeUnique<WireMessage>(base::RandBytesAsString(300u))); 347 base::MakeUnique<WireMessage>(base::RandBytesAsString(300u)));
348 connection_.OnBytesReceived(wire_message.Serialize()); 348 connection_.OnBytesReceived(wire_message.Serialize());
349 } 349 }
350 350
351 } // namespace proximity_auth 351 } // namespace proximity_auth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698