3939#include " ray/ray_syncer/ray_syncer_server.h"
4040#include " ray/rpc/authentication/authentication_token.h"
4141#include " ray/rpc/grpc_server.h"
42+ #include " ray/util/env.h"
4243#include " ray/util/network_util.h"
4344#include " ray/util/path_utils.h"
4445#include " ray/util/raii.h"
@@ -993,13 +994,13 @@ class SyncerAuthenticationTest : public ::testing::Test {
993994 protected:
994995 void SetUp () override {
995996 // Clear any existing environment variables and reset state
996- unsetenv (" RAY_AUTH_TOKEN" );
997+ ray::UnsetEnv (" RAY_AUTH_TOKEN" );
997998 ray::rpc::AuthenticationTokenLoader::instance ().ResetCache ();
998999 RayConfig::instance ().auth_mode () = " disabled" ;
9991000 }
10001001
10011002 void TearDown () override {
1002- unsetenv (" RAY_AUTH_TOKEN" );
1003+ ray::UnsetEnv (" RAY_AUTH_TOKEN" );
10031004 ray::rpc::AuthenticationTokenLoader::instance ().ResetCache ();
10041005 RayConfig::instance ().auth_mode () = " disabled" ;
10051006 }
@@ -1083,7 +1084,7 @@ TEST_F(SyncerAuthenticationTest, MatchingTokens) {
10831084 const std::string test_token = " matching-test-token-12345" ;
10841085
10851086 // Set client token via environment variable
1086- setenv (" RAY_AUTH_TOKEN" , test_token. c_str (), 1 );
1087+ ray::SetEnv (" RAY_AUTH_TOKEN" , test_token);
10871088 // Enable token authentication
10881089 RayConfig::instance ().auth_mode () = " token" ;
10891090 ray::rpc::AuthenticationTokenLoader::instance ().ResetCache ();
@@ -1110,7 +1111,7 @@ TEST_F(SyncerAuthenticationTest, MismatchedTokens) {
11101111 const std::string client_token = " different-client-token" ;
11111112
11121113 // Set client token via environment variable
1113- setenv (" RAY_AUTH_TOKEN" , client_token. c_str (), 1 );
1114+ ray::SetEnv (" RAY_AUTH_TOKEN" , client_token);
11141115 // Enable token authentication
11151116 RayConfig::instance ().auth_mode () = " token" ;
11161117 ray::rpc::AuthenticationTokenLoader::instance ().ResetCache ();
@@ -1136,7 +1137,7 @@ TEST_F(SyncerAuthenticationTest, ServerHasTokenClientDoesNot) {
11361137 const std::string server_token = " server-token-12345" ;
11371138
11381139 // Client has no token - auth mode is disabled (default from SetUp)
1139- unsetenv (" RAY_AUTH_TOKEN" );
1140+ ray::UnsetEnv (" RAY_AUTH_TOKEN" );
11401141 ray::rpc::AuthenticationTokenLoader::instance ().ResetCache ();
11411142
11421143 // Create authenticated server
@@ -1161,7 +1162,7 @@ TEST_F(SyncerAuthenticationTest, ClientHasTokenServerDoesNotRequire) {
11611162 const std::string client_token = " different-client-token" ;
11621163
11631164 // Set client token
1164- setenv (" RAY_AUTH_TOKEN" , client_token. c_str (), 1 );
1165+ ray::SetEnv (" RAY_AUTH_TOKEN" , client_token);
11651166 // Enable token authentication
11661167 RayConfig::instance ().auth_mode () = " token" ;
11671168 ray::rpc::AuthenticationTokenLoader::instance ().ResetCache ();
0 commit comments