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

Side by Side Diff: chromeos/network/onc/onc_utils_unittest.cc

Issue 11664005: Extending the translation from ONC to Shill. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased. Created 7 years, 11 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 unified diff | Download patch
« no previous file with comments | « chromeos/network/onc/onc_utils.cc ('k') | chromeos/test/data/network/shill_ethernet.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chromeos/network/onc/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 "chromeos/network/onc/onc_test_utils.h" 10 #include "chromeos/network/onc/onc_test_utils.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 std::string error; 43 std::string error;
44 scoped_ptr<base::DictionaryValue> actual_decrypted_onc = 44 scoped_ptr<base::DictionaryValue> actual_decrypted_onc =
45 Decrypt("test0000", *encrypted_onc); 45 Decrypt("test0000", *encrypted_onc);
46 46
47 base::DictionaryValue emptyDict; 47 base::DictionaryValue emptyDict;
48 EXPECT_TRUE(test_utils::Equals(expected_decrypted_onc.get(), 48 EXPECT_TRUE(test_utils::Equals(expected_decrypted_onc.get(),
49 actual_decrypted_onc.get())); 49 actual_decrypted_onc.get()));
50 } 50 }
51 51
52 namespace {
53
54 const char* kLoginId = "hans";
55 const char* kLoginEmail = "hans@my.domain.com";
56
57 class StringSubstitutionStub : public StringSubstitution {
58 public:
59 StringSubstitutionStub() {}
60 virtual bool GetSubstitute(std::string placeholder,
61 std::string* substitute) const {
62 if (placeholder == substitutes::kLoginIDField)
63 *substitute = kLoginId;
64 else if (placeholder == substitutes::kEmailField)
65 *substitute = kLoginEmail;
66 else
67 return false;
68 return true;
69 }
70 private:
71 DISALLOW_COPY_AND_ASSIGN(StringSubstitutionStub);
72 };
73
74 } // namespace
75
76 TEST(ONCStringExpansion, OpenVPN) {
77 scoped_ptr<base::DictionaryValue> vpn_onc =
78 test_utils::ReadTestDictionary("valid_openvpn.onc");
79
80 StringSubstitutionStub substitution;
81 ExpandStringsInOncObject(kNetworkConfigurationSignature, substitution,
82 vpn_onc.get());
83
84 std::string actual_expanded;
85 vpn_onc->GetString("VPN.OpenVPN.Username", &actual_expanded);
86 EXPECT_EQ(actual_expanded, std::string("abc ") + kLoginEmail + " def");
87 }
88
89 TEST(ONCStringExpansion, WiFi_EAP) {
90 scoped_ptr<base::DictionaryValue> wifi_onc =
91 test_utils::ReadTestDictionary("valid_wifi_clientcert.onc");
92
93 StringSubstitutionStub substitution;
94 ExpandStringsInOncObject(kNetworkConfigurationSignature, substitution,
95 wifi_onc.get());
96
97 std::string actual_expanded;
98 wifi_onc->GetString("WiFi.EAP.Identity", &actual_expanded);
99 EXPECT_EQ(actual_expanded, std::string("abc ") + kLoginId + "@my.domain.com");
100 }
101
52 } // namespace onc 102 } // namespace onc
53 } // namespace chromeos 103 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_utils.cc ('k') | chromeos/test/data/network/shill_ethernet.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698