1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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
|