| OLD | NEW |
| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/timer/mock_timer.h" | 10 #include "base/timer/mock_timer.h" |
| 11 #include "components/proximity_auth/connection.h" | 11 #include "components/proximity_auth/connection.h" |
| 12 #include "components/proximity_auth/cryptauth/base64url.h" | 12 #include "components/proximity_auth/cryptauth/base64url.h" |
| 13 #include "components/proximity_auth/cryptauth/fake_secure_message_delegate.h" | 13 #include "components/proximity_auth/cryptauth/fake_secure_message_delegate.h" |
| 14 #include "components/proximity_auth/device_to_device_responder_operations.h" | 14 #include "components/proximity_auth/device_to_device_responder_operations.h" |
| 15 #include "components/proximity_auth/secure_context.h" | 15 #include "components/proximity_auth/secure_context.h" |
| 16 #include "components/proximity_auth/wire_message.h" | 16 #include "components/proximity_auth/wire_message.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 namespace proximity_auth { | 20 namespace proximity_auth { |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 // The account id of the user. | 24 // The account id of the user. |
| 25 const char kAccountId[] = "example@gmail.com"; | 25 const char kAccountId[] = "example@gmail.com"; |
| 26 | 26 |
| 27 // Attributes of the connected remote device. | 27 // Attributes of the connected remote device. |
| 28 const char kRemoteDeviceUserId[] = "example@gmail.com"; |
| 28 const char kRemoteDeviceName[] = "iPhone 6"; | 29 const char kRemoteDeviceName[] = "iPhone 6"; |
| 29 const char kRemoteDevicePublicKey[] = "remote public key"; | 30 const char kRemoteDevicePublicKey[] = "remote public key"; |
| 30 const char kRemoteDeviceBluetoothAddress[] = "AA:BB:CC:DD:EE:FF"; | 31 const char kRemoteDeviceBluetoothAddress[] = "AA:BB:CC:DD:EE:FF"; |
| 31 const char kRemoteDevicePersistentSymmetricKey[] = "PSK"; | 32 const char kRemoteDevicePersistentSymmetricKey[] = "PSK"; |
| 32 | 33 |
| 33 // The initiator's session public key in base64url form. Note that this is | 34 // The initiator's session public key in base64url form. Note that this is |
| 34 // actually a serialized proto. | 35 // actually a serialized proto. |
| 35 const char kInitiatorSessionPublicKeyBase64[] = | 36 const char kInitiatorSessionPublicKeyBase64[] = |
| 36 "CAESRQogOlH8DgPMQu7eAt-b6yoTXcazG8mAl6SPC5Ds-LTULIcSIQDZDMqsoYRO4tNMej1FB" | 37 "CAESRQogOlH8DgPMQu7eAt-b6yoTXcazG8mAl6SPC5Ds-LTULIcSIQDZDMqsoYRO4tNMej1FB" |
| 37 "El1sTiTiVDqrcGq-CkYCzDThw=="; | 38 "El1sTiTiVDqrcGq-CkYCzDThw=="; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 base::MockTimer* timer_; | 132 base::MockTimer* timer_; |
| 132 | 133 |
| 133 DISALLOW_COPY_AND_ASSIGN(DeviceToDeviceAuthenticatorForTest); | 134 DISALLOW_COPY_AND_ASSIGN(DeviceToDeviceAuthenticatorForTest); |
| 134 }; | 135 }; |
| 135 | 136 |
| 136 } // namespace | 137 } // namespace |
| 137 | 138 |
| 138 class ProximityAuthDeviceToDeviceAuthenticatorTest : public testing::Test { | 139 class ProximityAuthDeviceToDeviceAuthenticatorTest : public testing::Test { |
| 139 public: | 140 public: |
| 140 ProximityAuthDeviceToDeviceAuthenticatorTest() | 141 ProximityAuthDeviceToDeviceAuthenticatorTest() |
| 141 : remote_device_(kRemoteDeviceName, | 142 : remote_device_(kRemoteDeviceUserId, |
| 143 kRemoteDeviceName, |
| 142 kRemoteDevicePublicKey, | 144 kRemoteDevicePublicKey, |
| 143 kRemoteDeviceBluetoothAddress, | 145 kRemoteDeviceBluetoothAddress, |
| 144 kRemoteDevicePersistentSymmetricKey), | 146 kRemoteDevicePersistentSymmetricKey), |
| 145 connection_(remote_device_), | 147 connection_(remote_device_), |
| 146 secure_message_delegate_(new FakeSecureMessageDelegate), | 148 secure_message_delegate_(new FakeSecureMessageDelegate), |
| 147 authenticator_(&connection_, | 149 authenticator_(&connection_, |
| 148 make_scoped_ptr(secure_message_delegate_)) {} | 150 make_scoped_ptr(secure_message_delegate_)) {} |
| 149 ~ProximityAuthDeviceToDeviceAuthenticatorTest() override {} | 151 ~ProximityAuthDeviceToDeviceAuthenticatorTest() override {} |
| 150 | 152 |
| 151 void SetUp() override { | 153 void SetUp() override { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 WireMessage wire_message(base::RandBytesAsString(300u)); | 344 WireMessage wire_message(base::RandBytesAsString(300u)); |
| 343 connection_.SendMessage( | 345 connection_.SendMessage( |
| 344 make_scoped_ptr(new WireMessage(base::RandBytesAsString(300u)))); | 346 make_scoped_ptr(new WireMessage(base::RandBytesAsString(300u)))); |
| 345 connection_.OnBytesReceived(wire_message.Serialize()); | 347 connection_.OnBytesReceived(wire_message.Serialize()); |
| 346 connection_.SendMessage( | 348 connection_.SendMessage( |
| 347 make_scoped_ptr(new WireMessage(base::RandBytesAsString(300u)))); | 349 make_scoped_ptr(new WireMessage(base::RandBytesAsString(300u)))); |
| 348 connection_.OnBytesReceived(wire_message.Serialize()); | 350 connection_.OnBytesReceived(wire_message.Serialize()); |
| 349 } | 351 } |
| 350 | 352 |
| 351 } // namespace proximity_auth | 353 } // namespace proximity_auth |
| OLD | NEW |