| // 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. | |
| // | |
| #include "testing/nonprod_validator.h" | |
| #include <memory> | |
| #include <utility> | |
| #include "absl/status/status_macros.h" | |
| #include "absl/status/statusor.h" | |
| #include "crypto/crypto_read_handler.h" | |
| #include "crypto/default/default_crypto_read_handler.h" | |
| #include "testing/create_test_crypto_write_handler.h" | |
| #include "testing/crypto_testing.h" | |
| #include "validator/asset_validator.h" | |
| #include "validator/asset_validator_impl.h" | |
| #include "validator/validator_options.h" | |
| namespace credentio { | |
| absl::StatusOr<std::unique_ptr<AssetValidator>> CreateNonProdValidator( | |
| const NonProdValidatorOptions& options) { | |
| const TestPki& pki = DefaultTestPki(); | |
| DefaultCryptoReadHandlerOptions crypto_options; | |
| crypto_options.claim_signer_trust_anchors_pem = pki.root_ca.cert_pem; | |
| crypto_options.tsa_trust_anchors_pem = pki.root_ca.cert_pem; | |
| crypto_options.clock = options.clock; | |
| ABSL_ASSIGN_OR_RETURN(std::unique_ptr<CryptoReadHandler> crypto_read_handler, | |
| CreateDefaultCryptoReadHandler(crypto_options)); | |
| return std::make_unique<AssetValidatorImpl>(ValidatorOptions{ | |
| .crypto_read_handler = std::move(crypto_read_handler), | |
| .clock = options.clock, | |
| .max_chunk_bytes = options.max_chunk_bytes, | |
| }); | |
| } | |
| } // namespace credentio |