// Copyright Epic Games, Inc. All Rights Reserved. #include #if ZEN_WITH_TESTS # include "zen-test.h" # include # include # include # include namespace zen::tests { namespace { // Returns "" when the variable is unset, "" when set to an empty value, // or the literal value otherwise. std::string DescribeEnvVar(std::string_view Name) { const std::optional Value = GetEnvVariable(Name); if (!Value) { return std::string(""); } return Value->empty() ? std::string("") : *Value; } // Same as DescribeEnvVar but redacts the value, since the variable may be a credential. // Reports presence and length without revealing contents. std::string DescribeSecretEnvVar(std::string_view Name) { const std::optional Value = GetEnvVariable(Name); if (!Value) { return std::string(""); } return Value->empty() ? std::string("") : fmt::format("", Value->size()); } } // namespace TEST_SUITE_BEGIN("zen.artifactprovider"); TEST_CASE("probe.s3_readme" * doctest::skip(!S3TestArtifactsAvailable())) { // Use a fresh cache so Exists() is forced through to S3 rather than being satisfied // by a README cached from a prior run. ScopedTemporaryDirectory CacheDir; TestArtifactProviderOptions Opts; Opts.CacheDir = CacheDir.Path(); Ref Provider = CreateTestArtifactProvider(std::move(Opts)); REQUIRE_MESSAGE(Provider, "no test artifact provider could be created on this platform"); constexpr std::string_view kArtifactPath = "README.md"; const std::string Description = Provider->Describe(); ZEN_INFO("Provider: {}", Description); ZEN_INFO("ZEN_TEST_ARTIFACTS_S3={}", DescribeEnvVar(kTestArtifactsS3EnvVar)); ZEN_INFO("AWS_DEFAULT_REGION={}", DescribeEnvVar("AWS_DEFAULT_REGION")); ZEN_INFO("AWS_REGION={}", DescribeEnvVar("AWS_REGION")); ZEN_INFO("AWS_ENDPOINT_URL={}", DescribeEnvVar("AWS_ENDPOINT_URL")); ZEN_INFO("AWS_ACCESS_KEY_ID={}", DescribeSecretEnvVar("AWS_ACCESS_KEY_ID")); ZEN_INFO("AWS_SECRET_ACCESS_KEY={}", DescribeSecretEnvVar("AWS_SECRET_ACCESS_KEY")); ZEN_INFO("AWS_SESSION_TOKEN={}", DescribeSecretEnvVar("AWS_SESSION_TOKEN")); CHECK_MESSAGE(Provider->Exists(kArtifactPath), "'" << kArtifactPath << "' not available via " << Description); } TEST_SUITE_END(); } // namespace zen::tests #endif