blob: 5d99c37b6384a25e01ad87895013bce7e4990124 [file] [edit]
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#ifndef THIRD_PARTY_CREDENTIO_TESTING_CREATE_TEST_CRYPTO_WRITE_HANDLER_H_
#define THIRD_PARTY_CREDENTIO_TESTING_CREATE_TEST_CRYPTO_WRITE_HANDLER_H_
#include <memory>
#include <optional>
#include "absl/status/statusor.h"
#include "absl/time/clock_interface.h"
#include "crypto/crypto_write_handler.h"
#include "testing/crypto_testing.h"
#include "testing/local_key_crypto_write_handler.h"
namespace credentio {
// Returns the default `TestPki` used by `TestClaimSignerCredentials()` and
// `TestTsaCredentials()`.
const TestPki& DefaultTestPki();
// Returns the claim signer credentials of `DefaultTestPki()`.
LocalKeyClaimSignerCredentials TestClaimSignerCredentials();
// Returns the timestamp authority credentials of `DefaultTestPki()`.
LocalKeyTsaCredentials TestTsaCredentials();
struct TestCryptoWriteHandlerOptions {
// If not provided, `absl::Clock::GetRealClock()` is used.
absl::Clock* clock = nullptr;
// If true, timestamping is disabled and returns UNAVAILABLE.
bool disable_timestamping = false;
// Credentials to sign claims with. If not provided,
// TestClaimSignerCredentials() is used.
std::optional<LocalKeyClaimSignerCredentials> claim_signer;
// Credentials to sign timestamps with. If not provided,
// TestTsaCredentials() is used.
std::optional<LocalKeyTsaCredentials> tsa;
};
// Creates a CryptoWriteHandler for testing. By default it uses claim and
// timestamp signers from `DefaultTestPki()`; see TestCryptoWriteHandlerOptions
// to supply your own.
absl::StatusOr<std::unique_ptr<CryptoWriteHandler>>
CreateTestCryptoWriteHandler(TestCryptoWriteHandlerOptions options = {});
} // namespace credentio
#endif // THIRD_PARTY_CREDENTIO_TESTING_CREATE_TEST_CRYPTO_WRITE_HANDLER_H_