OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 Base64Encode(const std::string& value, std::string* encoded) { |
Mattias Nissler (ping if slow)
2014/04/24 12:20:36
side note: The name of this function is misleading
Joao da Silva
2014/04/24 13:22:24
Done.
| |
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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
OLD | NEW |