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

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: Split authenticator into base, client, host 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 1e3f5409adb8578fef452286738897556548bb07..6a7aa86dac943156f9bf86a7ef004c959841ec48 100644
--- a/remoting/protocol/authenticator_test_base.cc
+++ b/remoting/protocol/authenticator_test_base.cc
@@ -56,39 +56,31 @@ void AuthenticatorTestBase::SetUp() {
base::Base64Encode(key_string, &key_base64);
key_pair_ = new RsaKeyPair();
key_pair_->LoadFromString(key_base64);
+ host_public_key_ = key_pair_->GetPublicKey();
}
void AuthenticatorTestBase::RunAuthExchange() {
- do {
- scoped_ptr<buzz::XmlElement> message;
-
- // 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());
-
- // Are we done yet?
- if (host_->state() == Authenticator::ACCEPTED ||
- host_->state() == Authenticator::REJECTED) {
- break;
- }
-
- // Pass message from host to client.
- ASSERT_EQ(Authenticator::MESSAGE_READY, host_->state());
- message = host_->GetNextMessage();
- ASSERT_TRUE(message.get());
- ASSERT_NE(Authenticator::MESSAGE_READY, host_->state());
-
- 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);
+ ContinueAuthExchangeWith(client_.get(), host_.get());
+}
+
+// static
+void AuthenticatorTestBase::ContinueAuthExchangeWith(Authenticator* sender,
+ Authenticator* receiver) {
+ scoped_ptr<buzz::XmlElement> message;
+ ASSERT_NE(Authenticator::WAITING_MESSAGE, sender->state());
+ if (sender->state() == Authenticator::ACCEPTED ||
+ sender->state() == Authenticator::REJECTED)
+ return;
+ // Pass message from client to host.
+ ASSERT_EQ(Authenticator::MESSAGE_READY, sender->state());
+ message = sender->GetNextMessage();
+ ASSERT_TRUE(message.get());
+ ASSERT_NE(Authenticator::MESSAGE_READY, sender->state());
+
+ ASSERT_EQ(Authenticator::WAITING_MESSAGE, receiver->state());
+ receiver->ProcessMessage(message.get(), base::Bind(
+ &AuthenticatorTestBase::ContinueAuthExchangeWith,
+ base::Unretained(receiver), base::Unretained(sender)));
}
void AuthenticatorTestBase::RunChannelAuth(bool expected_fail) {

Powered by Google App Engine
This is Rietveld 408576698