| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "content/common/sandbox_mac.h" | 10 #include "content/common/sandbox_mac.h" |
| 11 #include "content/common/sandbox_mac_unittest_helper.h" | 11 #include "content/common/sandbox_mac_unittest_helper.h" |
| 12 #include "crypto/nss_util.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 //--------------------- Clipboard Sandboxing ---------------------- | 17 //--------------------- Clipboard Sandboxing ---------------------- |
| 17 // Test case for checking sandboxing of clipboard access. | 18 // Test case for checking sandboxing of clipboard access. |
| 18 class MacSandboxedClipboardTestCase : public MacSandboxTestCase { | 19 class MacSandboxedClipboardTestCase : public MacSandboxTestCase { |
| 19 public: | 20 public: |
| 20 MacSandboxedClipboardTestCase(); | 21 MacSandboxedClipboardTestCase(); |
| 21 virtual ~MacSandboxedClipboardTestCase(); | 22 virtual ~MacSandboxedClipboardTestCase(); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 114 |
| 114 char buf[16]; | 115 char buf[16]; |
| 115 int rc = read(fdes, buf, sizeof(buf)); | 116 int rc = read(fdes, buf, sizeof(buf)); |
| 116 return rc == sizeof(buf); | 117 return rc == sizeof(buf); |
| 117 } | 118 } |
| 118 | 119 |
| 119 TEST_F(MacSandboxTest, UrandomAccess) { | 120 TEST_F(MacSandboxTest, UrandomAccess) { |
| 120 EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedUrandomTestCase", NULL)); | 121 EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedUrandomTestCase", NULL)); |
| 121 } | 122 } |
| 122 | 123 |
| 124 //--------------------- NSS Sandboxing ---------------------- |
| 125 // Test case for checking sandboxing of NSS initialization. |
| 126 class MacSandboxedNSSTestCase : public MacSandboxTestCase { |
| 127 public: |
| 128 virtual bool SandboxedTest() OVERRIDE; |
| 129 }; |
| 130 |
| 131 REGISTER_SANDBOX_TEST_CASE(MacSandboxedNSSTestCase); |
| 132 |
| 133 bool MacSandboxedNSSTestCase::SandboxedTest() { |
| 134 // If NSS cannot read from /dev/urandom, NSS initialization will call abort(), |
| 135 // which will cause this test case to fail. |
| 136 crypto::ForceNSSNoDBInit(); |
| 137 crypto::EnsureNSSInit(); |
| 138 return true; |
| 139 } |
| 140 |
| 141 TEST_F(MacSandboxTest, NSSAccess) { |
| 142 EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedNSSTestCase", NULL)); |
| 143 } |
| 144 |
| 123 } // namespace content | 145 } // namespace content |
| OLD | NEW |