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

Unified Diff: content/common/sandbox_mac_system_access_unittest.mm

Issue 400293002: Write MacSandboxTest.OpenSSLAccess. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/sandbox_mac_system_access_unittest.mm
diff --git a/content/common/sandbox_mac_system_access_unittest.mm b/content/common/sandbox_mac_system_access_unittest.mm
index c527ea5be29b1f58c309482df3e19524df0d0e60..95503a5f6cb50d241b3d1a8bb429c7b28454628b 100644
--- a/content/common/sandbox_mac_system_access_unittest.mm
+++ b/content/common/sandbox_mac_system_access_unittest.mm
@@ -10,9 +10,15 @@
#include "base/strings/sys_string_conversions.h"
#include "content/common/sandbox_mac.h"
#include "content/common/sandbox_mac_unittest_helper.h"
-#include "crypto/nss_util.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 {
//--------------------- Clipboard Sandboxing ----------------------
@@ -120,6 +126,31 @@ TEST_F(MacSandboxTest, UrandomAccess) {
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 ----------------------
// Test case for checking sandboxing of NSS initialization.
class MacSandboxedNSSTestCase : public MacSandboxTestCase {
@@ -141,4 +172,6 @@ TEST_F(MacSandboxTest, NSSAccess) {
EXPECT_TRUE(RunTestInAllSandboxTypes("MacSandboxedNSSTestCase", NULL));
}
+#endif // defined(USE_OPENSSL)
+
} // namespace content
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698