aboutsummaryrefslogtreecommitdiff
path: root/src/zen-test/artifactprovider-tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zen-test/artifactprovider-tests.cpp')
-rw-r--r--src/zen-test/artifactprovider-tests.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/zen-test/artifactprovider-tests.cpp b/src/zen-test/artifactprovider-tests.cpp
new file mode 100644
index 000000000..48bbf8222
--- /dev/null
+++ b/src/zen-test/artifactprovider-tests.cpp
@@ -0,0 +1,66 @@
+// Copyright Epic Games, Inc. All Rights Reserved.
+
+#include <zencore/zencore.h>
+
+#if ZEN_WITH_TESTS
+
+# include "zen-test.h"
+
+# include <zencore/filesystem.h>
+# include <zencore/testing.h>
+# include <zencore/testutils.h>
+# include <zenutil/testartifactprovider.h>
+
+namespace zen::tests {
+
+namespace {
+
+ // Returns "<unset>" when the variable is unset, the literal value otherwise.
+ std::string DescribeEnvVar(std::string_view Name)
+ {
+ const std::string Value = GetEnvVariable(Name);
+ return Value.empty() ? std::string("<unset>") : 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::string Value = GetEnvVariable(Name);
+ return Value.empty() ? std::string("<unset>") : fmt::format("<set, {} chars>", 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<TestArtifactProvider> 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