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

Side by Side Diff: chrome/browser/signin/local_auth_unittest.cc

Issue 548393002: Enable lock even when no password hash is present. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remote AuthCredsExist check Created 6 years, 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/signin/local_auth.h" 5 #include "chrome/browser/signin/local_auth.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
(...skipping 17 matching lines...) Expand all
28 EXPECT_EQ(1U, cache.GetNumberOfProfiles()); 28 EXPECT_EQ(1U, cache.GetNumberOfProfiles());
29 EXPECT_EQ("", cache.GetLocalAuthCredentialsOfProfileAtIndex(0)); 29 EXPECT_EQ("", cache.GetLocalAuthCredentialsOfProfileAtIndex(0));
30 30
31 #if defined(OS_MACOSX) 31 #if defined(OS_MACOSX)
32 OSCrypt::UseMockKeychain(true); 32 OSCrypt::UseMockKeychain(true);
33 #endif 33 #endif
34 34
35 std::string password("Some Password"); 35 std::string password("Some Password");
36 EXPECT_FALSE(ValidateLocalAuthCredentials(prof, password)); 36 EXPECT_FALSE(ValidateLocalAuthCredentials(prof, password));
37 37
38 EXPECT_FALSE(LocalAuthCredentialsExist(prof));
39 SetLocalAuthCredentials(prof, password); 38 SetLocalAuthCredentials(prof, password);
40 EXPECT_TRUE(LocalAuthCredentialsExist(prof));
msw 2014/09/09 16:52:56 You can keep/move the functions if they're truly v
41 std::string passhash = cache.GetLocalAuthCredentialsOfProfileAtIndex(0); 39 std::string passhash = cache.GetLocalAuthCredentialsOfProfileAtIndex(0);
42 40
43 // We perform basic validation on the written record to ensure bugs don't slip 41 // We perform basic validation on the written record to ensure bugs don't slip
44 // in that cannot be seen from the API: 42 // in that cannot be seen from the API:
45 // - The encoding exists (we can guarantee future backward compatibility). 43 // - The encoding exists (we can guarantee future backward compatibility).
46 // - The plaintext version of the password is not mistakenly stored anywhere. 44 // - The plaintext version of the password is not mistakenly stored anywhere.
47 EXPECT_FALSE(passhash.empty()); 45 EXPECT_FALSE(passhash.empty());
48 EXPECT_EQ('1', passhash[0]); 46 EXPECT_EQ('1', passhash[0]);
49 EXPECT_EQ(passhash.find(password), std::string::npos); 47 EXPECT_EQ(passhash.find(password), std::string::npos);
50 48
51 std::string decodedhash; 49 std::string decodedhash;
52 base::Base64Decode(passhash.substr(1), &decodedhash); 50 base::Base64Decode(passhash.substr(1), &decodedhash);
53 EXPECT_FALSE(decodedhash.empty()); 51 EXPECT_FALSE(decodedhash.empty());
54 EXPECT_EQ(decodedhash.find(password), std::string::npos); 52 EXPECT_EQ(decodedhash.find(password), std::string::npos);
55 53
56 EXPECT_TRUE(ValidateLocalAuthCredentials(prof, password)); 54 EXPECT_TRUE(ValidateLocalAuthCredentials(prof, password));
57 EXPECT_FALSE(ValidateLocalAuthCredentials(prof, password + "1")); 55 EXPECT_FALSE(ValidateLocalAuthCredentials(prof, password + "1"));
58 56
59 SetLocalAuthCredentials(prof, password); // makes different salt 57 SetLocalAuthCredentials(prof, password); // makes different salt
60 EXPECT_NE(passhash, cache.GetLocalAuthCredentialsOfProfileAtIndex(0)); 58 EXPECT_NE(passhash, cache.GetLocalAuthCredentialsOfProfileAtIndex(0));
61 } 59 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/local_auth.cc ('k') | chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698