blob: 80c4fa3c1f46d6dc44b34f70d88611579411eadb [file] [log] [blame]
Bob Beckbc97b7a2023-04-18 08:35:15 -06001// Copyright 2022 The Chromium Authors
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 BSSL_PKI_MOCK_SIGNATURE_VERIFY_CACHE_H_
6#define BSSL_PKI_MOCK_SIGNATURE_VERIFY_CACHE_H_
7
8#include <stddef.h>
9
10#include <string>
11#include <string_view>
12#include <unordered_map>
13
14
15#include "signature_verify_cache.h"
16
17namespace bssl {
18
19// MockSignatureVerifyCache is an implementation of SignatureVerifyCache. It is
20// intended only for testing of cache functionality.
21
22class MockSignatureVerifyCache : public SignatureVerifyCache {
23 public:
24 MockSignatureVerifyCache();
25
26 ~MockSignatureVerifyCache() override;
27
Bob Beck5c7a2a02023-11-20 17:28:21 -070028 void Store(const std::string &key,
Bob Beckbc97b7a2023-04-18 08:35:15 -060029 SignatureVerifyCache::Value value) override;
30
Bob Beck5c7a2a02023-11-20 17:28:21 -070031 SignatureVerifyCache::Value Check(const std::string &key) override;
Bob Beckbc97b7a2023-04-18 08:35:15 -060032
33 size_t CacheHits() { return hits_; }
34
35 size_t CacheMisses() { return misses_; }
36
37 size_t CacheStores() { return stores_; }
38
39 private:
40 std::unordered_map<std::string, SignatureVerifyCache::Value> cache_;
41 size_t hits_ = 0;
42 size_t misses_ = 0;
43 size_t stores_ = 0;
44};
45
Bob Beck5c7a2a02023-11-20 17:28:21 -070046} // namespace bssl
Bob Beckbc97b7a2023-04-18 08:35:15 -060047
48#endif // BSSL_PKI_MOCK_PATH_BUILDER_DELEGATE_H_