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

Unified Diff: chromeos/dbus/fake_auth_policy_client_unittest.cc

Issue 2653913002: Check username validity in the FakeAuthPolicyClient (Closed)
Patch Set: Add unittests Created 3 years, 11 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 | « chromeos/dbus/fake_auth_policy_client.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/fake_auth_policy_client_unittest.cc
diff --git a/chromeos/dbus/fake_auth_policy_client_unittest.cc b/chromeos/dbus/fake_auth_policy_client_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8df16808686b6d48a2177674f9c5a6d2d06d7a5d
--- /dev/null
+++ b/chromeos/dbus/fake_auth_policy_client_unittest.cc
@@ -0,0 +1,48 @@
+// Copyright 2017 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 "chromeos/dbus/fake_auth_policy_client.h"
+
+#include "base/bind.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chromeos {
+namespace {
+
+const char kMachineName[] = "machine_name";
achuithb 2017/01/25 20:02:46 I think this just adds noise - why not pass in ""
Roman Sorokin (ftl) 2017/01/26 13:10:14 I decided to add machine_name checks, and tests fo
+
+void JoinAdCallback(authpolicy::ErrorType expected,
+ authpolicy::ErrorType actual) {
+ EXPECT_EQ(expected, actual);
achuithb 2017/01/25 20:02:46 Hmm, I believe you won't be able to tell which cas
Roman Sorokin (ftl) 2017/01/26 13:10:14 Done.
+}
+
+} // namespace
+
+TEST(FakeAuthPolicyClientTest, JoinAdDomain_ParseUPN) {
+ FakeAuthPolicyClient client;
+ client.JoinAdDomain(kMachineName, "user@realm.com", /* password_fd */ -1,
+ base::Bind(&JoinAdCallback, authpolicy::ERROR_NONE));
+
+ client.JoinAdDomain(
+ kMachineName, "user", /* password_fd */ -1,
+ base::Bind(&JoinAdCallback, authpolicy::ERROR_PARSE_UPN_FAILED));
+
+ client.JoinAdDomain(
+ kMachineName, "", /* password_fd */ -1,
+ base::Bind(&JoinAdCallback, authpolicy::ERROR_PARSE_UPN_FAILED));
+
+ client.JoinAdDomain(
+ kMachineName, "user@", /* password_fd */ -1,
+ base::Bind(&JoinAdCallback, authpolicy::ERROR_PARSE_UPN_FAILED));
+
+ client.JoinAdDomain(
+ kMachineName, "@realm.com", /* password_fd */ -1,
+ base::Bind(&JoinAdCallback, authpolicy::ERROR_PARSE_UPN_FAILED));
+
+ client.JoinAdDomain(
+ kMachineName, "user@realm@com", /* password_fd */ -1,
+ base::Bind(&JoinAdCallback, authpolicy::ERROR_PARSE_UPN_FAILED));
+}
+
+} // namespace chromeos
« no previous file with comments | « chromeos/dbus/fake_auth_policy_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698