| // 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. | |
| // | |
| // Utilities for creating and validating C2PA manifest stores in tests. | |
| #ifndef THIRD_PARTY_CREDENTIO_TESTING_MANIFEST_STORE_TEST_UTILS_H_ | |
| #define THIRD_PARTY_CREDENTIO_TESTING_MANIFEST_STORE_TEST_UTILS_H_ | |
| #include <memory> | |
| #include <optional> | |
| #include <string> | |
| #include "absl/status/statusor.h" | |
| #include "absl/strings/string_view.h" | |
| #include "absl/time/clock_interface.h" | |
| #include "proto/generator_info.pb.h" | |
| #include "proto/manifest.pb.h" | |
| #include "proto/validation_result.pb.h" | |
| #include "uuid/uuid.h" | |
| namespace credentio { | |
| struct SimpleManifestStoreOptions { | |
| // If omitted, default test claim generator info will be used. | |
| std::optional<GeneratorInfo> generator_info = std::nullopt; | |
| // Optional. If not provided, `absl::Clock::GetRealClock()` is used. | |
| absl::Clock* clock = nullptr; | |
| // Optional. If not provided, a default UuidGenerator will be used. | |
| const UuidGenerator* uuid_generator = &UuidGenerator::Default(); | |
| // If true, timestamping is disabled. | |
| bool disable_timestamping = false; | |
| }; | |
| // Creates a simple manifest store bytes for testing. | |
| absl::StatusOr<std::string> CreateSimpleManifestStoreBytes( | |
| const SimpleManifestStoreOptions& options = {}); | |
| // Validates the given manifest store bytes by returning the partial validation | |
| // result. | |
| absl::StatusOr<std::unique_ptr<PartialValidationResultProto>> | |
| ValidateManifestStore(absl::string_view manifest_store_bytes); | |
| // Validates the claim in the given manifest store bytes and returns the claim. | |
| absl::StatusOr<Claim> ValidateClaim(absl::string_view manifest_store_bytes); | |
| } // namespace credentio | |
| #endif // THIRD_PARTY_CREDENTIO_TESTING_MANIFEST_STORE_TEST_UTILS_H_ |