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

Side by Side Diff: google_apis/google_api_keys_unittest.cc

Issue 10941034: Adding unit tests for google_api_keys functionality. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restrict google_api_keys tests to Linux and MacOSX. Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « google_apis/google_api_keys.cc ('k') | google_apis/google_apis.gyp » ('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 // Unit tests for implementation of google_api_keys namespace. 5 // Unit tests for implementation of google_api_keys namespace.
6 // 6 //
7 // Because the file deals with a lot of preprocessor defines and 7 // Because the file deals with a lot of preprocessor defines and
8 // optionally includes an internal header, the way we test is by 8 // optionally includes an internal header, the way we test is by
9 // including the .cc file multiple times with different defines set. 9 // including the .cc file multiple times with different defines set.
10 // This is a little unorthodox, but it lets us test the behavior as 10 // This is a little unorthodox, but it lets us test the behavior as
11 // close to unmodified as possible. 11 // close to unmodified as possible.
12 12
13 #include "build/build_config.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 namespace { 16 // The Win builders fail (with a linker crash) when trying to link
17 // unit_tests, and the Android builders complain about multiply
18 // defined symbols (likely they don't do name decoration as well as
19 // the Mac and Linux linkers). Therefore these tests are only built
20 // and run on Mac and Linux, which should provide plenty of coverage
21 // since there are no platform-specific bits in this code.
22 #if defined(OS_LINUX) || defined(OS_MACOSX)
16 23
17 #if defined(GOOGLE_CHROME_BUILD) or defined(USE_OFFICIAL_GOOGLE_API_KEYS) 24 // We need to include this once at global scope so things like STL and
25 // classes from base do not get defined again within the different
26 // namespaces below.
27 #include "google_apis/google_api_keys.cc"
28
29 // These are the (temporary) default values for OAuth IDs and secrets.
30 static const char kDefaultNonOfficialAPIKey[] =
31 "AIzaSyBHDrl33hwRp4rMQY0ziRbj8K9LPA6vUCY";
32 static const char kDefaultNonOfficialClientID[] =
33 "609716072145.apps.googleusercontent.com";
34 static const char kDefaultNonOfficialClientSecret[] =
35 "WF4uG3gJzEH0KLpS7OuFBDux";
36
37 struct EnvironmentCache {
38 public:
39 EnvironmentCache() : variable_name(NULL), was_set(false) {}
40
41 const char* variable_name;
42 bool was_set;
43 std::string value;
44 };
45
46 class GoogleAPIKeysTest : public testing::Test {
47 public:
48 GoogleAPIKeysTest() : env_(base::Environment::Create()) {
49 env_cache_[0].variable_name = "GOOGLE_API_KEY";
50 env_cache_[1].variable_name = "GOOGLE_CLIENT_ID_MAIN";
51 env_cache_[2].variable_name = "GOOGLE_CLIENT_SECRET_MAIN";
52 env_cache_[3].variable_name = "GOOGLE_CLIENT_ID_CLOUD_PRINT";
53 env_cache_[4].variable_name = "GOOGLE_CLIENT_SECRET_CLOUD_PRINT";
54 env_cache_[5].variable_name = "GOOGLE_CLIENT_ID_REMOTING";
55 env_cache_[6].variable_name = "GOOGLE_CLIENT_SECRET_REMOTING";
56 env_cache_[7].variable_name = "GOOGLE_DEFAULT_CLIENT_ID";
57 env_cache_[8].variable_name = "GOOGLE_DEFAULT_CLIENT_SECRET";
58 }
59
60 void SetUp() {
61 // Unset all environment variables that can affect these tests,
62 // for the duration of the tests.
63 for (size_t i = 0; i < arraysize(env_cache_); ++i) {
64 EnvironmentCache& cache = env_cache_[i];
65 cache.was_set = env_->HasVar(cache.variable_name);
66 cache.value.clear();
67 if (cache.was_set) {
68 env_->GetVar(cache.variable_name, &cache.value);
69 env_->UnSetVar(cache.variable_name);
70 }
71 }
72 }
73
74 void TearDown() {
75 // Restore environment.
76 for (size_t i = 0; i < arraysize(env_cache_); ++i) {
77 EnvironmentCache& cache = env_cache_[i];
78 if (cache.was_set) {
79 env_->SetVar(cache.variable_name, cache.value);
80 }
81 }
82 }
83
84 private:
85 scoped_ptr<base::Environment> env_;
86
87 // Why 3? It is for GOOGLE_API_KEY, GOOGLE_DEFAULT_CLIENT_ID and
88 // GOOGLE_DEFAULT_CLIENT_SECRET.
89 //
90 // Why 2 times CLIENT_NUM_ITEMS? This is the number of different
91 // clients in the OAuth2Client enumeration, and for each of these we
92 // have both an ID and a secret.
93 EnvironmentCache env_cache_[3 + 2 * google_apis::CLIENT_NUM_ITEMS];
94 };
95
96 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
18 // Test official build behavior, since we are in a checkout where this 97 // Test official build behavior, since we are in a checkout where this
19 // is possible. 98 // is possible.
20 namespace official_build { 99 namespace official_build {
21 100
101 // We start every test by creating a clean environment for the
102 // preprocessor defines used in google_api_keys.cc
103 #undef DUMMY_API_TOKEN
22 #undef GOOGLE_API_KEY 104 #undef GOOGLE_API_KEY
23 #undef GOOGLE_CLIENT_ID_MAIN 105 #undef GOOGLE_CLIENT_ID_MAIN
24 #undef GOOGLE_CLIENT_SECRET_MAIN 106 #undef GOOGLE_CLIENT_SECRET_MAIN
25 #undef GOOGLE_CLIENT_ID_CLOUD_PRINT 107 #undef GOOGLE_CLIENT_ID_CLOUD_PRINT
26 #undef GOOGLE_CLIENT_SECRET_CLOUD_PRINT 108 #undef GOOGLE_CLIENT_SECRET_CLOUD_PRINT
27 #undef GOOGLE_CLIENT_ID_REMOTING 109 #undef GOOGLE_CLIENT_ID_REMOTING
28 #undef GOOGLE_CLIENT_SECRET_REMOTING 110 #undef GOOGLE_CLIENT_SECRET_REMOTING
111 #undef GOOGLE_DEFAULT_CLIENT_ID
112 #undef GOOGLE_DEFAULT_CLIENT_SECRET
29 113
30 // Try setting some keys, these should be ignored since it's a build 114 // Try setting some keys, these should be ignored since it's a build
31 // with official keys. 115 // with official keys.
32 #define GOOGLE_API_KEY "bogus api key" 116 #define GOOGLE_API_KEY "bogus api_key"
33 #define GOOGLE_CLIENT_ID_MAIN "bogus client_id_main" 117 #define GOOGLE_CLIENT_ID_MAIN "bogus client_id_main"
34 118
35 #include "google_apis/google_api_keys.cc" 119 // Undef include guard so things get defined again, within this namespace.
36 120 #undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
37 TEST(GoogleAPIKeys, OfficialKeys) { 121 #undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
38 std::string api_key = g_api_key_cache.Get().api_key(); 122 #include "google_apis/google_api_keys.cc"
39 std::string id_main = g_api_key_cache.Get().GetClientID(CLIENT_MAIN);
40 std::string secret_main = g_api_key_cache.Get().GetClientSecret(CLIENT_MAIN);
41 std::string id_cloud_print =
42 g_api_key_cache.Get().GetClientID(CLIENT_CLOUD_PRINT);
43 std::string secret_cloud_print =
44 g_api_key_cache.Get().GetClientSecret(CLIENT_CLOUD_PRINT);
45 std::string id_remoting = g_api_key_cache.Get().GetClientID(CLIENT_REMOTING);
46 std::string secret_remoting =
47 g_api_key_cache.Get().GetClientSecret(CLIENT_REMOTING);
48
49 ASSERT_TRUE(api_key.size() == 0);
50 }
51 123
52 } // namespace official_build 124 } // namespace official_build
53 #endif // defined(GOOGLE_CHROME_BUILD) or defined(USE_OFFICIAL_GOOGLE_API_KEYS) 125
54 126 TEST_F(GoogleAPIKeysTest, OfficialKeys) {
55 127 namespace testcase = official_build::google_apis;
56 } // namespace 128
129 std::string api_key = testcase::g_api_key_cache.Get().api_key();
130 std::string id_main = testcase::g_api_key_cache.Get().GetClientID(
131 testcase::CLIENT_MAIN);
132 std::string secret_main = testcase::g_api_key_cache.Get().GetClientSecret(
133 testcase::CLIENT_MAIN);
134 std::string id_cloud_print =
135 testcase::g_api_key_cache.Get().GetClientID(
136 testcase::CLIENT_CLOUD_PRINT);
137 std::string secret_cloud_print =
138 testcase::g_api_key_cache.Get().GetClientSecret(
139 testcase::CLIENT_CLOUD_PRINT);
140 std::string id_remoting = testcase::g_api_key_cache.Get().GetClientID(
141 testcase::CLIENT_REMOTING);
142 std::string secret_remoting =
143 testcase::g_api_key_cache.Get().GetClientSecret(
144 testcase::CLIENT_REMOTING);
145
146 EXPECT_NE(0u, api_key.size());
147 EXPECT_NE(DUMMY_API_TOKEN, api_key);
148 EXPECT_NE("bogus api_key", api_key);
149 EXPECT_NE(kDefaultNonOfficialAPIKey, api_key);
150
151 EXPECT_NE(0u, id_main.size());
152 EXPECT_NE(DUMMY_API_TOKEN, id_main);
153 EXPECT_NE("bogus client_id_main", id_main);
154 EXPECT_NE(kDefaultNonOfficialClientID, id_main);
155
156 EXPECT_NE(0u, secret_main.size());
157 EXPECT_NE(DUMMY_API_TOKEN, secret_main);
158 EXPECT_NE(kDefaultNonOfficialClientSecret, secret_main);
159
160 EXPECT_NE(0u, id_cloud_print.size());
161 EXPECT_NE(DUMMY_API_TOKEN, id_cloud_print);
162 EXPECT_NE(kDefaultNonOfficialClientID, id_cloud_print);
163
164 EXPECT_NE(0u, secret_cloud_print.size());
165 EXPECT_NE(DUMMY_API_TOKEN, secret_cloud_print);
166 EXPECT_NE(kDefaultNonOfficialClientSecret, secret_cloud_print);
167
168 EXPECT_NE(0u, id_remoting.size());
169 EXPECT_NE(DUMMY_API_TOKEN, id_remoting);
170 EXPECT_NE(kDefaultNonOfficialClientID, id_remoting);
171
172 EXPECT_NE(0u, secret_remoting.size());
173 EXPECT_NE(DUMMY_API_TOKEN, secret_remoting);
174 EXPECT_NE(kDefaultNonOfficialClientSecret, secret_remoting);
175 }
176 #endif // defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
177
178 // After this test, for the remainder of this compilation unit, we
179 // need official keys to not be used.
180 #undef GOOGLE_CHROME_BUILD
181 #undef USE_OFFICIAL_GOOGLE_API_KEYS
182
183 // Test the set of keys temporarily baked into Chromium by default.
184 namespace default_keys {
185
186 // We start every test by creating a clean environment for the
187 // preprocessor defines used in google_api_keys.cc
188 #undef DUMMY_API_TOKEN
189 #undef GOOGLE_API_KEY
190 #undef GOOGLE_CLIENT_ID_MAIN
191 #undef GOOGLE_CLIENT_SECRET_MAIN
192 #undef GOOGLE_CLIENT_ID_CLOUD_PRINT
193 #undef GOOGLE_CLIENT_SECRET_CLOUD_PRINT
194 #undef GOOGLE_CLIENT_ID_REMOTING
195 #undef GOOGLE_CLIENT_SECRET_REMOTING
196 #undef GOOGLE_DEFAULT_CLIENT_ID
197 #undef GOOGLE_DEFAULT_CLIENT_SECRET
198
199 // Undef include guard so things get defined again, within this namespace.
200 #undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
201 #undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
202 #include "google_apis/google_api_keys.cc"
203
204 } // namespace default_keys
205
206 TEST_F(GoogleAPIKeysTest, DefaultKeys) {
207 namespace testcase = default_keys::google_apis;
208
209 std::string api_key = testcase::g_api_key_cache.Get().api_key();
210 std::string id_main = testcase::g_api_key_cache.Get().GetClientID(
211 testcase::CLIENT_MAIN);
212 std::string secret_main = testcase::g_api_key_cache.Get().GetClientSecret(
213 testcase::CLIENT_MAIN);
214 std::string id_cloud_print =
215 testcase::g_api_key_cache.Get().GetClientID(
216 testcase::CLIENT_CLOUD_PRINT);
217 std::string secret_cloud_print =
218 testcase::g_api_key_cache.Get().GetClientSecret(
219 testcase::CLIENT_CLOUD_PRINT);
220 std::string id_remoting = testcase::g_api_key_cache.Get().GetClientID(
221 testcase::CLIENT_REMOTING);
222 std::string secret_remoting =
223 testcase::g_api_key_cache.Get().GetClientSecret(
224 testcase::CLIENT_REMOTING);
225
226 EXPECT_EQ(kDefaultNonOfficialAPIKey, api_key);
227 EXPECT_EQ(kDefaultNonOfficialClientID, id_main);
228 EXPECT_EQ(kDefaultNonOfficialClientSecret, secret_main);
229 EXPECT_EQ(kDefaultNonOfficialClientID, id_cloud_print);
230 EXPECT_EQ(kDefaultNonOfficialClientSecret, secret_cloud_print);
231 EXPECT_EQ(kDefaultNonOfficialClientID, id_remoting);
232 EXPECT_EQ(kDefaultNonOfficialClientSecret, secret_remoting);
233 }
234
235 // Override a couple of keys, leave the rest default.
236 namespace override_some_keys {
237
238 // We start every test by creating a clean environment for the
239 // preprocessor defines used in google_api_keys.cc
240 #undef DUMMY_API_TOKEN
241 #undef GOOGLE_API_KEY
242 #undef GOOGLE_CLIENT_ID_MAIN
243 #undef GOOGLE_CLIENT_SECRET_MAIN
244 #undef GOOGLE_CLIENT_ID_CLOUD_PRINT
245 #undef GOOGLE_CLIENT_SECRET_CLOUD_PRINT
246 #undef GOOGLE_CLIENT_ID_REMOTING
247 #undef GOOGLE_CLIENT_SECRET_REMOTING
248 #undef GOOGLE_DEFAULT_CLIENT_ID
249 #undef GOOGLE_DEFAULT_CLIENT_SECRET
250
251 #define GOOGLE_API_KEY "API_KEY override"
252 #define GOOGLE_CLIENT_ID_REMOTING "CLIENT_ID_REMOTING override"
253
254 // Undef include guard so things get defined again, within this namespace.
255 #undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
256 #undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
257 #include "google_apis/google_api_keys.cc"
258
259 } // namespace override_some_keys
260
261 TEST_F(GoogleAPIKeysTest, OverrideSomeKeys) {
262 namespace testcase = override_some_keys::google_apis;
263
264 std::string api_key = testcase::g_api_key_cache.Get().api_key();
265 std::string id_main = testcase::g_api_key_cache.Get().GetClientID(
266 testcase::CLIENT_MAIN);
267 std::string secret_main = testcase::g_api_key_cache.Get().GetClientSecret(
268 testcase::CLIENT_MAIN);
269 std::string id_cloud_print =
270 testcase::g_api_key_cache.Get().GetClientID(
271 testcase::CLIENT_CLOUD_PRINT);
272 std::string secret_cloud_print =
273 testcase::g_api_key_cache.Get().GetClientSecret(
274 testcase::CLIENT_CLOUD_PRINT);
275 std::string id_remoting = testcase::g_api_key_cache.Get().GetClientID(
276 testcase::CLIENT_REMOTING);
277 std::string secret_remoting =
278 testcase::g_api_key_cache.Get().GetClientSecret(
279 testcase::CLIENT_REMOTING);
280
281 EXPECT_EQ("API_KEY override", api_key);
282 EXPECT_EQ(kDefaultNonOfficialClientID, id_main);
283 EXPECT_EQ(kDefaultNonOfficialClientSecret, secret_main);
284 EXPECT_EQ(kDefaultNonOfficialClientID, id_cloud_print);
285 EXPECT_EQ(kDefaultNonOfficialClientSecret, secret_cloud_print);
286 EXPECT_EQ("CLIENT_ID_REMOTING override", id_remoting);
287 EXPECT_EQ(kDefaultNonOfficialClientSecret, secret_remoting);
288 }
289
290 // Override all keys.
291 namespace override_all_keys {
292
293 // We start every test by creating a clean environment for the
294 // preprocessor defines used in google_api_keys.cc
295 #undef DUMMY_API_TOKEN
296 #undef GOOGLE_API_KEY
297 #undef GOOGLE_CLIENT_ID_MAIN
298 #undef GOOGLE_CLIENT_SECRET_MAIN
299 #undef GOOGLE_CLIENT_ID_CLOUD_PRINT
300 #undef GOOGLE_CLIENT_SECRET_CLOUD_PRINT
301 #undef GOOGLE_CLIENT_ID_REMOTING
302 #undef GOOGLE_CLIENT_SECRET_REMOTING
303 #undef GOOGLE_DEFAULT_CLIENT_ID
304 #undef GOOGLE_DEFAULT_CLIENT_SECRET
305
306 #define GOOGLE_API_KEY "API_KEY"
307 #define GOOGLE_CLIENT_ID_MAIN "ID_MAIN"
308 #define GOOGLE_CLIENT_SECRET_MAIN "SECRET_MAIN"
309 #define GOOGLE_CLIENT_ID_CLOUD_PRINT "ID_CLOUD_PRINT"
310 #define GOOGLE_CLIENT_SECRET_CLOUD_PRINT "SECRET_CLOUD_PRINT"
311 #define GOOGLE_CLIENT_ID_REMOTING "ID_REMOTING"
312 #define GOOGLE_CLIENT_SECRET_REMOTING "SECRET_REMOTING"
313
314 // Undef include guard so things get defined again, within this namespace.
315 #undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
316 #undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
317 #include "google_apis/google_api_keys.cc"
318
319 } // namespace override_all_keys
320
321 TEST_F(GoogleAPIKeysTest, OverrideAllKeys) {
322 namespace testcase = override_all_keys::google_apis;
323
324 std::string api_key = testcase::g_api_key_cache.Get().api_key();
325 std::string id_main = testcase::g_api_key_cache.Get().GetClientID(
326 testcase::CLIENT_MAIN);
327 std::string secret_main = testcase::g_api_key_cache.Get().GetClientSecret(
328 testcase::CLIENT_MAIN);
329 std::string id_cloud_print =
330 testcase::g_api_key_cache.Get().GetClientID(
331 testcase::CLIENT_CLOUD_PRINT);
332 std::string secret_cloud_print =
333 testcase::g_api_key_cache.Get().GetClientSecret(
334 testcase::CLIENT_CLOUD_PRINT);
335 std::string id_remoting = testcase::g_api_key_cache.Get().GetClientID(
336 testcase::CLIENT_REMOTING);
337 std::string secret_remoting =
338 testcase::g_api_key_cache.Get().GetClientSecret(
339 testcase::CLIENT_REMOTING);
340
341 EXPECT_EQ("API_KEY", api_key);
342 EXPECT_EQ("ID_MAIN", id_main);
343 EXPECT_EQ("SECRET_MAIN", secret_main);
344 EXPECT_EQ("ID_CLOUD_PRINT", id_cloud_print);
345 EXPECT_EQ("SECRET_CLOUD_PRINT", secret_cloud_print);
346 EXPECT_EQ("ID_REMOTING", id_remoting);
347 EXPECT_EQ("SECRET_REMOTING", secret_remoting);
348 }
349
350 // Override all keys using both preprocessor defines and environment
351 // variables. The environment variables should win.
352 namespace override_all_keys_env {
353
354 // We start every test by creating a clean environment for the
355 // preprocessor defines used in google_api_keys.cc
356 #undef DUMMY_API_TOKEN
357 #undef GOOGLE_API_KEY
358 #undef GOOGLE_CLIENT_ID_MAIN
359 #undef GOOGLE_CLIENT_SECRET_MAIN
360 #undef GOOGLE_CLIENT_ID_CLOUD_PRINT
361 #undef GOOGLE_CLIENT_SECRET_CLOUD_PRINT
362 #undef GOOGLE_CLIENT_ID_REMOTING
363 #undef GOOGLE_CLIENT_SECRET_REMOTING
364 #undef GOOGLE_DEFAULT_CLIENT_ID
365 #undef GOOGLE_DEFAULT_CLIENT_SECRET
366
367 #define GOOGLE_API_KEY "API_KEY"
368 #define GOOGLE_CLIENT_ID_MAIN "ID_MAIN"
369 #define GOOGLE_CLIENT_SECRET_MAIN "SECRET_MAIN"
370 #define GOOGLE_CLIENT_ID_CLOUD_PRINT "ID_CLOUD_PRINT"
371 #define GOOGLE_CLIENT_SECRET_CLOUD_PRINT "SECRET_CLOUD_PRINT"
372 #define GOOGLE_CLIENT_ID_REMOTING "ID_REMOTING"
373 #define GOOGLE_CLIENT_SECRET_REMOTING "SECRET_REMOTING"
374
375 // Undef include guard so things get defined again, within this namespace.
376 #undef GOOGLE_APIS_GOOGLE_API_KEYS_H_
377 #undef GOOGLE_APIS_INTERNAL_GOOGLE_CHROME_API_KEYS_
378 #include "google_apis/google_api_keys.cc"
379
380 } // namespace override_all_keys_env
381
382 TEST_F(GoogleAPIKeysTest, OverrideAllKeysUsingEnvironment) {
383 namespace testcase = override_all_keys_env::google_apis;
384
385 scoped_ptr<base::Environment> env(base::Environment::Create());
386 env->SetVar("GOOGLE_API_KEY", "env-API_KEY");
387 env->SetVar("GOOGLE_CLIENT_ID_MAIN", "env-ID_MAIN");
388 env->SetVar("GOOGLE_CLIENT_ID_CLOUD_PRINT", "env-ID_CLOUD_PRINT");
389 env->SetVar("GOOGLE_CLIENT_ID_REMOTING", "env-ID_REMOTING");
390 env->SetVar("GOOGLE_CLIENT_SECRET_MAIN", "env-SECRET_MAIN");
391 env->SetVar("GOOGLE_CLIENT_SECRET_CLOUD_PRINT", "env-SECRET_CLOUD_PRINT");
392 env->SetVar("GOOGLE_CLIENT_SECRET_REMOTING", "env-SECRET_REMOTING");
393
394 // It's important that the first call to Get() only happen after the
395 // environment variables have been set.
396 std::string api_key = testcase::g_api_key_cache.Get().api_key();
397 std::string id_main = testcase::g_api_key_cache.Get().GetClientID(
398 testcase::CLIENT_MAIN);
399 std::string secret_main = testcase::g_api_key_cache.Get().GetClientSecret(
400 testcase::CLIENT_MAIN);
401 std::string id_cloud_print =
402 testcase::g_api_key_cache.Get().GetClientID(
403 testcase::CLIENT_CLOUD_PRINT);
404 std::string secret_cloud_print =
405 testcase::g_api_key_cache.Get().GetClientSecret(
406 testcase::CLIENT_CLOUD_PRINT);
407 std::string id_remoting = testcase::g_api_key_cache.Get().GetClientID(
408 testcase::CLIENT_REMOTING);
409 std::string secret_remoting =
410 testcase::g_api_key_cache.Get().GetClientSecret(
411 testcase::CLIENT_REMOTING);
412
413 EXPECT_EQ("env-API_KEY", api_key);
414 EXPECT_EQ("env-ID_MAIN", id_main);
415 EXPECT_EQ("env-SECRET_MAIN", secret_main);
416 EXPECT_EQ("env-ID_CLOUD_PRINT", id_cloud_print);
417 EXPECT_EQ("env-SECRET_CLOUD_PRINT", secret_cloud_print);
418 EXPECT_EQ("env-ID_REMOTING", id_remoting);
419 EXPECT_EQ("env-SECRET_REMOTING", secret_remoting);
420 }
421
422 #endif // defined(OS_LINUX) || defined(OS_MACOSX)
OLDNEW
« no previous file with comments | « google_apis/google_api_keys.cc ('k') | google_apis/google_apis.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698