Commit 51e0322f authored by davidben@chromium.org's avatar davidben@chromium.org

Write MacSandboxTest.OpenSSLAccess.

Replaces MacSandboxTest.NSSAccess. With this, content_unittest links and this
new test passes (modulo BoringSSL switchover fixes still pending).

BUG=395231

Review URL: https://codereview.chromium.org/400293002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@284266 0039d316-1c4b-4281-b951-d872f2087c98
parent 449afc0d
...@@ -10,9 +10,15 @@ ...@@ -10,9 +10,15 @@
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "content/common/sandbox_mac.h" #include "content/common/sandbox_mac.h"
#include "content/common/sandbox_mac_unittest_helper.h" #include "content/common/sandbox_mac_unittest_helper.h"
#include "crypto/nss_util.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#if defined(USE_OPENSSL)
#include <openssl/rand.h>
#include "crypto/openssl_util.h"
#else
#include "crypto/nss_util.h"
#endif
namespace content { namespace content {
//--------------------- Clipboard Sandboxing ---------------------- //--------------------- Clipboard Sandboxing ----------------------
...@@ -120,6 +126,31 @@ TEST_F(MacSandboxTest, UrandomAccess) { ...@@ -120,6 +126,31 @@ TEST_F(MacSandboxTest, UrandomAccess) {
EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedUrandomTestCase", NULL)); EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedUrandomTestCase", NULL));
} }
#if defined(USE_OPENSSL)
//--------------------- OpenSSL Sandboxing ----------------------
// Test case for checking sandboxing of OpenSSL initialization.
class MacSandboxedOpenSSLTestCase : public MacSandboxTestCase {
public:
virtual bool SandboxedTest() OVERRIDE;
};
REGISTER_SANDBOX_TEST_CASE(MacSandboxedOpenSSLTestCase);
bool MacSandboxedOpenSSLTestCase::SandboxedTest() {
crypto::EnsureOpenSSLInit();
// Ensure that RAND_bytes is functional within the sandbox.
uint8_t byte;
return RAND_bytes(&byte, 1) == 1;
}
TEST_F(MacSandboxTest, OpenSSLAccess) {
EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedOpenSSLTestCase", NULL));
}
#else // !defined(USE_OPENSSL)
//--------------------- NSS Sandboxing ---------------------- //--------------------- NSS Sandboxing ----------------------
// Test case for checking sandboxing of NSS initialization. // Test case for checking sandboxing of NSS initialization.
class MacSandboxedNSSTestCase : public MacSandboxTestCase { class MacSandboxedNSSTestCase : public MacSandboxTestCase {
...@@ -141,4 +172,6 @@ TEST_F(MacSandboxTest, NSSAccess) { ...@@ -141,4 +172,6 @@ TEST_F(MacSandboxTest, NSSAccess) {
EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedNSSTestCase", NULL)); EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedNSSTestCase", NULL));
} }
#endif // defined(USE_OPENSSL)
} // namespace content } // namespace content
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment