summaryrefslogtreecommitdiffstats
path: root/components/proximity_auth
diff options
context:
space:
mode:
authortengs <tengs@chromium.org>2015-07-22 10:43:19 -0700
committerCommit bot <commit-bot@chromium.org>2015-07-22 17:43:45 +0000
commit2ae24cbb93377a9c69e5e0fa3a1f52e0cefb38d7 (patch)
treee349f35ce2021d9a0b576c3d1ad7232e2437e1c7 /components/proximity_auth
parent38dd87acb3c43fdd856baab8855f187c3b231da2 (diff)
downloadchromium_src-2ae24cbb93377a9c69e5e0fa3a1f52e0cefb38d7.zip
chromium_src-2ae24cbb93377a9c69e5e0fa3a1f52e0cefb38d7.tar.gz
chromium_src-2ae24cbb93377a9c69e5e0fa3a1f52e0cefb38d7.tar.bz2
Add |public_key| and |persistent_symmetric_key| fields to RemoteDevice.
Due to the Chromium style checker, we need to add an explicit constructor and destructor to the RemoteDevice struct. BUG=508761 Review URL: https://codereview.chromium.org/1224283004 Cr-Commit-Position: refs/heads/master@{#339907}
Diffstat (limited to 'components/proximity_auth')
-rw-r--r--components/proximity_auth/BUILD.gn1
-rw-r--r--components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc10
-rw-r--r--components/proximity_auth/ble/bluetooth_low_energy_connection_unittest.cc7
-rw-r--r--components/proximity_auth/bluetooth_connection_finder_unittest.cc15
-rw-r--r--components/proximity_auth/bluetooth_connection_unittest.cc13
-rw-r--r--components/proximity_auth/proximity_auth_system.h2
-rw-r--r--components/proximity_auth/proximity_auth_system_unittest.cc6
-rw-r--r--components/proximity_auth/proximity_monitor_impl_unittest.cc14
-rw-r--r--components/proximity_auth/remote_device.cc22
-rw-r--r--components/proximity_auth/remote_device.h11
10 files changed, 85 insertions, 16 deletions
diff --git a/components/proximity_auth/BUILD.gn b/components/proximity_auth/BUILD.gn
index 3f26253..d5defb3 100644
--- a/components/proximity_auth/BUILD.gn
+++ b/components/proximity_auth/BUILD.gn
@@ -33,6 +33,7 @@ source_set("proximity_auth") {
"proximity_monitor_impl.cc",
"proximity_monitor_impl.h",
"proximity_monitor_observer.h",
+ "remote_device.cc",
"remote_device.h",
"remote_status_update.cc",
"remote_status_update.h",
diff --git a/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc b/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc
index 71448b0..d685e6f 100644
--- a/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc
+++ b/components/proximity_auth/ble/bluetooth_low_energy_connection_finder_unittest.cc
@@ -36,8 +36,9 @@ namespace proximity_auth {
namespace {
const char kDeviceName[] = "Device name";
+const char kPublicKey[] = "Public key";
const char kBluetoothAddress[] = "11:22:33:44:55:66";
-const RemoteDevice kRemoteDevice = {kDeviceName, kBluetoothAddress};
+const char kPersistentSymmetricKey[] = "PSK";
const char kServiceUUID[] = "DEADBEEF-CAFE-FEED-FOOD-D15EA5EBEEEF";
const char kToPeripheralCharUUID[] = "FBAE09F2-0482-11E5-8418-1697F925EC7B";
@@ -50,7 +51,7 @@ const int kMaxNumberOfAttempts = 2;
class MockConnection : public Connection {
public:
- MockConnection() : Connection(kRemoteDevice) {}
+ MockConnection() : Connection(CreateRemoteDevice()) {}
~MockConnection() override {}
MOCK_METHOD0(Connect, void());
@@ -61,6 +62,11 @@ class MockConnection : public Connection {
void Disconnect() override {}
void SendMessageImpl(scoped_ptr<WireMessage> message) override {}
+ RemoteDevice CreateRemoteDevice() {
+ return RemoteDevice(kDeviceName, kPublicKey, kBluetoothAddress,
+ kPersistentSymmetricKey);
+ }
+
DISALLOW_COPY_AND_ASSIGN(MockConnection);
};
diff --git a/components/proximity_auth/ble/bluetooth_low_energy_connection_unittest.cc b/components/proximity_auth/ble/bluetooth_low_energy_connection_unittest.cc
index 87b013a..2e550c9 100644
--- a/components/proximity_auth/ble/bluetooth_low_energy_connection_unittest.cc
+++ b/components/proximity_auth/ble/bluetooth_low_energy_connection_unittest.cc
@@ -34,7 +34,9 @@ namespace proximity_auth {
namespace {
const char kDeviceName[] = "Device name";
+const char kPublicKey[] = "Public key";
const char kBluetoothAddress[] = "11:22:33:44:55:66";
+const char kPersistentSymmetricKey[] = "PSK";
const char kServiceUUID[] = "DEADBEEF-CAFE-FEED-FOOD-D15EA5EBEEEF";
const char kToPeripheralCharUUID[] = "FBAE09F2-0482-11E5-8418-1697F925EC7B";
@@ -105,7 +107,10 @@ class ProximityAuthBluetoothLowEnergyConnectionTest : public testing::Test {
public:
ProximityAuthBluetoothLowEnergyConnectionTest()
: adapter_(new NiceMock<device::MockBluetoothAdapter>),
- remote_device_({kDeviceName, kBluetoothAddress}),
+ remote_device_(kDeviceName,
+ kPublicKey,
+ kBluetoothAddress,
+ kPersistentSymmetricKey),
service_uuid_(device::BluetoothUUID(kServiceUUID)),
to_peripheral_char_uuid_(device::BluetoothUUID(kToPeripheralCharUUID)),
from_peripheral_char_uuid_(
diff --git a/components/proximity_auth/bluetooth_connection_finder_unittest.cc b/components/proximity_auth/bluetooth_connection_finder_unittest.cc
index 29561e8..ac6b38c 100644
--- a/components/proximity_auth/bluetooth_connection_finder_unittest.cc
+++ b/components/proximity_auth/bluetooth_connection_finder_unittest.cc
@@ -27,14 +27,20 @@ namespace proximity_auth {
namespace {
const char kDeviceName[] = "Device name";
+const char kPublicKey[] = "Public key";
const char kBluetoothAddress[] = "11:22:33:44:55:66";
-const RemoteDevice kRemoteDevice = {kDeviceName, kBluetoothAddress};
+const char kPersistentSymmetricKey[] = "PSK";
const char kUuid[] = "DEADBEEF-CAFE-FEED-FOOD-D15EA5EBEEF";
+RemoteDevice CreateRemoteDevice() {
+ return RemoteDevice(kDeviceName, kPublicKey, kBluetoothAddress,
+ kPersistentSymmetricKey);
+}
+
class MockConnection : public Connection {
public:
- MockConnection() : Connection(kRemoteDevice) {}
+ MockConnection() : Connection(CreateRemoteDevice()) {}
~MockConnection() override {}
MOCK_METHOD0(Connect, void());
@@ -51,7 +57,7 @@ class MockConnection : public Connection {
class MockBluetoothConnectionFinder : public BluetoothConnectionFinder {
public:
MockBluetoothConnectionFinder()
- : BluetoothConnectionFinder(kRemoteDevice,
+ : BluetoothConnectionFinder(CreateRemoteDevice(),
device::BluetoothUUID(kUuid),
base::TimeDelta()) {}
~MockBluetoothConnectionFinder() override {}
@@ -121,8 +127,7 @@ TEST_F(ProximityAuthBluetoothConnectionFinderTest,
// Destroying a BluetoothConnectionFinder for which Find() has not been called
// should not crash.
BluetoothConnectionFinder connection_finder(
- kRemoteDevice,
- device::BluetoothUUID(kUuid),
+ CreateRemoteDevice(), device::BluetoothUUID(kUuid),
base::TimeDelta::FromMilliseconds(1));
}
diff --git a/components/proximity_auth/bluetooth_connection_unittest.cc b/components/proximity_auth/bluetooth_connection_unittest.cc
index 129d439..fb007ba 100644
--- a/components/proximity_auth/bluetooth_connection_unittest.cc
+++ b/components/proximity_auth/bluetooth_connection_unittest.cc
@@ -35,13 +35,14 @@ const char kOtherDeviceName[] = "Other device name";
const char kBluetoothAddress[] = "11:22:33:44:55:66";
const char kOtherBluetoothAddress[] = "AA:BB:CC:DD:EE:FF";
+const char kPublicKey[] = "Public key";
+const char kPersistentSymmetricKey[] = "PSK";
+
const char kSerializedMessage[] = "Yarrr, this be a serialized message. Yarr!";
const int kSerializedMessageLength = strlen(kSerializedMessage);
const char kUuid[] = "DEADBEEF-CAFE-FEED-FOOD-D15EA5EBEEF";
-const RemoteDevice kRemoteDevice = {kDeviceName, kBluetoothAddress};
-
const int kReceiveBufferSize = 6;
const char kReceiveBufferContents[] = "bytes";
@@ -55,7 +56,8 @@ scoped_refptr<net::IOBuffer> CreateReceiveBuffer() {
class MockBluetoothConnection : public BluetoothConnection {
public:
MockBluetoothConnection()
- : BluetoothConnection(kRemoteDevice, device::BluetoothUUID(kUuid)) {}
+ : BluetoothConnection(CreateRemoteDevice(),
+ device::BluetoothUUID(kUuid)) {}
// Calls back into the parent Connection class.
MOCK_METHOD1(SetStatusProxy, void(Status status));
@@ -74,6 +76,11 @@ class MockBluetoothConnection : public BluetoothConnection {
using BluetoothConnection::Disconnect;
private:
+ RemoteDevice CreateRemoteDevice() {
+ return RemoteDevice(kDeviceName, kPublicKey, kBluetoothAddress,
+ kPersistentSymmetricKey);
+ }
+
DISALLOW_COPY_AND_ASSIGN(MockBluetoothConnection);
};
diff --git a/components/proximity_auth/proximity_auth_system.h b/components/proximity_auth/proximity_auth_system.h
index 1cef1cd..644d65d 100644
--- a/components/proximity_auth/proximity_auth_system.h
+++ b/components/proximity_auth/proximity_auth_system.h
@@ -5,6 +5,8 @@
#ifndef COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H
#define COMPONENTS_PROXIMITY_AUTH_PROXIMITY_AUTH_SYSTEM_H
+#include <vector>
+
#include "base/macros.h"
#include "components/proximity_auth/remote_device.h"
diff --git a/components/proximity_auth/proximity_auth_system_unittest.cc b/components/proximity_auth/proximity_auth_system_unittest.cc
index 2184d87..45d17db 100644
--- a/components/proximity_auth/proximity_auth_system_unittest.cc
+++ b/components/proximity_auth/proximity_auth_system_unittest.cc
@@ -9,8 +9,8 @@
namespace proximity_auth {
TEST(ProximityAuthSystemTest, GetRemoteDevices) {
- RemoteDevice device1 = {"device 1"};
- RemoteDevice device2 = {"device 2"};
+ RemoteDevice device1("device1", "public_key1", "bt_addr1", "psk1");
+ RemoteDevice device2("device2", "public_key2", "bt_addr2", "psk2");
std::vector<RemoteDevice> device_list;
device_list.push_back(device1);
@@ -21,7 +21,9 @@ TEST(ProximityAuthSystemTest, GetRemoteDevices) {
const std::vector<RemoteDevice>& returned_list = system.GetRemoteDevices();
ASSERT_EQ(2u, returned_list.size());
EXPECT_EQ(device1.name, returned_list[0].name);
+ EXPECT_EQ(device1.public_key, returned_list[0].public_key);
EXPECT_EQ(device2.name, returned_list[1].name);
+ EXPECT_EQ(device2.public_key, returned_list[1].public_key);
}
} // namespace proximity_auth
diff --git a/components/proximity_auth/proximity_monitor_impl_unittest.cc b/components/proximity_auth/proximity_monitor_impl_unittest.cc
index 660f4a3..4231934 100644
--- a/components/proximity_auth/proximity_monitor_impl_unittest.cc
+++ b/components/proximity_auth/proximity_monitor_impl_unittest.cc
@@ -31,7 +31,9 @@ namespace proximity_auth {
namespace {
const char kBluetoothAddress[] = "AA:BB:CC:DD:EE:FF";
+const char kRemoteDevicePublicKey[] = "Remote Public Key";
const char kRemoteDeviceName[] = "LGE Nexus 5";
+const char kPersistentSymmetricKey[] = "PSK";
class TestProximityMonitorImpl : public ProximityMonitorImpl {
public:
@@ -81,7 +83,10 @@ class ProximityAuthProximityMonitorImplTest : public testing::Test {
kBluetoothAddress,
false /* paired */,
true /* connected */),
- monitor_({kRemoteDeviceName, kBluetoothAddress},
+ monitor_(RemoteDevice(kRemoteDeviceName,
+ kRemoteDevicePublicKey,
+ kBluetoothAddress,
+ kPersistentSymmetricKey),
make_scoped_ptr(clock_),
&observer_),
task_runner_(new base::TestSimpleTaskRunner()),
@@ -528,7 +533,12 @@ TEST_F(ProximityAuthProximityMonitorImplTest,
TEST_F(ProximityAuthProximityMonitorImplTest,
RecordProximityMetricsOnAuthSuccess_UnknownValues) {
- RemoteDevice unnamed_remote_device = {kBluetoothAddress, kBluetoothAddress};
+ // Note: A device without a recorded name will have its Bluetooth address as
+ // its name.
+ RemoteDevice unnamed_remote_device(kBluetoothAddress, kRemoteDevicePublicKey,
+ kBluetoothAddress,
+ kPersistentSymmetricKey);
+
scoped_ptr<base::TickClock> clock(new base::SimpleTestTickClock());
ProximityMonitorImpl monitor(unnamed_remote_device, clock.Pass(), &observer_);
monitor.Start();
diff --git a/components/proximity_auth/remote_device.cc b/components/proximity_auth/remote_device.cc
new file mode 100644
index 0000000..378c2df
--- /dev/null
+++ b/components/proximity_auth/remote_device.cc
@@ -0,0 +1,22 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/proximity_auth/remote_device.h"
+
+namespace proximity_auth {
+
+RemoteDevice::RemoteDevice() {}
+
+RemoteDevice::RemoteDevice(const std::string& name,
+ const std::string& public_key,
+ const std::string& bluetooth_address,
+ const std::string& persistent_symmetric_key)
+ : name(name),
+ public_key(public_key),
+ bluetooth_address(bluetooth_address),
+ persistent_symmetric_key(persistent_symmetric_key) {}
+
+RemoteDevice::~RemoteDevice() {}
+
+} // namespace
diff --git a/components/proximity_auth/remote_device.h b/components/proximity_auth/remote_device.h
index b36c616..582f2f7 100644
--- a/components/proximity_auth/remote_device.h
+++ b/components/proximity_auth/remote_device.h
@@ -6,13 +6,22 @@
#define COMPONENTS_PROXIMITY_AUTH_REMOTE_DEVICE_H
#include <string>
-#include <vector>
namespace proximity_auth {
struct RemoteDevice {
+ public:
std::string name;
+ std::string public_key;
std::string bluetooth_address;
+ std::string persistent_symmetric_key;
+
+ RemoteDevice();
+ RemoteDevice(const std::string& name,
+ const std::string& public_key,
+ const std::string& bluetooth_address,
+ const std::string& persistent_symmetric_key);
+ ~RemoteDevice();
};
} // namespace proximity_auth