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

Side by Side Diff: net/cert/internal/cert_issuer_source_test_helpers.h

Issue 2126803004: WIP: NSS trust store integration for path builder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert-command-line-path-builder-add_certpathbuilder
Patch Set: . Created 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef NET_CERT_INTERNAL_CERT_ISSUER_SOURCE_TEST_HELPERS_H_
6 #define NET_CERT_INTERNAL_CERT_ISSUER_SOURCE_TEST_HELPERS_H_
7
8 #include "base/cancelable_callback.h"
9 #include "base/location.h"
10 #include "base/threading/thread_task_runner_handle.h"
11 #include "net/cert/internal/cert_issuer_source_static.h"
12 #include "net/cert/internal/parsed_certificate.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14
15 namespace net {
16
17 // AsyncCertIssuerSourceStatic always returns its certs asynchronously, in a
18 // single batch.
19 class AsyncCertIssuerSourceStatic : public CertIssuerSource {
20 public:
21 AsyncCertIssuerSourceStatic();
22 ~AsyncCertIssuerSourceStatic() override;
23
24 void AddCert(scoped_refptr<ParsedCertificate> cert);
25 int num_async_gets() const { return num_async_gets_; }
26
27 // CertIssuerSource implementation:
28 void SyncGetIssuersOf(const ParsedCertificate* cert,
29 ParsedCertificateList* issuers) override {}
30 void AsyncGetIssuersOf(scoped_refptr<ParsedCertificate> cert,
31 const IssuerCallback& issuers_callback,
32 std::unique_ptr<Request>* out_req) override;
33
34 private:
35 CertIssuerSourceStatic static_cert_issuer_source_;
36
37 int num_async_gets_ = 0;
38 };
39
40 // Mocks of CertIssuerSource::Request and CertIssuerSource that allow testing
41 // more complicated sequences of results.
42 class MockCertIssuerSourceRequest : public CertIssuerSource::Request {
43 public:
44 MockCertIssuerSourceRequest();
45 ~MockCertIssuerSourceRequest() override;
46
47 MOCK_METHOD1(GetNext, CompletionStatus(scoped_refptr<ParsedCertificate>*));
48 };
49
50 class MockCertIssuerSource : public CertIssuerSource {
51 public:
52 MockCertIssuerSource();
53 ~MockCertIssuerSource() override;
54
55 MOCK_METHOD2(SyncGetIssuersOf,
56 void(const ParsedCertificate*, ParsedCertificateList*));
57 MOCK_METHOD3(AsyncGetIssuersOf,
58 void(scoped_refptr<ParsedCertificate>,
59 const IssuerCallback&,
60 std::unique_ptr<Request>*));
61 };
62
63 // Helper class to pass the Request to the PathBuilder when it calls
64 // AsyncGetIssuersOf. (GoogleMock has a ByMove helper, but it apparently can
65 // only be used with Return, not SetArgPointee.)
66 class CertIssuerSourceRequestMover {
67 public:
68 CertIssuerSourceRequestMover(std::unique_ptr<CertIssuerSource::Request> req);
69 ~CertIssuerSourceRequestMover();
70
71 void MoveIt(scoped_refptr<ParsedCertificate> cert,
72 const CertIssuerSource::IssuerCallback& issuers_callback,
73 std::unique_ptr<CertIssuerSource::Request>* out_req) {
74 *out_req = std::move(request_);
75 }
76
77 private:
78 std::unique_ptr<CertIssuerSource::Request> request_;
79 };
80
81 class MockIssuerCallback {
82 public:
83 MockIssuerCallback();
84 ~MockIssuerCallback();
85
86 MOCK_METHOD1(Callback, void(CertIssuerSource::Request*));
87 };
88
89 } // namespace net
90
91 #endif // NET_CERT_INTERNAL_CERT_ISSUER_SOURCE_TEST_HELPERS_H_
OLDNEW
« no previous file with comments | « net/cert/internal/cert_issuer_source_static_unittest.cc ('k') | net/cert/internal/cert_issuer_source_test_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698