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

Side by Side Diff: content/browser/child_process_security_policy_unittest.cc

Issue 7038032: Fix PP_FileOpenFlags_Dev handling: (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Make changes according to Darin's suggestions. Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/platform_file.h" 9 #include "base/platform_file.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance(); 279 ChildProcessSecurityPolicy* p = ChildProcessSecurityPolicy::GetInstance();
280 280
281 // Grant permissions for a file. 281 // Grant permissions for a file.
282 p->Add(kRendererID); 282 p->Add(kRendererID);
283 FilePath file = FilePath(FILE_PATH_LITERAL("/etc/passwd")); 283 FilePath file = FilePath(FILE_PATH_LITERAL("/etc/passwd"));
284 EXPECT_FALSE(p->HasPermissionsForFile(kRendererID, file, 284 EXPECT_FALSE(p->HasPermissionsForFile(kRendererID, file,
285 base::PLATFORM_FILE_OPEN)); 285 base::PLATFORM_FILE_OPEN));
286 286
287 p->GrantPermissionsForFile(kRendererID, file, 287 p->GrantPermissionsForFile(kRendererID, file,
288 base::PLATFORM_FILE_OPEN | 288 base::PLATFORM_FILE_OPEN |
289 base::PLATFORM_FILE_OPEN_TRUNCATED |
289 base::PLATFORM_FILE_READ | 290 base::PLATFORM_FILE_READ |
290 base::PLATFORM_FILE_WRITE | 291 base::PLATFORM_FILE_WRITE);
291 base::PLATFORM_FILE_TRUNCATE);
292 EXPECT_TRUE(p->HasPermissionsForFile(kRendererID, file, 292 EXPECT_TRUE(p->HasPermissionsForFile(kRendererID, file,
293 base::PLATFORM_FILE_OPEN | 293 base::PLATFORM_FILE_OPEN |
294 base::PLATFORM_FILE_OPEN_TRUNCATED |
294 base::PLATFORM_FILE_READ | 295 base::PLATFORM_FILE_READ |
295 base::PLATFORM_FILE_WRITE | 296 base::PLATFORM_FILE_WRITE));
296 base::PLATFORM_FILE_TRUNCATE));
297 EXPECT_TRUE(p->HasPermissionsForFile(kRendererID, file, 297 EXPECT_TRUE(p->HasPermissionsForFile(kRendererID, file,
298 base::PLATFORM_FILE_OPEN | 298 base::PLATFORM_FILE_OPEN |
299 base::PLATFORM_FILE_READ)); 299 base::PLATFORM_FILE_READ));
300 EXPECT_FALSE(p->HasPermissionsForFile(kRendererID, file, 300 EXPECT_FALSE(p->HasPermissionsForFile(kRendererID, file,
301 base::PLATFORM_FILE_CREATE)); 301 base::PLATFORM_FILE_CREATE));
302 EXPECT_FALSE(p->HasPermissionsForFile(kRendererID, file, 302 EXPECT_FALSE(p->HasPermissionsForFile(kRendererID, file,
303 base::PLATFORM_FILE_CREATE | 303 base::PLATFORM_FILE_CREATE |
304 base::PLATFORM_FILE_OPEN_TRUNCATED |
304 base::PLATFORM_FILE_READ | 305 base::PLATFORM_FILE_READ |
305 base::PLATFORM_FILE_WRITE | 306 base::PLATFORM_FILE_WRITE));
306 base::PLATFORM_FILE_TRUNCATE));
307 p->Remove(kRendererID); 307 p->Remove(kRendererID);
308 308
309 // Grant permissions for the directory the file is in. 309 // Grant permissions for the directory the file is in.
310 p->Add(kRendererID); 310 p->Add(kRendererID);
311 EXPECT_FALSE(p->HasPermissionsForFile(kRendererID, file, 311 EXPECT_FALSE(p->HasPermissionsForFile(kRendererID, file,
312 base::PLATFORM_FILE_OPEN)); 312 base::PLATFORM_FILE_OPEN));
313 p->GrantPermissionsForFile(kRendererID, FilePath(FILE_PATH_LITERAL("/etc")), 313 p->GrantPermissionsForFile(kRendererID, FilePath(FILE_PATH_LITERAL("/etc")),
314 base::PLATFORM_FILE_OPEN | 314 base::PLATFORM_FILE_OPEN |
315 base::PLATFORM_FILE_READ); 315 base::PLATFORM_FILE_READ);
316 EXPECT_TRUE(p->HasPermissionsForFile(kRendererID, file, 316 EXPECT_TRUE(p->HasPermissionsForFile(kRendererID, file,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 410
411 // Renderers are added and removed on the UI thread, but the policy can be 411 // Renderers are added and removed on the UI thread, but the policy can be
412 // queried on the IO thread. The ChildProcessSecurityPolicy needs to be 412 // queried on the IO thread. The ChildProcessSecurityPolicy needs to be
413 // prepared to answer policy questions about renderers who no longer exist. 413 // prepared to answer policy questions about renderers who no longer exist.
414 414
415 // In this case, we default to secure behavior. 415 // In this case, we default to secure behavior.
416 EXPECT_FALSE(p->CanRequestURL(kRendererID, url)); 416 EXPECT_FALSE(p->CanRequestURL(kRendererID, url));
417 EXPECT_FALSE(p->CanReadFile(kRendererID, file)); 417 EXPECT_FALSE(p->CanReadFile(kRendererID, file));
418 EXPECT_FALSE(p->HasWebUIBindings(kRendererID)); 418 EXPECT_FALSE(p->HasWebUIBindings(kRendererID));
419 } 419 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698