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

Side by Side Diff: chrome/browser/policy/cloud/component_cloud_policy_browsertest.cc

Issue 233423002: Don't upload extension IDs in the cloud policy protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed nits Created 6 years, 7 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 | « no previous file | chrome/browser/policy/test/policy_testserver.py » ('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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <string> 5 #include <string>
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 using testing::InvokeWithoutArgs; 48 using testing::InvokeWithoutArgs;
49 using testing::Mock; 49 using testing::Mock;
50 using testing::Return; 50 using testing::Return;
51 using testing::_; 51 using testing::_;
52 52
53 namespace em = enterprise_management; 53 namespace em = enterprise_management;
54 54
55 namespace policy { 55 namespace policy {
56 56
57 namespace {
58
57 const char kDMToken[] = "dmtoken"; 59 const char kDMToken[] = "dmtoken";
58 const char kDeviceID[] = "deviceid"; 60 const char kDeviceID[] = "deviceid";
59 61
60 const char kTestExtension[] = "kjmkgkdkpedkejedfhmfcenooemhbpbo"; 62 const char kTestExtension[] = "kjmkgkdkpedkejedfhmfcenooemhbpbo";
61 63
62 const base::FilePath::CharType kTestExtensionPath[] = 64 const base::FilePath::CharType kTestExtensionPath[] =
63 FILE_PATH_LITERAL("extensions/managed_extension"); 65 FILE_PATH_LITERAL("extensions/managed_extension");
64 66
65 const char kTestPolicy[] = 67 const char kTestPolicy[] =
66 "{" 68 "{"
(...skipping 10 matching lines...) Expand all
77 79
78 const char kTestPolicy2[] = 80 const char kTestPolicy2[] =
79 "{" 81 "{"
80 " \"Another\": {" 82 " \"Another\": {"
81 " \"Value\": \"turn_it_off\"" 83 " \"Value\": \"turn_it_off\""
82 " }" 84 " }"
83 "}"; 85 "}";
84 86
85 const char kTestPolicy2JSON[] = "{\"Another\":\"turn_it_off\"}"; 87 const char kTestPolicy2JSON[] = "{\"Another\":\"turn_it_off\"}";
86 88
89 #if !defined(OS_CHROMEOS)
87 // Same encoding as ResourceCache does for its keys. 90 // Same encoding as ResourceCache does for its keys.
88 bool Base64Encode(const std::string& value, std::string* encoded) { 91 bool Base64UrlEncode(const std::string& value, std::string* encoded) {
89 if (value.empty()) 92 if (value.empty())
90 return false; 93 return false;
91 base::Base64Encode(value, encoded); 94 base::Base64Encode(value, encoded);
92 base::ReplaceChars(*encoded, "+", "-", encoded); 95 base::ReplaceChars(*encoded, "+", "-", encoded);
93 base::ReplaceChars(*encoded, "/", "_", encoded); 96 base::ReplaceChars(*encoded, "/", "_", encoded);
94 return true; 97 return true;
95 } 98 }
99 #endif
100
101 } // namespace
96 102
97 class ComponentCloudPolicyTest : public ExtensionBrowserTest { 103 class ComponentCloudPolicyTest : public ExtensionBrowserTest {
98 protected: 104 protected:
99 ComponentCloudPolicyTest() {} 105 ComponentCloudPolicyTest() {}
100 virtual ~ComponentCloudPolicyTest() {} 106 virtual ~ComponentCloudPolicyTest() {}
101 107
102 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 108 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
103 ExtensionBrowserTest::SetUpCommandLine(command_line); 109 ExtensionBrowserTest::SetUpCommandLine(command_line);
104 #if defined(OS_CHROMEOS) 110 #if defined(OS_CHROMEOS)
105 // ExtensionBrowserTest sets the login users to a non-managed value; 111 // ExtensionBrowserTest sets the login users to a non-managed value;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 // get policy for components working again. 293 // get policy for components working again.
288 #if !defined(OS_CHROMEOS) 294 #if !defined(OS_CHROMEOS)
289 IN_PROC_BROWSER_TEST_F(ComponentCloudPolicyTest, SignOutAndBackIn) { 295 IN_PROC_BROWSER_TEST_F(ComponentCloudPolicyTest, SignOutAndBackIn) {
290 // Read the initial policy. 296 // Read the initial policy.
291 ExtensionTestMessageListener initial_policy_listener(kTestPolicyJSON, true); 297 ExtensionTestMessageListener initial_policy_listener(kTestPolicyJSON, true);
292 event_listener_->Reply("get-policy-Name"); 298 event_listener_->Reply("get-policy-Name");
293 EXPECT_TRUE(initial_policy_listener.WaitUntilSatisfied()); 299 EXPECT_TRUE(initial_policy_listener.WaitUntilSatisfied());
294 300
295 // Verify that the policy cache exists. 301 // Verify that the policy cache exists.
296 std::string cache_key; 302 std::string cache_key;
297 ASSERT_TRUE(Base64Encode("extension-policy", &cache_key)); 303 ASSERT_TRUE(Base64UrlEncode("extension-policy", &cache_key));
298 std::string cache_subkey; 304 std::string cache_subkey;
299 ASSERT_TRUE(Base64Encode(kTestExtension, &cache_subkey)); 305 ASSERT_TRUE(Base64UrlEncode(kTestExtension, &cache_subkey));
300 base::FilePath cache_path = browser()->profile()->GetPath() 306 base::FilePath cache_path = browser()->profile()->GetPath()
301 .Append(FILE_PATH_LITERAL("Policy")) 307 .Append(FILE_PATH_LITERAL("Policy"))
302 .Append(FILE_PATH_LITERAL("Components")) 308 .Append(FILE_PATH_LITERAL("Components"))
303 .AppendASCII(cache_key) 309 .AppendASCII(cache_key)
304 .AppendASCII(cache_subkey); 310 .AppendASCII(cache_subkey);
305 EXPECT_TRUE(base::PathExists(cache_path)); 311 EXPECT_TRUE(base::PathExists(cache_path));
306 312
307 // Now sign-out. The policy cache should be removed, and the extension should 313 // Now sign-out. The policy cache should be removed, and the extension should
308 // get an empty policy update. 314 // get an empty policy update.
309 ExtensionTestMessageListener event_listener("event", true); 315 ExtensionTestMessageListener event_listener("event", true);
(...skipping 18 matching lines...) Expand all
328 ExtensionTestMessageListener signin_policy_listener(kTestPolicyJSON, true); 334 ExtensionTestMessageListener signin_policy_listener(kTestPolicyJSON, true);
329 event_listener2.Reply("get-policy-Name"); 335 event_listener2.Reply("get-policy-Name");
330 EXPECT_TRUE(signin_policy_listener.WaitUntilSatisfied()); 336 EXPECT_TRUE(signin_policy_listener.WaitUntilSatisfied());
331 337
332 // And the cache is back. 338 // And the cache is back.
333 EXPECT_TRUE(base::PathExists(cache_path)); 339 EXPECT_TRUE(base::PathExists(cache_path));
334 } 340 }
335 #endif 341 #endif
336 342
337 } // namespace policy 343 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/policy/test/policy_testserver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698