| 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/chromeos/network_settings/onc_utils.h" | 5 #include "chromeos/network/onc/onc_utils.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/chromeos/network_settings/onc_test_utils.h" | 10 #include "chromeos/network/onc/onc_test_utils.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace chromeos { | 13 namespace chromeos { |
| 14 namespace onc { | 14 namespace onc { |
| 15 | 15 |
| 16 TEST(ONCDecrypterTest, BrokenEncryptionIterations) { | 16 TEST(ONCDecrypterTest, BrokenEncryptionIterations) { |
| 17 scoped_ptr<base::DictionaryValue> encrypted_onc = | 17 scoped_ptr<base::DictionaryValue> encrypted_onc = |
| 18 test_utils::ReadTestDictionary("broken-encrypted-iterations.onc"); | 18 test_utils::ReadTestDictionary("broken-encrypted-iterations.onc"); |
| 19 | 19 |
| 20 std::string error; | |
| 21 scoped_ptr<base::DictionaryValue> decrypted_onc = | 20 scoped_ptr<base::DictionaryValue> decrypted_onc = |
| 22 Decrypt("test0000", *encrypted_onc, &error); | 21 Decrypt("test0000", *encrypted_onc); |
| 23 | 22 |
| 24 EXPECT_EQ(NULL, decrypted_onc.get()); | 23 EXPECT_EQ(NULL, decrypted_onc.get()); |
| 25 EXPECT_FALSE(error.empty()); | |
| 26 } | 24 } |
| 27 | 25 |
| 28 TEST(ONCDecrypterTest, BrokenEncryptionZeroIterations) { | 26 TEST(ONCDecrypterTest, BrokenEncryptionZeroIterations) { |
| 29 scoped_ptr<base::DictionaryValue> encrypted_onc = | 27 scoped_ptr<base::DictionaryValue> encrypted_onc = |
| 30 test_utils::ReadTestDictionary("broken-encrypted-zero-iterations.onc"); | 28 test_utils::ReadTestDictionary("broken-encrypted-zero-iterations.onc"); |
| 31 | 29 |
| 32 std::string error; | 30 std::string error; |
| 33 scoped_ptr<base::DictionaryValue> decrypted_onc = | 31 scoped_ptr<base::DictionaryValue> decrypted_onc = |
| 34 Decrypt("test0000", *encrypted_onc, &error); | 32 Decrypt("test0000", *encrypted_onc); |
| 35 | 33 |
| 36 EXPECT_EQ(NULL, decrypted_onc.get()); | 34 EXPECT_EQ(NULL, decrypted_onc.get()); |
| 37 EXPECT_FALSE(error.empty()); | |
| 38 } | 35 } |
| 39 | 36 |
| 40 TEST(ONCDecrypterTest, LoadEncryptedOnc) { | 37 TEST(ONCDecrypterTest, LoadEncryptedOnc) { |
| 41 scoped_ptr<base::DictionaryValue> encrypted_onc = | 38 scoped_ptr<base::DictionaryValue> encrypted_onc = |
| 42 test_utils::ReadTestDictionary("encrypted.onc"); | 39 test_utils::ReadTestDictionary("encrypted.onc"); |
| 43 scoped_ptr<base::DictionaryValue> expected_decrypted_onc = | 40 scoped_ptr<base::DictionaryValue> expected_decrypted_onc = |
| 44 test_utils::ReadTestDictionary("decrypted.onc"); | 41 test_utils::ReadTestDictionary("decrypted.onc"); |
| 45 | 42 |
| 46 std::string error; | 43 std::string error; |
| 47 scoped_ptr<base::DictionaryValue> actual_decrypted_onc = | 44 scoped_ptr<base::DictionaryValue> actual_decrypted_onc = |
| 48 Decrypt("test0000", *encrypted_onc, &error); | 45 Decrypt("test0000", *encrypted_onc); |
| 49 | 46 |
| 50 base::DictionaryValue emptyDict; | 47 base::DictionaryValue emptyDict; |
| 51 EXPECT_TRUE(test_utils::Equals(expected_decrypted_onc.get(), | 48 EXPECT_TRUE(test_utils::Equals(expected_decrypted_onc.get(), |
| 52 actual_decrypted_onc.get())); | 49 actual_decrypted_onc.get())); |
| 53 EXPECT_TRUE(error.empty()) << error; | |
| 54 } | 50 } |
| 55 | 51 |
| 56 } // namespace onc | 52 } // namespace onc |
| 57 } // namespace chromeos | 53 } // namespace chromeos |
| OLD | NEW |