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

Unified Diff: chrome/browser/internal_auth_unittest.cc

Issue 10694060: browser: Move more files into chrome namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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/internal_auth.cc ('k') | chrome/browser/printing/print_error_dialog.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/internal_auth_unittest.cc
diff --git a/chrome/browser/internal_auth_unittest.cc b/chrome/browser/internal_auth_unittest.cc
index 952976b919e13f1dfb47550c1742b2317ee306a8..39319ec7bf06f5a6d52444bc226b6c95efdeed1d 100644
--- a/chrome/browser/internal_auth_unittest.cc
+++ b/chrome/browser/internal_auth_unittest.cc
@@ -12,7 +12,7 @@
#include "content/public/test/test_browser_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace browser {
+namespace chrome {
class InternalAuthTest : public ::testing::Test {
public:
@@ -36,23 +36,23 @@ class InternalAuthTest : public ::testing::Test {
TEST_F(InternalAuthTest, BasicGeneration) {
std::map<std::string, std::string> map;
map["key"] = "value";
- std::string token = browser::InternalAuthGeneration::GeneratePassport(
+ std::string token = InternalAuthGeneration::GeneratePassport(
"zapata", map);
ASSERT_GT(token.size(), 10u); // short token is insecure.
map["key2"] = "value2";
- token = browser::InternalAuthGeneration::GeneratePassport("zapata", map);
+ token = InternalAuthGeneration::GeneratePassport("zapata", map);
ASSERT_GT(token.size(), 10u);
}
TEST_F(InternalAuthTest, DoubleGeneration) {
std::map<std::string, std::string> map;
map["key"] = "value";
- std::string token1 = browser::InternalAuthGeneration::GeneratePassport(
+ std::string token1 = InternalAuthGeneration::GeneratePassport(
"zapata", map);
ASSERT_GT(token1.size(), 10u);
- std::string token2 = browser::InternalAuthGeneration::GeneratePassport(
+ std::string token2 = InternalAuthGeneration::GeneratePassport(
"zapata", map);
ASSERT_GT(token2.size(), 10u);
// tokens are different even if credentials coincide.
@@ -63,17 +63,16 @@ TEST_F(InternalAuthTest, BadGeneration) {
std::map<std::string, std::string> map;
map["key"] = "value";
// Trying huge domain.
- std::string token = browser::InternalAuthGeneration::GeneratePassport(
+ std::string token = InternalAuthGeneration::GeneratePassport(
long_string_, map);
ASSERT_TRUE(token.empty());
- ASSERT_FALSE(browser::InternalAuthVerification::VerifyPassport(
+ ASSERT_FALSE(InternalAuthVerification::VerifyPassport(
token, long_string_, map));
// Trying empty domain.
- token = browser::InternalAuthGeneration::GeneratePassport("", map);
+ token = InternalAuthGeneration::GeneratePassport("", map);
ASSERT_TRUE(token.empty());
- ASSERT_FALSE(browser::InternalAuthVerification::VerifyPassport(
- token, "", map));
+ ASSERT_FALSE(InternalAuthVerification::VerifyPassport(token, "", map));
std::string dummy("abcdefghij");
for (size_t i = 1000; i--;) {
@@ -84,31 +83,27 @@ TEST_F(InternalAuthTest, BadGeneration) {
map[key] = value;
}
// Trying huge var=value map.
- token = browser::InternalAuthGeneration::GeneratePassport("zapata", map);
+ token = InternalAuthGeneration::GeneratePassport("zapata", map);
ASSERT_TRUE(token.empty());
- ASSERT_FALSE(browser::InternalAuthVerification::VerifyPassport(
- token, "zapata", map));
+ ASSERT_FALSE(InternalAuthVerification::VerifyPassport(token, "zapata", map));
map.clear();
map[""] = "value";
// Trying empty key.
- token = browser::InternalAuthGeneration::GeneratePassport("zapata", map);
+ token = InternalAuthGeneration::GeneratePassport("zapata", map);
ASSERT_TRUE(token.empty());
- ASSERT_FALSE(browser::InternalAuthVerification::VerifyPassport(
- token, "zapata", map));
+ ASSERT_FALSE(InternalAuthVerification::VerifyPassport(token, "zapata", map));
}
TEST_F(InternalAuthTest, BasicVerification) {
std::map<std::string, std::string> map;
map["key"] = "value";
- std::string token = browser::InternalAuthGeneration::GeneratePassport(
- "zapata", map);
+ std::string token = InternalAuthGeneration::GeneratePassport("zapata", map);
ASSERT_GT(token.size(), 10u);
- ASSERT_TRUE(browser::InternalAuthVerification::VerifyPassport(
- token, "zapata", map));
+ ASSERT_TRUE(InternalAuthVerification::VerifyPassport(token, "zapata", map));
// Passport can not be reused.
for (int i = 1000; i--;) {
- ASSERT_FALSE(browser::InternalAuthVerification::VerifyPassport(
+ ASSERT_FALSE(InternalAuthVerification::VerifyPassport(
token, "zapata", map));
}
}
@@ -116,37 +111,34 @@ TEST_F(InternalAuthTest, BasicVerification) {
TEST_F(InternalAuthTest, BruteForce) {
std::map<std::string, std::string> map;
map["key"] = "value";
- std::string token = browser::InternalAuthGeneration::GeneratePassport(
- "zapata", map);
+ std::string token = InternalAuthGeneration::GeneratePassport("zapata", map);
ASSERT_GT(token.size(), 10u);
// Trying bruteforce.
std::string dummy = token;
for (size_t i = 100; i--;) {
std::next_permutation(dummy.begin(), dummy.end());
- ASSERT_FALSE(browser::InternalAuthVerification::VerifyPassport(
+ ASSERT_FALSE(InternalAuthVerification::VerifyPassport(
dummy, "zapata", map));
}
dummy = token;
for (size_t i = 100; i--;) {
std::next_permutation(dummy.begin(), dummy.begin() + dummy.size() / 2);
- ASSERT_FALSE(browser::InternalAuthVerification::VerifyPassport(
+ ASSERT_FALSE(InternalAuthVerification::VerifyPassport(
dummy, "zapata", map));
}
// We brute forced just too little, so original token must not expire yet.
- ASSERT_TRUE(browser::InternalAuthVerification::VerifyPassport(
- token, "zapata", map));
+ ASSERT_TRUE(InternalAuthVerification::VerifyPassport(token, "zapata", map));
}
TEST_F(InternalAuthTest, ExpirationAndBruteForce) {
int kCustomVerificationWindow = 2;
- browser::InternalAuthVerification::set_verification_window_seconds(
+ InternalAuthVerification::set_verification_window_seconds(
kCustomVerificationWindow);
std::map<std::string, std::string> map;
map["key"] = "value";
- std::string token = browser::InternalAuthGeneration::GeneratePassport(
- "zapata", map);
+ std::string token = InternalAuthGeneration::GeneratePassport("zapata", map);
ASSERT_GT(token.size(), 10u);
// We want to test token expiration, so we need to wait some amount of time,
@@ -157,12 +149,12 @@ TEST_F(InternalAuthTest, ExpirationAndBruteForce) {
for (;;) {
for (size_t i = 100; i--;) {
std::next_permutation(dummy1.begin(), dummy1.end());
- ASSERT_FALSE(browser::InternalAuthVerification::VerifyPassport(
+ ASSERT_FALSE(InternalAuthVerification::VerifyPassport(
dummy1, "zapata", map));
}
for (size_t i = 100; i--;) {
std::next_permutation(dummy2.begin(), dummy2.begin() + dummy2.size() / 2);
- ASSERT_FALSE(browser::InternalAuthVerification::VerifyPassport(
+ ASSERT_FALSE(InternalAuthVerification::VerifyPassport(
dummy2, "zapata", map));
}
if (base::Time::Now() - timestamp > base::TimeDelta::FromSeconds(
@@ -170,31 +162,27 @@ TEST_F(InternalAuthTest, ExpirationAndBruteForce) {
break;
}
}
- ASSERT_FALSE(browser::InternalAuthVerification::VerifyPassport(
- token, "zapata", map));
+ ASSERT_FALSE(InternalAuthVerification::VerifyPassport(token, "zapata", map));
// Reset verification window to default.
- browser::InternalAuthVerification::set_verification_window_seconds(0);
+ InternalAuthVerification::set_verification_window_seconds(0);
}
TEST_F(InternalAuthTest, ChangeKey) {
std::map<std::string, std::string> map;
map["key"] = "value";
- std::string token = browser::InternalAuthGeneration::GeneratePassport(
- "zapata", map);
+ std::string token = InternalAuthGeneration::GeneratePassport("zapata", map);
ASSERT_GT(token.size(), 10u);
- browser::InternalAuthGeneration::GenerateNewKey();
+ InternalAuthGeneration::GenerateNewKey();
// Passport should survive key change.
- ASSERT_TRUE(browser::InternalAuthVerification::VerifyPassport(
- token, "zapata", map));
+ ASSERT_TRUE(InternalAuthVerification::VerifyPassport(token, "zapata", map));
- token = browser::InternalAuthGeneration::GeneratePassport("zapata", map);
+ token = InternalAuthGeneration::GeneratePassport("zapata", map);
ASSERT_GT(token.size(), 10u);
for (int i = 20; i--;)
- browser::InternalAuthGeneration::GenerateNewKey();
+ InternalAuthGeneration::GenerateNewKey();
// Passport should not survive series of key changes.
- ASSERT_FALSE(browser::InternalAuthVerification::VerifyPassport(
- token, "zapata", map));
+ ASSERT_FALSE(InternalAuthVerification::VerifyPassport(token, "zapata", map));
}
-} // namespace browser
+} // namespace chrome
« no previous file with comments | « chrome/browser/internal_auth.cc ('k') | chrome/browser/printing/print_error_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698