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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/login/auth/key.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace chromeos {
10
11 namespace {
12
13 const char kPassword[] = "password";
14 const char kLabel[] = "label";
15 const char kSalt[] =
16 "deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
17
18 } // namespace
19
20 TEST(KeyTest, ClearSecret) {
21 Key key(kPassword);
22 key.SetLabel(kLabel);
23 EXPECT_EQ(Key::KEY_TYPE_PASSWORD_PLAIN, key.GetKeyType());
24 EXPECT_EQ(kPassword, key.GetSecret());
25 EXPECT_EQ(kLabel, key.GetLabel());
26
27 key.ClearSecret();
28 EXPECT_EQ(Key::KEY_TYPE_PASSWORD_PLAIN, key.GetKeyType());
29 EXPECT_TRUE(key.GetSecret().empty());
30 EXPECT_EQ(kLabel, key.GetLabel());
31 }
32
33 TEST(KeyTest, TransformToSaltedSHA256TopHalf) {
34 Key key(kPassword);
35 key.Transform(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, kSalt);
36 EXPECT_EQ(Key::KEY_TYPE_SALTED_SHA256_TOP_HALF, key.GetKeyType());
37 EXPECT_EQ("5b01941771e47fa408380aa675703f4f", key.GetSecret());
38 }
39
40 TEST(KeyTest, TransformToSaltedAES2561234) {
41 Key key(kPassword);
42 key.Transform(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, kSalt);
43 EXPECT_EQ(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, key.GetKeyType());
44 EXPECT_EQ("GUkNnvqoULf/cXbZscVUnANmLBB0ovjGZsj1sKzP5BE=", key.GetSecret());
45 }
46
47 } // namespace chromeos
OLDNEW
« 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