summaryrefslogtreecommitdiff
path: root/test/buildtool/execution_api/bazel/bazel_network.test.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-02 16:47:13 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-07-04 16:05:08 +0200
commitc2f7ead468d5e65c57e7ecb49d7fbba4254c46b7 (patch)
treeb96ce2e63d9d6a2d486cb4133c290187156b97ac /test/buildtool/execution_api/bazel/bazel_network.test.cpp
parent0d60cd9ba4a5c18b01b6ef996434953071f0576e (diff)
downloadjustbuild-c2f7ead468d5e65c57e7ecb49d7fbba4254c46b7.tar.gz
Replace the Auth and Auth::TLS singletons
Use a builder pattern for creation and validation, in a manner that allows also other authentication methods to be added in the future besides the current TLS/SSL. The main Auth instances are built early and then passed by not_null const pointers, to avoid passing temporaries, replacing the previous Auth::TLS instances passed by simple nullable const pointers. Where needed, these passed Auth instances are also stored, by const ref. Tests also build Auth instances as needed, either with the default 'no certification' or from the test environment arguments.
Diffstat (limited to 'test/buildtool/execution_api/bazel/bazel_network.test.cpp')
-rw-r--r--test/buildtool/execution_api/bazel/bazel_network.test.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/test/buildtool/execution_api/bazel/bazel_network.test.cpp b/test/buildtool/execution_api/bazel/bazel_network.test.cpp
index 75821454..54d99305 100644
--- a/test/buildtool/execution_api/bazel/bazel_network.test.cpp
+++ b/test/buildtool/execution_api/bazel/bazel_network.test.cpp
@@ -26,18 +26,17 @@
#include "src/buildtool/execution_api/remote/bazel/bazel_network.hpp"
#include "src/buildtool/execution_api/remote/config.hpp"
#include "src/buildtool/file_system/object_type.hpp"
+#include "test/utils/remote_execution/test_auth_config.hpp"
constexpr std::size_t kLargeSize = GRPC_DEFAULT_MAX_RECV_MESSAGE_LENGTH + 1;
TEST_CASE("Bazel network: write/read blobs", "[execution_api]") {
auto const& info = RemoteExecutionConfig::RemoteAddress();
std::string instance_name{"remote-execution"};
- std::optional<Auth::TLS> auth = {};
- if (Auth::Instance().GetAuthMethod() == AuthMethod::kTLS) {
- auth = Auth::TLS::Instance();
- }
- auto network = BazelNetwork{
- instance_name, info->host, info->port, auth ? &*auth : nullptr, {}};
+ auto auth_config = TestAuthConfig::ReadAuthConfigFromEnvironment();
+ REQUIRE(auth_config);
+ auto network =
+ BazelNetwork{instance_name, info->host, info->port, &*auth_config, {}};
std::string content_foo("foo");
std::string content_bar("bar");
@@ -82,12 +81,10 @@ TEST_CASE("Bazel network: read blobs with unknown size", "[execution_api]") {
auto const& info = RemoteExecutionConfig::RemoteAddress();
std::string instance_name{"remote-execution"};
- std::optional<Auth::TLS> auth = {};
- if (Auth::Instance().GetAuthMethod() == AuthMethod::kTLS) {
- auth = Auth::TLS::Instance();
- }
- auto network = BazelNetwork{
- instance_name, info->host, info->port, auth ? &*auth : nullptr, {}};
+ auto auth_config = TestAuthConfig::ReadAuthConfigFromEnvironment();
+ REQUIRE(auth_config);
+ auto network =
+ BazelNetwork{instance_name, info->host, info->port, &*auth_config, {}};
std::string content_foo("foo");
std::string content_bar(kLargeSize, 'x'); // single larger blob