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

Unified Diff: remoting/protocol/negotiating_authenticator_unittest.cc

Issue 12518027: Protocol / client plugin changes to support interactively asking for a PIN (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix comments Created 7 years, 9 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
« no previous file with comments | « remoting/protocol/negotiating_authenticator.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/negotiating_authenticator_unittest.cc
diff --git a/remoting/protocol/negotiating_authenticator_unittest.cc b/remoting/protocol/negotiating_authenticator_unittest.cc
index 73daf833286c1d6cce8655186bdf7aceba0d8a0e..b17fa6a1bfd8da621d435e81daee40636c8bf3ef 100644
--- a/remoting/protocol/negotiating_authenticator_unittest.cc
+++ b/remoting/protocol/negotiating_authenticator_unittest.cc
@@ -59,9 +59,15 @@ class NegotiatingAuthenticatorTest : public AuthenticatorTestBase {
AuthenticationMethod::NONE));
}
client_ = NegotiatingAuthenticator::CreateForClient(
- kTestHostId, client_secret, methods);
+ kTestHostId, base::Bind(&NegotiatingAuthenticatorTest::FetchSecret,
+ client_secret), methods);
}
+ static void FetchSecret(
+ const std::string& client_secret,
+ const protocol::SecretFetchedCallback& secret_fetched_callback) {
+ secret_fetched_callback.Run(client_secret);
+ }
void VerifyRejected(Authenticator::RejectionReason reason) {
ASSERT_TRUE((client_->state() == Authenticator::REJECTED &&
(client_->rejection_reason() == reason)) ||
@@ -69,6 +75,28 @@ class NegotiatingAuthenticatorTest : public AuthenticatorTestBase {
(host_->rejection_reason() == reason)));
}
+ void VerifyAccepted() {
+ ASSERT_NO_FATAL_FAILURE(RunAuthExchange());
+
+ ASSERT_EQ(Authenticator::ACCEPTED, host_->state());
+ ASSERT_EQ(Authenticator::ACCEPTED, client_->state());
+
+ client_auth_ = client_->CreateChannelAuthenticator();
+ host_auth_ = host_->CreateChannelAuthenticator();
+ RunChannelAuth(false);
+
+ EXPECT_TRUE(client_socket_.get() != NULL);
+ EXPECT_TRUE(host_socket_.get() != NULL);
+
+ StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
+ kMessageSize, kMessages);
+
+ tester.Start();
+ message_loop_.Run();
+ tester.CheckResults();
+ }
+
+ private:
DISALLOW_COPY_AND_ASSIGN(NegotiatingAuthenticatorTest);
};
@@ -76,48 +104,14 @@ TEST_F(NegotiatingAuthenticatorTest, SuccessfulAuthHmac) {
ASSERT_NO_FATAL_FAILURE(InitAuthenticators(
kTestSharedSecret, kTestSharedSecret,
AuthenticationMethod::HMAC_SHA256, false));
- ASSERT_NO_FATAL_FAILURE(RunAuthExchange());
-
- ASSERT_EQ(Authenticator::ACCEPTED, host_->state());
- ASSERT_EQ(Authenticator::ACCEPTED, client_->state());
-
- client_auth_ = client_->CreateChannelAuthenticator();
- host_auth_ = host_->CreateChannelAuthenticator();
- RunChannelAuth(false);
-
- EXPECT_TRUE(client_socket_.get() != NULL);
- EXPECT_TRUE(host_socket_.get() != NULL);
-
- StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
- kMessageSize, kMessages);
-
- tester.Start();
- message_loop_.Run();
- tester.CheckResults();
+ VerifyAccepted();
}
TEST_F(NegotiatingAuthenticatorTest, SuccessfulAuthPlain) {
ASSERT_NO_FATAL_FAILURE(InitAuthenticators(
kTestSharedSecret, kTestSharedSecret,
AuthenticationMethod::NONE, false));
- ASSERT_NO_FATAL_FAILURE(RunAuthExchange());
-
- ASSERT_EQ(Authenticator::ACCEPTED, host_->state());
- ASSERT_EQ(Authenticator::ACCEPTED, client_->state());
-
- client_auth_ = client_->CreateChannelAuthenticator();
- host_auth_ = host_->CreateChannelAuthenticator();
- RunChannelAuth(false);
-
- EXPECT_TRUE(client_socket_.get() != NULL);
- EXPECT_TRUE(host_socket_.get() != NULL);
-
- StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
- kMessageSize, kMessages);
-
- tester.Start();
- message_loop_.Run();
- tester.CheckResults();
+ VerifyAccepted();
}
TEST_F(NegotiatingAuthenticatorTest, InvalidSecretHmac) {
« no previous file with comments | « remoting/protocol/negotiating_authenticator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698