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

Unified Diff: chrome/test/base/cert_verifier_browser_test.h

Issue 1227943002: Allow browser tests to use a MockCertVerifier (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move factory-setter to ProfileIOData to work with ChromeOS Created 5 years, 4 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
Index: chrome/test/base/cert_verifier_browser_test.h
diff --git a/chrome/test/base/cert_verifier_browser_test.h b/chrome/test/base/cert_verifier_browser_test.h
new file mode 100644
index 0000000000000000000000000000000000000000..64c95b12d8cddd8859cad212c208f57c1d2dd083
--- /dev/null
+++ b/chrome/test/base/cert_verifier_browser_test.h
@@ -0,0 +1,52 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_TEST_BASE_CERT_VERIFIER_BROWSER_TEST_H_
+#define CHROME_TEST_BASE_CERT_VERIFIER_BROWSER_TEST_H_
+
+#include "chrome/test/base/in_process_browser_test.h"
+#include "net/cert/cert_verifier.h"
+
+namespace net {
+class MockCertVerifier;
+} // namespace net
+
+// CertVerifierBrowserTest allows tests to force certificate
+// verification results for requests made with the profile's main
+// request context (such as navigations). To do so, tests can use the
+// MockCertVerifier exposed via
+// CertVerifierBrowserTest::mock_cert_verifier().
+class CertVerifierBrowserTest : public InProcessBrowserTest {
+ public:
+ CertVerifierBrowserTest();
+ ~CertVerifierBrowserTest() override;
+
+ // Sets up the mock cert verifier so that tests can set certificate
+ // verification results.
+ void SetUpInProcessBrowserTestFixture() override;
+
+ net::MockCertVerifier* mock_cert_verifier();
+
+ private:
+ // A mock CertVerifierFactory that has a single MockCertVerifier and
+ // always returns that when asked to create new CertVerifiers.
+ class MockCertVerifierFactory : public net::CertVerifierFactory {
+ public:
+ MockCertVerifierFactory();
+ ~MockCertVerifierFactory() override;
+
+ // net::CertVerifierFactory overrides
+ net::CertVerifier* CreateCertVerifier() override;
+
+ net::MockCertVerifier* mock_cert_verifier();
+
+ private:
+ // Ownership of this will be passed to the caller of CreateCertVerifier().
+ net::MockCertVerifier* mock_cert_verifier_;
+ };
+
+ MockCertVerifierFactory mock_cert_verifier_factory_;
+};
+
+#endif // CHROME_TEST_BASE_CERT_VERIFIER_BROWSER_TEST_H_

Powered by Google App Engine
This is Rietveld 408576698