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