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

Side by Side Diff: content/browser/renderer_host/media/webrtc_identity_service_host_unittest.cc

Issue 1948223005: ChildProcessSecurityPolicy::CanAccessDataForOrigin workaround to suppress bad kills (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 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
« no previous file with comments | « content/browser/child_process_security_policy_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 <deque> 5 #include <deque>
6 6
7 #include "content/browser/child_process_security_policy_impl.h" 7 #include "content/browser/child_process_security_policy_impl.h"
8 #include "content/browser/media/webrtc/webrtc_identity_store.h" 8 #include "content/browser/media/webrtc/webrtc_identity_store.h"
9 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h" 9 #include "content/browser/renderer_host/media/webrtc_identity_service_host.h"
10 #include "content/common/media/webrtc_identity_messages.h" 10 #include "content/common/media/webrtc_identity_messages.h"
11 #include "content/public/test/mock_resource_context.h" 11 #include "content/public/test/mock_resource_context.h"
12 #include "content/public/test/test_browser_thread_bundle.h" 12 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "content/test/test_content_browser_client.h" 13 #include "content/test/test_content_browser_client.h"
14 #include "ipc/ipc_message.h" 14 #include "ipc/ipc_message.h"
15 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 17
18 namespace content { 18 namespace content {
19 19
20 namespace { 20 namespace {
21 21
22 const char FAKE_URL[] = "http://fake.com"; 22 const char FAKE_URL[] = "http://www.fake.com";
23 const char FAKE_SITE[] = "http://fake.com";
24 const char OTHER_SITE[] = "https://other.com";
23 const char FAKE_FIRST_PARTY_URL[] = "http://fake.firstparty.com"; 25 const char FAKE_FIRST_PARTY_URL[] = "http://fake.firstparty.com";
24 const char FAKE_IDENTITY_NAME[] = "fake identity"; 26 const char FAKE_IDENTITY_NAME[] = "fake identity";
25 const char FAKE_COMMON_NAME[] = "fake common name"; 27 const char FAKE_COMMON_NAME[] = "fake common name";
26 const char FAKE_CERTIFICATE[] = "fake cert"; 28 const char FAKE_CERTIFICATE[] = "fake cert";
27 const char FAKE_PRIVATE_KEY[] = "fake private key"; 29 const char FAKE_PRIVATE_KEY[] = "fake private key";
28 const int FAKE_RENDERER_ID = 10; 30 const int FAKE_RENDERER_ID = 10;
29 const int FAKE_REQUEST_ID = 1; 31 const int FAKE_REQUEST_ID = 1;
30 32
31 class WebRTCIdentityServiceHostTestBrowserClient 33 class WebRTCIdentityServiceHostTestBrowserClient
32 : public TestContentBrowserClient { 34 : public TestContentBrowserClient {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 226
225 TEST_F(WebRTCIdentityServiceHostTest, TestOnRequestFailed) { 227 TEST_F(WebRTCIdentityServiceHostTest, TestOnRequestFailed) {
226 SendRequestToHost(); 228 SendRequestToHost();
227 store_->RunCompletionCallback(net::ERR_KEY_GENERATION_FAILED, "", ""); 229 store_->RunCompletionCallback(net::ERR_KEY_GENERATION_FAILED, "", "");
228 VerifyRequestFailedMessage(net::ERR_KEY_GENERATION_FAILED); 230 VerifyRequestFailedMessage(net::ERR_KEY_GENERATION_FAILED);
229 } 231 }
230 232
231 TEST_F(WebRTCIdentityServiceHostTest, TestOriginAccessDenied) { 233 TEST_F(WebRTCIdentityServiceHostTest, TestOriginAccessDenied) {
232 ChildProcessSecurityPolicyImpl* policy = 234 ChildProcessSecurityPolicyImpl* policy =
233 ChildProcessSecurityPolicyImpl::GetInstance(); 235 ChildProcessSecurityPolicyImpl::GetInstance();
234 policy->Remove(FAKE_RENDERER_ID); 236 policy->LockToOrigin(FAKE_RENDERER_ID, GURL(OTHER_SITE));
235 237
236 SendRequestToHost(); 238 SendRequestToHost();
237 VerifyRequestFailedMessage(net::ERR_ACCESS_DENIED); 239 VerifyRequestFailedMessage(net::ERR_ACCESS_DENIED);
238 } 240 }
239 241
242 TEST_F(WebRTCIdentityServiceHostTest, TestOriginAccessAllowed) {
243 ChildProcessSecurityPolicyImpl* policy =
244 ChildProcessSecurityPolicyImpl::GetInstance();
245 policy->LockToOrigin(FAKE_RENDERER_ID, GURL(FAKE_SITE));
246
247 SendRequestToHost();
248 store_->RunCompletionCallback(net::OK, FAKE_CERTIFICATE, FAKE_PRIVATE_KEY);
249 VerifyIdentityReadyMessage(FAKE_CERTIFICATE, FAKE_PRIVATE_KEY);
250 }
251
240 // Verifies that we do not crash if we try to cancel a completed request. 252 // Verifies that we do not crash if we try to cancel a completed request.
241 TEST_F(WebRTCIdentityServiceHostTest, TestCancelAfterRequestCompleted) { 253 TEST_F(WebRTCIdentityServiceHostTest, TestCancelAfterRequestCompleted) {
242 SendRequestToHost(); 254 SendRequestToHost();
243 store_->RunCompletionCallback(net::OK, FAKE_CERTIFICATE, FAKE_PRIVATE_KEY); 255 store_->RunCompletionCallback(net::OK, FAKE_CERTIFICATE, FAKE_PRIVATE_KEY);
244 SendCancelRequestToHost(); 256 SendCancelRequestToHost();
245 } 257 }
246 258
247 } // namespace content 259 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/child_process_security_policy_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698