summaryrefslogtreecommitdiff
path: root/test/utils
diff options
context:
space:
mode:
Diffstat (limited to 'test/utils')
-rw-r--r--test/utils/TARGETS6
-rw-r--r--test/utils/remote_execution/main-remote-execution.cpp3
-rw-r--r--test/utils/test_env.hpp28
3 files changed, 36 insertions, 1 deletions
diff --git a/test/utils/TARGETS b/test/utils/TARGETS
index c9f40532..81137cb5 100644
--- a/test/utils/TARGETS
+++ b/test/utils/TARGETS
@@ -26,7 +26,11 @@
{ "type": ["@", "rules", "CC", "library"]
, "name": ["test_env"]
, "hdrs": ["test_env.hpp"]
- , "deps": ["log_config", ["src/buildtool/compatibility", "compatibility"]]
+ , "deps":
+ [ "log_config"
+ , ["src/buildtool/compatibility", "compatibility"]
+ , ["src/buildtool/auth", "auth"]
+ ]
, "stage": ["test", "utils"]
}
, "local_hermeticity":
diff --git a/test/utils/remote_execution/main-remote-execution.cpp b/test/utils/remote_execution/main-remote-execution.cpp
index 32774a65..952b025e 100644
--- a/test/utils/remote_execution/main-remote-execution.cpp
+++ b/test/utils/remote_execution/main-remote-execution.cpp
@@ -37,6 +37,9 @@ void wait_for_grpc_to_shutdown() {
/// \returns true If remote execution was successfully configured.
[[nodiscard]] auto ConfigureRemoteExecution() -> bool {
ReadCompatibilityFromEnv();
+ if (not ReadTLSAuthArgsFromEnv()) {
+ return false;
+ }
HashFunction::SetHashType(Compatibility::IsCompatible()
? HashFunction::JustHash::Compatible
: HashFunction::JustHash::Native);
diff --git a/test/utils/test_env.hpp b/test/utils/test_env.hpp
index 0302f555..7013d2ff 100644
--- a/test/utils/test_env.hpp
+++ b/test/utils/test_env.hpp
@@ -21,6 +21,7 @@
#include <sstream>
#include <string>
+#include "src/buildtool/auth/authentication.hpp"
#include "src/buildtool/compatibility/compatibility.hpp"
#include "test/utils/logging/log_config.hpp"
@@ -53,4 +54,31 @@ static inline void ReadCompatibilityFromEnv() {
: std::make_optional(std::string{execution_address});
}
+[[nodiscard]] static inline auto ReadTLSAuthArgsFromEnv() -> bool {
+ auto* ca_cert = std::getenv("TLS_CA_CERT");
+ auto* client_cert = std::getenv("TLS_CLIENT_CERT");
+ auto* client_key = std::getenv("TLS_CLIENT_KEY");
+ if (ca_cert != nullptr) {
+ if (not Auth::TLS::SetCACertificate(ca_cert)) {
+ return false;
+ }
+ }
+ if (client_cert != nullptr) {
+ if (not Auth::TLS::SetClientCertificate(client_cert)) {
+ return false;
+ }
+ }
+ if (client_key != nullptr) {
+ if (not Auth::TLS::SetClientKey(client_key)) {
+ return false;
+ }
+ }
+ if (Auth::GetAuthMethod() == AuthMethod::kTLS) {
+ if (not Auth::TLS::Validate()) {
+ return false;
+ }
+ }
+ return true;
+}
+
#endif // INCLUDED_SRC_TEST_UTILS_TEST_ENV_HPP