| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/internal_auth.h" | 5 #include "chrome/browser/internal_auth.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 namespace chrome { | 14 namespace chrome { |
| 15 | 15 |
| 16 class InternalAuthTest : public ::testing::Test { | 16 class InternalAuthTest : public ::testing::Test { |
| 17 public: | 17 public: |
| 18 InternalAuthTest() { | 18 InternalAuthTest() { |
| 19 long_string_ = "seed"; | 19 long_string_ = "seed"; |
| 20 for (int i = 20; i--;) | 20 for (int i = 20; i--;) |
| 21 long_string_ += long_string_; | 21 long_string_ += long_string_; |
| 22 } | 22 } |
| 23 virtual ~InternalAuthTest() {} | 23 ~InternalAuthTest() override {} |
| 24 | 24 |
| 25 virtual void SetUp() { | 25 void SetUp() override {} |
| 26 } | |
| 27 | 26 |
| 28 virtual void TearDown() { | 27 void TearDown() override {} |
| 29 } | |
| 30 | 28 |
| 31 base::MessageLoop message_loop_; | 29 base::MessageLoop message_loop_; |
| 32 std::string long_string_; | 30 std::string long_string_; |
| 33 }; | 31 }; |
| 34 | 32 |
| 35 TEST_F(InternalAuthTest, BasicGeneration) { | 33 TEST_F(InternalAuthTest, BasicGeneration) { |
| 36 std::map<std::string, std::string> map; | 34 std::map<std::string, std::string> map; |
| 37 map["key"] = "value"; | 35 map["key"] = "value"; |
| 38 std::string token = InternalAuthGeneration::GeneratePassport( | 36 std::string token = InternalAuthGeneration::GeneratePassport( |
| 39 "zapata", map); | 37 "zapata", map); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 177 |
| 180 token = InternalAuthGeneration::GeneratePassport("zapata", map); | 178 token = InternalAuthGeneration::GeneratePassport("zapata", map); |
| 181 ASSERT_GT(token.size(), 10u); | 179 ASSERT_GT(token.size(), 10u); |
| 182 for (int i = 20; i--;) | 180 for (int i = 20; i--;) |
| 183 InternalAuthGeneration::GenerateNewKey(); | 181 InternalAuthGeneration::GenerateNewKey(); |
| 184 // Passport should not survive series of key changes. | 182 // Passport should not survive series of key changes. |
| 185 ASSERT_FALSE(InternalAuthVerification::VerifyPassport(token, "zapata", map)); | 183 ASSERT_FALSE(InternalAuthVerification::VerifyPassport(token, "zapata", map)); |
| 186 } | 184 } |
| 187 | 185 |
| 188 } // namespace chrome | 186 } // namespace chrome |
| OLD | NEW |