diff options
author | isherman <isherman@chromium.org> | 2015-06-25 11:46:52 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-25 18:48:31 +0000 |
commit | 27661ed66f7f5790f6bda0f08d6ef0b7c7dcf8ff (patch) | |
tree | 541b986e00eabdea374b11b3b9bea1c7cc67d049 /components/proximity_auth | |
parent | c03c1b6f2e84d8d43d5573a3fa25ba65d536311b (diff) | |
download | chromium_src-27661ed66f7f5790f6bda0f08d6ef0b7c7dcf8ff.zip chromium_src-27661ed66f7f5790f6bda0f08d6ef0b7c7dcf8ff.tar.gz chromium_src-27661ed66f7f5790f6bda0f08d6ef0b7c7dcf8ff.tar.bz2 |
[Proximity Auth] Split the Client class an interface + concrete impl.
Among other things, this allows the class to be more easily mocked out in tests.
BUG=501626
TEST=none
R=tengs@chromium.org
Review URL: https://codereview.chromium.org/1205193003
Cr-Commit-Position: refs/heads/master@{#336212}
Diffstat (limited to 'components/proximity_auth')
-rw-r--r-- | components/proximity_auth/BUILD.gn | 5 | ||||
-rw-r--r-- | components/proximity_auth/client.h | 100 | ||||
-rw-r--r-- | components/proximity_auth/client_impl.cc (renamed from components/proximity_auth/client.cc) | 65 | ||||
-rw-r--r-- | components/proximity_auth/client_impl.h | 112 | ||||
-rw-r--r-- | components/proximity_auth/client_impl_unittest.cc (renamed from components/proximity_auth/client_unittest.cc) | 69 |
5 files changed, 191 insertions, 160 deletions
diff --git a/components/proximity_auth/BUILD.gn b/components/proximity_auth/BUILD.gn index 1d5ba24..3f26253 100644 --- a/components/proximity_auth/BUILD.gn +++ b/components/proximity_auth/BUILD.gn @@ -16,8 +16,9 @@ source_set("proximity_auth") { "bluetooth_util.cc", "bluetooth_util.h", "bluetooth_util_chromeos.cc", - "client.cc", "client.h", + "client_impl.cc", + "client_impl.h", "client_observer.h", "connection.cc", "connection.h", @@ -61,7 +62,7 @@ source_set("unit_tests") { "bluetooth_connection_finder_unittest.cc", "bluetooth_connection_unittest.cc", "bluetooth_throttler_impl_unittest.cc", - "client_unittest.cc", + "client_impl_unittest.cc", "connection_unittest.cc", "proximity_auth_system_unittest.cc", "proximity_monitor_impl_unittest.cc", diff --git a/components/proximity_auth/client.h b/components/proximity_auth/client.h index 269c672..c3526fc 100644 --- a/components/proximity_auth/client.h +++ b/components/proximity_auth/client.h @@ -5,119 +5,35 @@ #ifndef COMPONENTS_PROXIMITY_AUTH_CLIENT_H #define COMPONENTS_PROXIMITY_AUTH_CLIENT_H -#include <deque> - -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" -#include "base/observer_list.h" -#include "components/proximity_auth/connection_observer.h" - -namespace base { -class DictionaryValue; -} - namespace proximity_auth { class ClientObserver; -class Connection; -class SecureContext; // A client handling the Easy Unlock protocol, capable of parsing events from // the remote device and sending events for the local device. -class Client : public ConnectionObserver { +class Client { public: - // Constructs a client that sends and receives messages over the given - // |connection|, using the |secure_context| to encrypt and decrypt the - // messages. The |connection| must be connected. The client begins observing - // messages as soon as it is constructed. - Client(scoped_ptr<Connection> connection, - scoped_ptr<SecureContext> secure_context); - virtual ~Client(); + virtual ~Client() {} // Adds or removes an observer for Client events. - void AddObserver(ClientObserver* observer); - void RemoveObserver(ClientObserver* observer); + virtual void AddObserver(ClientObserver* observer) = 0; + virtual void RemoveObserver(ClientObserver* observer) = 0; // Returns true iff the remote device supports the v3.1 sign-in protocol. - bool SupportsSignIn() const; + virtual bool SupportsSignIn() const = 0; // Sends an unlock event message to the remote device. - void DispatchUnlockEvent(); + virtual void DispatchUnlockEvent() = 0; // Sends a serialized SecureMessage to the remote device to decrypt the // |challenge|. OnDecryptResponse will be called for each observer when the // decrypted response is received. // TODO(isherman): Add params for the RSA private key and crypto delegate. - void RequestDecryption(const std::string& challenge); + virtual void RequestDecryption(const std::string& challenge) = 0; // Sends a simple request to the remote device to unlock the screen. // OnUnlockResponse is called for each observer when the response is returned. - void RequestUnlock(); - - protected: - // Exposed for testing. - Connection* connection() { return connection_.get(); } - SecureContext* secure_context() { return secure_context_.get(); } - - private: - // Internal data structure to represent a pending message that either hasn't - // been sent yet or is waiting for a response from the remote device. - struct PendingMessage { - PendingMessage(); - PendingMessage(const base::DictionaryValue& message); - ~PendingMessage(); - - // The message, serialized as JSON. - const std::string json_message; - - // The message type. This is possible to parse from the |json_message|; it's - // stored redundantly for convenience. - const std::string type; - }; - - // Pops the first of the |queued_messages_| and sends it to the remote device. - void ProcessMessageQueue(); - - // Handles an incoming "status_update" |message|, parsing and notifying - // observers of the content. - void HandleRemoteStatusUpdateMessage(const base::DictionaryValue& message); - - // Handles an incoming "decrypt_response" message, parsing and notifying - // observers of the decrypted content. - void HandleDecryptResponseMessage(const base::DictionaryValue& message); - - // Handles an incoming "unlock_response" message, notifying observers of the - // response. - void HandleUnlockResponseMessage(const base::DictionaryValue& message); - - // ConnectionObserver: - void OnConnectionStatusChanged(Connection* connection, - Connection::Status old_status, - Connection::Status new_status) override; - void OnMessageReceived(const Connection& connection, - const WireMessage& wire_message) override; - void OnSendCompleted(const Connection& connection, - const WireMessage& wire_message, - bool success) override; - - // The connection used to send and receive events and status updates. - scoped_ptr<Connection> connection_; - - // Used to encrypt and decrypt payloads sent and received over the - // |connection_|. - scoped_ptr<SecureContext> secure_context_; - - // The registered observers of |this_| client. - base::ObserverList<ClientObserver> observers_; - - // Queue of messages to send to the remote device. - std::deque<PendingMessage> queued_messages_; - - // The current message being sent or waiting on the remote device for a - // response. Null if there is no message currently in this state. - scoped_ptr<PendingMessage> pending_message_; - - DISALLOW_COPY_AND_ASSIGN(Client); + virtual void RequestUnlock() = 0; }; } // namespace proximity_auth diff --git a/components/proximity_auth/client.cc b/components/proximity_auth/client_impl.cc index 3a03388..fc7d6e4b 100644 --- a/components/proximity_auth/client.cc +++ b/components/proximity_auth/client_impl.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/proximity_auth/client.h" +#include "components/proximity_auth/client_impl.h" #include "base/json/json_reader.h" #include "base/json/json_writer.h" @@ -52,32 +52,32 @@ std::string GetMessageType(const base::DictionaryValue& message) { } // namespace -Client::Client(scoped_ptr<Connection> connection, - scoped_ptr<SecureContext> secure_context) +ClientImpl::ClientImpl(scoped_ptr<Connection> connection, + scoped_ptr<SecureContext> secure_context) : connection_(connection.Pass()), secure_context_(secure_context.Pass()) { DCHECK(connection_->IsConnected()); connection_->AddObserver(this); } -Client::~Client() { +ClientImpl::~ClientImpl() { if (connection_) connection_->RemoveObserver(this); } -void Client::AddObserver(ClientObserver* observer) { +void ClientImpl::AddObserver(ClientObserver* observer) { observers_.AddObserver(observer); } -void Client::RemoveObserver(ClientObserver* observer) { +void ClientImpl::RemoveObserver(ClientObserver* observer) { observers_.RemoveObserver(observer); } -bool Client::SupportsSignIn() const { +bool ClientImpl::SupportsSignIn() const { return (secure_context_->GetProtocolVersion() == SecureContext::PROTOCOL_VERSION_THREE_ONE); } -void Client::DispatchUnlockEvent() { +void ClientImpl::DispatchUnlockEvent() { base::DictionaryValue message; message.SetString(kTypeKey, kMessageTypeLocalEvent); message.SetString(kNameKey, kUnlockEventName); @@ -85,12 +85,11 @@ void Client::DispatchUnlockEvent() { ProcessMessageQueue(); } -void Client::RequestDecryption(const std::string& challenge) { +void ClientImpl::RequestDecryption(const std::string& challenge) { if (!SupportsSignIn()) { VLOG(1) << "[Client] Dropping decryption request, as remote device " << "does not support protocol v3.1."; - FOR_EACH_OBSERVER(ClientObserver, - observers_, + FOR_EACH_OBSERVER(ClientObserver, observers_, OnDecryptResponse(scoped_ptr<std::string>())); return; } @@ -107,7 +106,7 @@ void Client::RequestDecryption(const std::string& challenge) { ProcessMessageQueue(); } -void Client::RequestUnlock() { +void ClientImpl::RequestUnlock() { if (!SupportsSignIn()) { VLOG(1) << "[Client] Dropping unlock request, as remote device does not " << "support protocol v3.1."; @@ -121,18 +120,18 @@ void Client::RequestUnlock() { ProcessMessageQueue(); } -Client::PendingMessage::PendingMessage() { +ClientImpl::PendingMessage::PendingMessage() { } -Client::PendingMessage::PendingMessage(const base::DictionaryValue& message) +ClientImpl::PendingMessage::PendingMessage(const base::DictionaryValue& message) : json_message(SerializeValueToJson(message)), type(GetMessageType(message)) { } -Client::PendingMessage::~PendingMessage() { +ClientImpl::PendingMessage::~PendingMessage() { } -void Client::ProcessMessageQueue() { +void ClientImpl::ProcessMessageQueue() { if (pending_message_ || queued_messages_.empty() || connection_->is_sending_message()) return; @@ -144,7 +143,7 @@ void Client::ProcessMessageQueue() { std::string(), secure_context_->Encode(pending_message_->json_message)))); } -void Client::HandleRemoteStatusUpdateMessage( +void ClientImpl::HandleRemoteStatusUpdateMessage( const base::DictionaryValue& message) { scoped_ptr<RemoteStatusUpdate> status_update = RemoteStatusUpdate::Deserialize(message); @@ -153,11 +152,11 @@ void Client::HandleRemoteStatusUpdateMessage( return; } - FOR_EACH_OBSERVER( - ClientObserver, observers_, OnRemoteStatusUpdate(*status_update)); + FOR_EACH_OBSERVER(ClientObserver, observers_, + OnRemoteStatusUpdate(*status_update)); } -void Client::HandleDecryptResponseMessage( +void ClientImpl::HandleDecryptResponseMessage( const base::DictionaryValue& message) { std::string base64_data; std::string decrypted_data; @@ -169,17 +168,18 @@ void Client::HandleDecryptResponseMessage( } else { response.reset(new std::string(decrypted_data)); } - FOR_EACH_OBSERVER( - ClientObserver, observers_, OnDecryptResponse(response.Pass())); + FOR_EACH_OBSERVER(ClientObserver, observers_, + OnDecryptResponse(response.Pass())); } -void Client::HandleUnlockResponseMessage(const base::DictionaryValue& message) { +void ClientImpl::HandleUnlockResponseMessage( + const base::DictionaryValue& message) { FOR_EACH_OBSERVER(ClientObserver, observers_, OnUnlockResponse(true)); } -void Client::OnConnectionStatusChanged(Connection* connection, - Connection::Status old_status, - Connection::Status new_status) { +void ClientImpl::OnConnectionStatusChanged(Connection* connection, + Connection::Status old_status, + Connection::Status new_status) { DCHECK_EQ(connection, connection_.get()); if (new_status != Connection::CONNECTED) { VLOG(1) << "[Client] Secure channel disconnected..."; @@ -191,8 +191,8 @@ void Client::OnConnectionStatusChanged(Connection* connection, } } -void Client::OnMessageReceived(const Connection& connection, - const WireMessage& wire_message) { +void ClientImpl::OnMessageReceived(const Connection& connection, + const WireMessage& wire_message) { std::string json_message = secure_context_->Decode(wire_message.payload()); scoped_ptr<base::Value> message_value = base::JSONReader::Read(json_message); if (!message_value || !message_value->IsType(base::Value::TYPE_DICTIONARY)) { @@ -251,9 +251,9 @@ void Client::OnMessageReceived(const Connection& connection, ProcessMessageQueue(); } -void Client::OnSendCompleted(const Connection& connection, - const WireMessage& wire_message, - bool success) { +void ClientImpl::OnSendCompleted(const Connection& connection, + const WireMessage& wire_message, + bool success) { if (!pending_message_) { VLOG(1) << "[Client] Unexpected message sent."; return; @@ -270,8 +270,7 @@ void Client::OnSendCompleted(const Connection& connection, // For local events, we don't expect a response, so on success, we // notify observers right away. if (pending_message_->type == kMessageTypeDecryptRequest) { - FOR_EACH_OBSERVER(ClientObserver, - observers_, + FOR_EACH_OBSERVER(ClientObserver, observers_, OnDecryptResponse(scoped_ptr<std::string>())); } else if (pending_message_->type == kMessageTypeUnlockRequest) { FOR_EACH_OBSERVER(ClientObserver, observers_, OnUnlockResponse(false)); diff --git a/components/proximity_auth/client_impl.h b/components/proximity_auth/client_impl.h new file mode 100644 index 0000000..b4d8dcb --- /dev/null +++ b/components/proximity_auth/client_impl.h @@ -0,0 +1,112 @@ +// Copyright 2014 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. + +#ifndef COMPONENTS_PROXIMITY_AUTH_CLIENT_IMPL_H +#define COMPONENTS_PROXIMITY_AUTH_CLIENT_IMPL_H + +#include <deque> + +#include "base/macros.h" +#include "base/memory/scoped_ptr.h" +#include "base/observer_list.h" +#include "components/proximity_auth/client.h" +#include "components/proximity_auth/connection_observer.h" + +namespace base { +class DictionaryValue; +} + +namespace proximity_auth { + +class Connection; +class SecureContext; + +// Concrete implementation of the Client interface. +class ClientImpl : public Client, public ConnectionObserver { + public: + // Constructs a client that sends and receives messages over the given + // |connection|, using the |secure_context| to encrypt and decrypt the + // messages. The |connection| must be connected. The client begins observing + // messages as soon as it is constructed. + ClientImpl(scoped_ptr<Connection> connection, + scoped_ptr<SecureContext> secure_context); + ~ClientImpl() override; + + // Client: + void AddObserver(ClientObserver* observer) override; + void RemoveObserver(ClientObserver* observer) override; + bool SupportsSignIn() const override; + void DispatchUnlockEvent() override; + void RequestDecryption(const std::string& challenge) override; + void RequestUnlock() override; + + protected: + // Exposed for testing. + Connection* connection() { return connection_.get(); } + SecureContext* secure_context() { return secure_context_.get(); } + + private: + // Internal data structure to represent a pending message that either hasn't + // been sent yet or is waiting for a response from the remote device. + struct PendingMessage { + PendingMessage(); + PendingMessage(const base::DictionaryValue& message); + ~PendingMessage(); + + // The message, serialized as JSON. + const std::string json_message; + + // The message type. This is possible to parse from the |json_message|; it's + // stored redundantly for convenience. + const std::string type; + }; + + // Pops the first of the |queued_messages_| and sends it to the remote device. + void ProcessMessageQueue(); + + // Handles an incoming "status_update" |message|, parsing and notifying + // observers of the content. + void HandleRemoteStatusUpdateMessage(const base::DictionaryValue& message); + + // Handles an incoming "decrypt_response" message, parsing and notifying + // observers of the decrypted content. + void HandleDecryptResponseMessage(const base::DictionaryValue& message); + + // Handles an incoming "unlock_response" message, notifying observers of the + // response. + void HandleUnlockResponseMessage(const base::DictionaryValue& message); + + // ConnectionObserver: + void OnConnectionStatusChanged(Connection* connection, + Connection::Status old_status, + Connection::Status new_status) override; + void OnMessageReceived(const Connection& connection, + const WireMessage& wire_message) override; + void OnSendCompleted(const Connection& connection, + const WireMessage& wire_message, + bool success) override; + + // The connection used to send and receive events and status updates. + scoped_ptr<Connection> connection_; + + // Used to encrypt and decrypt payloads sent and received over the + // |connection_|. + scoped_ptr<SecureContext> secure_context_; + + // The registered observers of |this_| client. + base::ObserverList<ClientObserver> observers_; + + // Queue of messages to send to the remote device. + std::deque<PendingMessage> queued_messages_; + + // The current message being sent or waiting on the remote device for a + // response. Null if there is no message currently in this state. + scoped_ptr<PendingMessage> pending_message_; + + DISALLOW_COPY_AND_ASSIGN(ClientImpl); +}; + +} // namespace proximity_auth + +#endif // COMPONENTS_PROXIMITY_AUTH_CLIENT_IMPL_H diff --git a/components/proximity_auth/client_unittest.cc b/components/proximity_auth/client_impl_unittest.cc index 8085a58..f519e01 100644 --- a/components/proximity_auth/client_unittest.cc +++ b/components/proximity_auth/client_impl_unittest.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "components/proximity_auth/client.h" +#include "components/proximity_auth/client_impl.h" #include "base/macros.h" #include "base/memory/scoped_ptr.h" @@ -137,11 +137,11 @@ class MockClientObserver : public ClientObserver { DISALLOW_COPY_AND_ASSIGN(MockClientObserver); }; -class TestClient : public Client { +class TestClient : public ClientImpl { public: TestClient() - : Client(make_scoped_ptr(new NiceMock<FakeConnection>()), - make_scoped_ptr(new NiceMock<MockSecureContext>())) {} + : ClientImpl(make_scoped_ptr(new NiceMock<FakeConnection>()), + make_scoped_ptr(new NiceMock<MockSecureContext>())) {} ~TestClient() override {} // Simple getters for the mock objects owned by |this| client. @@ -158,21 +158,22 @@ class TestClient : public Client { } // namespace -TEST(ProximityAuthClientTest, SupportsSignIn_ProtocolVersionThreeZero) { +TEST(ProximityAuthClientImplTest, SupportsSignIn_ProtocolVersionThreeZero) { TestClient client; ON_CALL(*client.GetMockSecureContext(), GetProtocolVersion()) .WillByDefault(Return(SecureContext::PROTOCOL_VERSION_THREE_ZERO)); EXPECT_FALSE(client.SupportsSignIn()); } -TEST(ProximityAuthClientTest, SupportsSignIn_ProtocolVersionThreeOne) { +TEST(ProximityAuthClientImplTest, SupportsSignIn_ProtocolVersionThreeOne) { TestClient client; ON_CALL(*client.GetMockSecureContext(), GetProtocolVersion()) .WillByDefault(Return(SecureContext::PROTOCOL_VERSION_THREE_ONE)); EXPECT_TRUE(client.SupportsSignIn()); } -TEST(ProximityAuthClientTest, OnConnectionStatusChanged_ConnectionDisconnects) { +TEST(ProximityAuthClientImplTest, + OnConnectionStatusChanged_ConnectionDisconnects) { TestClient client; MockClientObserver observer(&client); @@ -180,7 +181,7 @@ TEST(ProximityAuthClientTest, OnConnectionStatusChanged_ConnectionDisconnects) { client.GetFakeConnection()->Disconnect(); } -TEST(ProximityAuthClientTest, DispatchUnlockEvent_SendsExpectedMessage) { +TEST(ProximityAuthClientImplTest, DispatchUnlockEvent_SendsExpectedMessage) { TestClient client; client.DispatchUnlockEvent(); @@ -195,7 +196,7 @@ TEST(ProximityAuthClientTest, DispatchUnlockEvent_SendsExpectedMessage) { message->payload()); } -TEST(ProximityAuthClientTest, DispatchUnlockEvent_SendMessageFails) { +TEST(ProximityAuthClientImplTest, DispatchUnlockEvent_SendMessageFails) { TestClient client; MockClientObserver observer(&client); client.DispatchUnlockEvent(); @@ -204,7 +205,7 @@ TEST(ProximityAuthClientTest, DispatchUnlockEvent_SendMessageFails) { client.GetFakeConnection()->FinishSendingMessageWithSuccess(false); } -TEST(ProximityAuthClientTest, DispatchUnlockEvent_SendMessageSucceeds) { +TEST(ProximityAuthClientImplTest, DispatchUnlockEvent_SendMessageSucceeds) { TestClient client; MockClientObserver observer(&client); client.DispatchUnlockEvent(); @@ -213,7 +214,7 @@ TEST(ProximityAuthClientTest, DispatchUnlockEvent_SendMessageSucceeds) { client.GetFakeConnection()->FinishSendingMessageWithSuccess(true); } -TEST(ProximityAuthClientTest, +TEST(ProximityAuthClientImplTest, RequestDecryption_SignInUnsupported_DoesntSendMessage) { TestClient client; ON_CALL(*client.GetMockSecureContext(), GetProtocolVersion()) @@ -222,7 +223,7 @@ TEST(ProximityAuthClientTest, EXPECT_FALSE(client.GetFakeConnection()->current_message()); } -TEST(ProximityAuthClientTest, RequestDecryption_SendsExpectedMessage) { +TEST(ProximityAuthClientImplTest, RequestDecryption_SendsExpectedMessage) { TestClient client; client.RequestDecryption(kChallenge); @@ -237,7 +238,7 @@ TEST(ProximityAuthClientTest, RequestDecryption_SendsExpectedMessage) { message->payload()); } -TEST(ProximityAuthClientTest, +TEST(ProximityAuthClientImplTest, RequestDecryption_SendsExpectedMessage_UsingBase64UrlEncoding) { TestClient client; client.RequestDecryption("\xFF\xE6"); @@ -253,7 +254,7 @@ TEST(ProximityAuthClientTest, message->payload()); } -TEST(ProximityAuthClientTest, RequestDecryption_SendMessageFails) { +TEST(ProximityAuthClientImplTest, RequestDecryption_SendMessageFails) { TestClient client; MockClientObserver observer(&client); client.RequestDecryption(kChallenge); @@ -262,7 +263,8 @@ TEST(ProximityAuthClientTest, RequestDecryption_SendMessageFails) { client.GetFakeConnection()->FinishSendingMessageWithSuccess(false); } -TEST(ProximityAuthClientTest, RequestDecryption_SendSucceeds_WaitsForReply) { +TEST(ProximityAuthClientImplTest, + RequestDecryption_SendSucceeds_WaitsForReply) { TestClient client; MockClientObserver observer(&client); client.RequestDecryption(kChallenge); @@ -271,7 +273,7 @@ TEST(ProximityAuthClientTest, RequestDecryption_SendSucceeds_WaitsForReply) { client.GetFakeConnection()->FinishSendingMessageWithSuccess(true); } -TEST(ProximityAuthClientTest, +TEST(ProximityAuthClientImplTest, RequestDecryption_SendSucceeds_NotifiesObserversOnReply_NoData) { TestClient client; MockClientObserver observer(&client); @@ -283,7 +285,7 @@ TEST(ProximityAuthClientTest, "{\"type\":\"decrypt_response\"}, but encoded"); } -TEST(ProximityAuthClientTest, +TEST(ProximityAuthClientImplTest, RequestDecryption_SendSucceeds_NotifiesObserversOnReply_InvalidData) { TestClient client; MockClientObserver observer(&client); @@ -298,7 +300,7 @@ TEST(ProximityAuthClientTest, "}, but encoded"); } -TEST(ProximityAuthClientTest, +TEST(ProximityAuthClientImplTest, RequestDecryption_SendSucceeds_NotifiesObserversOnReply_ValidData) { TestClient client; MockClientObserver observer(&client); @@ -314,7 +316,7 @@ TEST(ProximityAuthClientTest, } // Verify that the client correctly parses base64url encoded data. -TEST(ProximityAuthClientTest, +TEST(ProximityAuthClientImplTest, RequestDecryption_SendSucceeds_ParsesBase64UrlEncodingInReply) { TestClient client; MockClientObserver observer(&client); @@ -329,7 +331,7 @@ TEST(ProximityAuthClientTest, "}, but encoded"); } -TEST(ProximityAuthClientTest, +TEST(ProximityAuthClientImplTest, RequestUnlock_SignInUnsupported_DoesntSendMessage) { TestClient client; ON_CALL(*client.GetMockSecureContext(), GetProtocolVersion()) @@ -338,7 +340,7 @@ TEST(ProximityAuthClientTest, EXPECT_FALSE(client.GetFakeConnection()->current_message()); } -TEST(ProximityAuthClientTest, RequestUnlock_SendsExpectedMessage) { +TEST(ProximityAuthClientImplTest, RequestUnlock_SendsExpectedMessage) { TestClient client; client.RequestUnlock(); @@ -348,7 +350,7 @@ TEST(ProximityAuthClientTest, RequestUnlock_SendsExpectedMessage) { EXPECT_EQ("{\"type\":\"unlock_request\"}, but encoded", message->payload()); } -TEST(ProximityAuthClientTest, RequestUnlock_SendMessageFails) { +TEST(ProximityAuthClientImplTest, RequestUnlock_SendMessageFails) { TestClient client; MockClientObserver observer(&client); client.RequestUnlock(); @@ -357,7 +359,7 @@ TEST(ProximityAuthClientTest, RequestUnlock_SendMessageFails) { client.GetFakeConnection()->FinishSendingMessageWithSuccess(false); } -TEST(ProximityAuthClientTest, RequestUnlock_SendSucceeds_WaitsForReply) { +TEST(ProximityAuthClientImplTest, RequestUnlock_SendSucceeds_WaitsForReply) { TestClient client; MockClientObserver observer(&client); client.RequestUnlock(); @@ -366,7 +368,7 @@ TEST(ProximityAuthClientTest, RequestUnlock_SendSucceeds_WaitsForReply) { client.GetFakeConnection()->FinishSendingMessageWithSuccess(true); } -TEST(ProximityAuthClientTest, +TEST(ProximityAuthClientImplTest, RequestUnlock_SendSucceeds_NotifiesObserversOnReply) { TestClient client; MockClientObserver observer(&client); @@ -378,7 +380,8 @@ TEST(ProximityAuthClientTest, "{\"type\":\"unlock_response\"}, but encoded"); } -TEST(ProximityAuthClientTest, OnMessageReceived_RemoteStatusUpdate_Invalid) { +TEST(ProximityAuthClientImplTest, + OnMessageReceived_RemoteStatusUpdate_Invalid) { TestClient client; MockClientObserver observer(&client); @@ -388,7 +391,7 @@ TEST(ProximityAuthClientTest, OnMessageReceived_RemoteStatusUpdate_Invalid) { "{\"type\":\"status_update\"}, but encoded"); } -TEST(ProximityAuthClientTest, OnMessageReceived_RemoteStatusUpdate_Valid) { +TEST(ProximityAuthClientImplTest, OnMessageReceived_RemoteStatusUpdate_Valid) { TestClient client; MockClientObserver observer(&client); @@ -408,7 +411,7 @@ TEST(ProximityAuthClientTest, OnMessageReceived_RemoteStatusUpdate_Valid) { "}, but encoded"); } -TEST(ProximityAuthClientTest, OnMessageReceived_InvalidJSON) { +TEST(ProximityAuthClientImplTest, OnMessageReceived_InvalidJSON) { TestClient client; StrictMock<MockClientObserver> observer(&client); client.RequestUnlock(); @@ -419,7 +422,7 @@ TEST(ProximityAuthClientTest, OnMessageReceived_InvalidJSON) { "Not JSON, but encoded"); } -TEST(ProximityAuthClientTest, OnMessageReceived_MissingTypeField) { +TEST(ProximityAuthClientImplTest, OnMessageReceived_MissingTypeField) { TestClient client; StrictMock<MockClientObserver> observer(&client); client.RequestUnlock(); @@ -430,7 +433,7 @@ TEST(ProximityAuthClientTest, OnMessageReceived_MissingTypeField) { "{\"some key that's not 'type'\":\"some value\"}, but encoded"); } -TEST(ProximityAuthClientTest, OnMessageReceived_UnexpectedReply) { +TEST(ProximityAuthClientImplTest, OnMessageReceived_UnexpectedReply) { TestClient client; StrictMock<MockClientObserver> observer(&client); @@ -439,7 +442,7 @@ TEST(ProximityAuthClientTest, OnMessageReceived_UnexpectedReply) { "{\"type\":\"unlock_response\"}, but encoded"); } -TEST(ProximityAuthClientTest, +TEST(ProximityAuthClientImplTest, OnMessageReceived_MismatchedReply_UnlockInReplyToDecrypt) { TestClient client; StrictMock<MockClientObserver> observer(&client); @@ -452,7 +455,7 @@ TEST(ProximityAuthClientTest, "{\"type\":\"unlock_response\"}, but encoded"); } -TEST(ProximityAuthClientTest, +TEST(ProximityAuthClientImplTest, OnMessageReceived_MismatchedReply_DecryptInReplyToUnlock) { TestClient client; StrictMock<MockClientObserver> observer(&client); @@ -468,7 +471,7 @@ TEST(ProximityAuthClientTest, "}, but encoded"); } -TEST(ProximityAuthClientTest, BuffersMessages_WhileSending) { +TEST(ProximityAuthClientImplTest, BuffersMessages_WhileSending) { TestClient client; MockClientObserver observer(&client); @@ -484,7 +487,7 @@ TEST(ProximityAuthClientTest, BuffersMessages_WhileSending) { client.GetFakeConnection()->FinishSendingMessageWithSuccess(false); } -TEST(ProximityAuthClientTest, BuffersMessages_WhileAwaitingReply) { +TEST(ProximityAuthClientImplTest, BuffersMessages_WhileAwaitingReply) { TestClient client; MockClientObserver observer(&client); |