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

Unified Diff: remoting/protocol/authenticator_test_base.cc

Issue 12326090: Third Party authentication protocol. (Closed) Base URL: http://git.chromium.org/chromium/src.git@host_key_pair
Patch Set: Add the missing new files Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: remoting/protocol/authenticator_test_base.cc
diff --git a/remoting/protocol/authenticator_test_base.cc b/remoting/protocol/authenticator_test_base.cc
index 02ea9c3bbece8f72c37d00b105f0c5f25e830b69..ca7d59770c78de129c30db79cbae5560340fd690 100644
--- a/remoting/protocol/authenticator_test_base.cc
+++ b/remoting/protocol/authenticator_test_base.cc
@@ -56,21 +56,38 @@ void AuthenticatorTestBase::SetUp() {
base::Base64Encode(key_string, &key_base64);
key_pair_.reset(new KeyPair());
key_pair_->LoadFromString(key_base64);
+ host_public_key_ = key_pair_->GetPublicKey();
}
void AuthenticatorTestBase::RunAuthExchange() {
- do {
- scoped_ptr<buzz::XmlElement> message;
+ ContinueAuthExchange(false);
+}
- // Pass message from client to host.
- ASSERT_EQ(Authenticator::MESSAGE_READY, client_->state());
- message = client_->GetNextMessage();
- ASSERT_TRUE(message.get());
- ASSERT_NE(Authenticator::MESSAGE_READY, client_->state());
+void AuthenticatorTestBase::ContinueAuthExchange(bool skip_client_to_host) {
+ while (client_->state() != Authenticator::ACCEPTED &&
+ client_->state() != Authenticator::REJECTED) {
+ scoped_ptr<buzz::XmlElement> message;
- ASSERT_EQ(Authenticator::WAITING_MESSAGE, host_->state());
- host_->ProcessMessage(message.get());
- ASSERT_NE(Authenticator::WAITING_MESSAGE, host_->state());
+ if (!skip_client_to_host) {
+ // Pass message from client to host.
+ ASSERT_EQ(Authenticator::MESSAGE_READY, client_->state());
+ message = client_->GetNextMessage();
+ ASSERT_TRUE(message.get());
+ ASSERT_NE(Authenticator::MESSAGE_READY, client_->state());
+
+ ASSERT_EQ(Authenticator::WAITING_MESSAGE, host_->state());
+ host_->ProcessMessage(message.get());
+ ASSERT_NE(Authenticator::WAITING_MESSAGE, host_->state());
+
+ if (host_->state() == Authenticator::WAITING_EXTERNAL) {
+ host_->PerformExternalAction(base::Bind(
+ &AuthenticatorTestBase::ContinueAuthExchange,
+ base::Unretained(this), true));
+ break;
+ }
+ } else {
+ skip_client_to_host = false;
+ }
// Are we done yet?
if (host_->state() == Authenticator::ACCEPTED ||
@@ -87,8 +104,14 @@ void AuthenticatorTestBase::RunAuthExchange() {
ASSERT_EQ(Authenticator::WAITING_MESSAGE, client_->state());
client_->ProcessMessage(message.get());
ASSERT_NE(Authenticator::WAITING_MESSAGE, client_->state());
- } while (client_->state() != Authenticator::ACCEPTED &&
- client_->state() != Authenticator::REJECTED);
+
+ if (client_->state() == Authenticator::WAITING_EXTERNAL) {
+ client_->PerformExternalAction(base::Bind(
+ &AuthenticatorTestBase::ContinueAuthExchange, base::Unretained(this),
+ false));
+ break;
+ }
+ }
}
void AuthenticatorTestBase::RunChannelAuth(bool expected_fail) {
@@ -96,16 +119,6 @@ void AuthenticatorTestBase::RunChannelAuth(bool expected_fail) {
host_fake_socket_.reset(new FakeSocket());
client_fake_socket_->PairWith(host_fake_socket_.get());
- client_auth_->SecureAndAuthenticate(
- client_fake_socket_.PassAs<net::StreamSocket>(),
- base::Bind(&AuthenticatorTestBase::OnClientConnected,
- base::Unretained(this)));
-
- host_auth_->SecureAndAuthenticate(
- host_fake_socket_.PassAs<net::StreamSocket>(),
- base::Bind(&AuthenticatorTestBase::OnHostConnected,
- base::Unretained(this)));
-
// Expect two callbacks to be called - the client callback and the host
// callback.
int callback_counter = 2;
@@ -120,6 +133,16 @@ void AuthenticatorTestBase::RunChannelAuth(bool expected_fail) {
.WillOnce(QuitThreadOnCounter(&callback_counter));
}
+ client_auth_->SecureAndAuthenticate(
+ client_fake_socket_.PassAs<net::StreamSocket>(),
+ base::Bind(&AuthenticatorTestBase::OnClientConnected,
+ base::Unretained(this)));
+
+ host_auth_->SecureAndAuthenticate(
+ host_fake_socket_.PassAs<net::StreamSocket>(),
+ base::Bind(&AuthenticatorTestBase::OnHostConnected,
+ base::Unretained(this)));
+
// Ensure that .Run() does not run unbounded if the callbacks are never
// called.
base::Timer shutdown_timer(false, false);

Powered by Google App Engine
This is Rietveld 408576698