| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <cryptohi.h> | 5 #include <cryptohi.h> |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" | 9 #include "chrome/browser/chromeos/policy/device_policy_cros_browser_test.h" |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 DeviceStatus device_status_; | 161 DeviceStatus device_status_; |
| 162 UserAffiliation user_affiliation_; | 162 UserAffiliation user_affiliation_; |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 class EnterprisePlatformKeysTest | 165 class EnterprisePlatformKeysTest |
| 166 : public ExtensionApiTest, | 166 : public ExtensionApiTest, |
| 167 public ::testing::WithParamInterface<Params> { | 167 public ::testing::WithParamInterface<Params> { |
| 168 public: | 168 public: |
| 169 EnterprisePlatformKeysTest() {} | 169 EnterprisePlatformKeysTest() {} |
| 170 | 170 |
| 171 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 171 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 172 ExtensionApiTest::SetUpCommandLine(command_line); | 172 ExtensionApiTest::SetUpCommandLine(command_line); |
| 173 | 173 |
| 174 // Enable the WebCrypto API. | 174 // Enable the WebCrypto API. |
| 175 command_line->AppendSwitch( | 175 command_line->AppendSwitch( |
| 176 switches::kEnableExperimentalWebPlatformFeatures); | 176 switches::kEnableExperimentalWebPlatformFeatures); |
| 177 | 177 |
| 178 std::string user_email = "someuser@anydomain.com"; | 178 std::string user_email = "someuser@anydomain.com"; |
| 179 | 179 |
| 180 // The command line flag kLoginUser determines the user's email and thus | 180 // The command line flag kLoginUser determines the user's email and thus |
| 181 // his affiliation to the domain that the device is enrolled to. | 181 // his affiliation to the domain that the device is enrolled to. |
| 182 if (GetParam().user_affiliation_ == USER_AFFILIATION_ENROLLED_DOMAIN) | 182 if (GetParam().user_affiliation_ == USER_AFFILIATION_ENROLLED_DOMAIN) |
| 183 user_email = chromeos::login::kStubUser; | 183 user_email = chromeos::login::kStubUser; |
| 184 | 184 |
| 185 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, user_email); | 185 command_line->AppendSwitchASCII(chromeos::switches::kLoginUser, user_email); |
| 186 } | 186 } |
| 187 | 187 |
| 188 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 188 virtual void SetUpInProcessBrowserTestFixture() override { |
| 189 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 189 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
| 190 | 190 |
| 191 if (GetParam().device_status_ == DEVICE_STATUS_ENROLLED) { | 191 if (GetParam().device_status_ == DEVICE_STATUS_ENROLLED) { |
| 192 device_policy_test_helper_.device_policy()->policy_data().set_username( | 192 device_policy_test_helper_.device_policy()->policy_data().set_username( |
| 193 chromeos::login::kStubUser); | 193 chromeos::login::kStubUser); |
| 194 | 194 |
| 195 device_policy_test_helper_.device_policy()->Build(); | 195 device_policy_test_helper_.device_policy()->Build(); |
| 196 device_policy_test_helper_.MarkAsEnterpriseOwned(); | 196 device_policy_test_helper_.MarkAsEnterpriseOwned(); |
| 197 } | 197 } |
| 198 | 198 |
| 199 EXPECT_CALL(policy_provider_, IsInitializationComplete(testing::_)) | 199 EXPECT_CALL(policy_provider_, IsInitializationComplete(testing::_)) |
| 200 .WillRepeatedly(testing::Return(true)); | 200 .WillRepeatedly(testing::Return(true)); |
| 201 policy_provider_.SetAutoRefresh(); | 201 policy_provider_.SetAutoRefresh(); |
| 202 policy::BrowserPolicyConnector::SetPolicyProviderForTesting( | 202 policy::BrowserPolicyConnector::SetPolicyProviderForTesting( |
| 203 &policy_provider_); | 203 &policy_provider_); |
| 204 } | 204 } |
| 205 | 205 |
| 206 virtual void SetUpOnMainThread() OVERRIDE { | 206 virtual void SetUpOnMainThread() override { |
| 207 if (GetParam().system_token_ == SYSTEM_TOKEN_EXISTS) { | 207 if (GetParam().system_token_ == SYSTEM_TOKEN_EXISTS) { |
| 208 base::RunLoop loop; | 208 base::RunLoop loop; |
| 209 content::BrowserThread::PostTask( | 209 content::BrowserThread::PostTask( |
| 210 content::BrowserThread::IO, | 210 content::BrowserThread::IO, |
| 211 FROM_HERE, | 211 FROM_HERE, |
| 212 base::Bind(&EnterprisePlatformKeysTest::SetUpTestSystemSlotOnIO, | 212 base::Bind(&EnterprisePlatformKeysTest::SetUpTestSystemSlotOnIO, |
| 213 base::Unretained(this), | 213 base::Unretained(this), |
| 214 browser()->profile()->GetResourceContext(), | 214 browser()->profile()->GetResourceContext(), |
| 215 loop.QuitClosure())); | 215 loop.QuitClosure())); |
| 216 loop.Run(); | 216 loop.Run(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 231 browser()->profile(), | 231 browser()->profile(), |
| 232 base::Bind(&EnterprisePlatformKeysTest::DidGetCertDatabase, | 232 base::Bind(&EnterprisePlatformKeysTest::DidGetCertDatabase, |
| 233 base::Unretained(this), | 233 base::Unretained(this), |
| 234 loop.QuitClosure())); | 234 loop.QuitClosure())); |
| 235 loop.Run(); | 235 loop.Run(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 SetPolicy(); | 238 SetPolicy(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 virtual void TearDownOnMainThread() OVERRIDE { | 241 virtual void TearDownOnMainThread() override { |
| 242 ExtensionApiTest::TearDownOnMainThread(); | 242 ExtensionApiTest::TearDownOnMainThread(); |
| 243 | 243 |
| 244 if (GetParam().system_token_ == SYSTEM_TOKEN_EXISTS) { | 244 if (GetParam().system_token_ == SYSTEM_TOKEN_EXISTS) { |
| 245 base::RunLoop loop; | 245 base::RunLoop loop; |
| 246 content::BrowserThread::PostTask( | 246 content::BrowserThread::PostTask( |
| 247 content::BrowserThread::IO, | 247 content::BrowserThread::IO, |
| 248 FROM_HERE, | 248 FROM_HERE, |
| 249 base::Bind(&EnterprisePlatformKeysTest::TearDownTestSystemSlotOnIO, | 249 base::Bind(&EnterprisePlatformKeysTest::TearDownTestSystemSlotOnIO, |
| 250 base::Unretained(this), | 250 base::Unretained(this), |
| 251 loop.QuitClosure())); | 251 loop.QuitClosure())); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 ExtensionService* service = | 376 ExtensionService* service = |
| 377 extensions::ExtensionSystem::Get(profile())->extension_service(); | 377 extensions::ExtensionSystem::Get(profile())->extension_service(); |
| 378 const extensions::Extension* extension = | 378 const extensions::Extension* extension = |
| 379 GetExtensionByPath(service->extensions(), extension_path); | 379 GetExtensionByPath(service->extensions(), extension_path); |
| 380 ASSERT_FALSE(extension->install_warnings().empty()); | 380 ASSERT_FALSE(extension->install_warnings().empty()); |
| 381 EXPECT_EQ( | 381 EXPECT_EQ( |
| 382 "'enterprise.platformKeys' is not allowed for specified install " | 382 "'enterprise.platformKeys' is not allowed for specified install " |
| 383 "location.", | 383 "location.", |
| 384 extension->install_warnings()[0].message); | 384 extension->install_warnings()[0].message); |
| 385 } | 385 } |
| OLD | NEW |