| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "net/base/keygen_handler.h" | 5 #include "net/base/keygen_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 namespace net { | 24 namespace net { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 class KeygenHandlerTest : public ::testing::Test { | 28 class KeygenHandlerTest : public ::testing::Test { |
| 29 public: | 29 public: |
| 30 KeygenHandlerTest() {} | 30 KeygenHandlerTest() {} |
| 31 virtual ~KeygenHandlerTest() {} | 31 virtual ~KeygenHandlerTest() {} |
| 32 | 32 |
| 33 virtual void SetUp() { | 33 private: |
| 34 #if defined(OS_CHROMEOS) && defined(USE_NSS) | 34 #if defined(OS_CHROMEOS) && defined(USE_NSS) |
| 35 crypto::OpenPersistentNSSDB(); | 35 crypto::ScopedTestNSSDB test_nss_db_; |
| 36 #endif | 36 #endif |
| 37 } | |
| 38 }; | 37 }; |
| 39 | 38 |
| 40 // Assert that |result| is a valid output for KeygenHandler given challenge | 39 // Assert that |result| is a valid output for KeygenHandler given challenge |
| 41 // string of |challenge|. | 40 // string of |challenge|. |
| 42 void AssertValidSignedPublicKeyAndChallenge(const std::string& result, | 41 void AssertValidSignedPublicKeyAndChallenge(const std::string& result, |
| 43 const std::string& challenge) { | 42 const std::string& challenge) { |
| 44 ASSERT_GT(result.length(), 0U); | 43 ASSERT_GT(result.length(), 0U); |
| 45 | 44 |
| 46 // Verify it's valid base64: | 45 // Verify it's valid base64: |
| 47 std::string spkac; | 46 std::string spkac; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 events[i] = NULL; | 124 events[i] = NULL; |
| 126 | 125 |
| 127 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i]; | 126 VLOG(1) << "KeygenHandler " << i << " produced: " << results[i]; |
| 128 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge"); | 127 AssertValidSignedPublicKeyAndChallenge(results[i], "some challenge"); |
| 129 } | 128 } |
| 130 } | 129 } |
| 131 | 130 |
| 132 } // namespace | 131 } // namespace |
| 133 | 132 |
| 134 } // namespace net | 133 } // namespace net |
| OLD | NEW |