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

Unified Diff: chrome/browser/chromeos/login/auth/key_unittest.cc

Issue 296773002: Add a Key class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 7 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 | « chrome/browser/chromeos/login/auth/key.cc ('k') | chrome/browser/chromeos/login/auth/login_performer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/login/auth/key_unittest.cc
diff --git a/chrome/browser/chromeos/login/auth/key_unittest.cc b/chrome/browser/chromeos/login/auth/key_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..558472b87ceb076a22845e0f8395c9e63cb9f117
--- /dev/null
+++ b/chrome/browser/chromeos/login/auth/key_unittest.cc
@@ -0,0 +1,47 @@
+// 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.
+
+#include "chrome/browser/chromeos/login/auth/key.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace chromeos {
+
+namespace {
+
+const char kPassword[] = "password";
+const char kLabel[] = "label";
+const char kSalt[] =
+ "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
+
+} // namespace
+
+TEST(KeyTest, ClearSecret) {
+ Key key(kPassword);
+ key.SetLabel(kLabel);
+ EXPECT_EQ(Key::KEY_TYPE_PASSWORD_PLAIN, key.GetKeyType());
+ EXPECT_EQ(kPassword, key.GetSecret());
+ EXPECT_EQ(kLabel, key.GetLabel());
+
+ key.ClearSecret();
+ EXPECT_EQ(Key::KEY_TYPE_PASSWORD_PLAIN, key.GetKeyType());
+ EXPECT_TRUE(key.GetSecret().empty());
+ EXPECT_EQ(kLabel, key.GetLabel());
+}
+
+TEST(KeyTest, TransformToSaltedSHA256TopHalf) {
+ Key key(kPassword);
+ key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, kSalt);
+ EXPECT_EQ(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, key.GetKeyType());
+ EXPECT_EQ("5b01941771e47fa408380aa675703f4f", key.GetSecret());
+}
+
+TEST(KeyTest, TransformToSaltedAES2561234) {
+ Key key(kPassword);
+ key.Transform(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, kSalt);
+ EXPECT_EQ(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, key.GetKeyType());
+ EXPECT_EQ("GUkNnvqoULf/cXbZscVUnANmLBB0ovjGZsj1sKzP5BE=", key.GetSecret());
+}
+
+} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/auth/key.cc ('k') | chrome/browser/chromeos/login/auth/login_performer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698