@@ -2,6 +2,7 @@ mod given_that_the_token_is_only_provided_in_the_authentication_header {
22 use hyper:: header;
33 use torrust_axum_rest_tracker_api_server:: environment:: Started ;
44 use torrust_rest_tracker_api_client:: common:: http:: Query ;
5+ use torrust_rest_tracker_api_client:: connection_info:: ConnectionInfo ;
56 use torrust_rest_tracker_api_client:: v1:: client:: {
67 headers_with_auth_token, headers_with_request_id, Client , AUTH_BEARER_TOKEN_HEADER_PREFIX ,
78 } ;
@@ -80,7 +81,9 @@ mod given_that_the_token_is_only_provided_in_the_authentication_header {
8081 . expect ( "the auth token is not a valid header value" ) ,
8182 ) ;
8283
83- let response = Client :: new ( env. get_connection_info ( ) )
84+ let connection_info = ConnectionInfo :: anonymous ( env. get_connection_info ( ) . origin ) ;
85+
86+ let response = Client :: new ( connection_info)
8487 . unwrap ( )
8588 . get_request_with_query ( "stats" , Query :: default ( ) , Some ( headers) )
8689 . await ;
@@ -99,7 +102,8 @@ mod given_that_the_token_is_only_provided_in_the_query_param {
99102
100103 use torrust_axum_rest_tracker_api_server:: environment:: Started ;
101104 use torrust_rest_tracker_api_client:: common:: http:: { Query , QueryParam } ;
102- use torrust_rest_tracker_api_client:: v1:: client:: { headers_with_request_id, Client } ;
105+ use torrust_rest_tracker_api_client:: connection_info:: ConnectionInfo ;
106+ use torrust_rest_tracker_api_client:: v1:: client:: { headers_with_request_id, Client , TOKEN_PARAM_NAME } ;
103107 use torrust_tracker_test_helpers:: logging:: logs_contains_a_line_with;
104108 use torrust_tracker_test_helpers:: { configuration, logging} ;
105109 use uuid:: Uuid ;
@@ -114,9 +118,15 @@ mod given_that_the_token_is_only_provided_in_the_query_param {
114118
115119 let token = env. get_connection_info ( ) . api_token . unwrap ( ) ;
116120
117- let response = Client :: new ( env. get_connection_info ( ) )
121+ let connection_info = ConnectionInfo :: anonymous ( env. get_connection_info ( ) . origin ) ;
122+
123+ let response = Client :: new ( connection_info)
118124 . unwrap ( )
119- . get_request_with_query ( "stats" , Query :: params ( [ QueryParam :: new ( "token" , & token) ] . to_vec ( ) ) , None )
125+ . get_request_with_query (
126+ "stats" ,
127+ Query :: params ( [ QueryParam :: new ( TOKEN_PARAM_NAME , & token) ] . to_vec ( ) ) ,
128+ None ,
129+ )
120130 . await ;
121131
122132 assert_eq ! ( response. status( ) , 200 ) ;
@@ -132,11 +142,13 @@ mod given_that_the_token_is_only_provided_in_the_query_param {
132142
133143 let request_id = Uuid :: new_v4 ( ) ;
134144
135- let response = Client :: new ( env. get_connection_info ( ) )
145+ let connection_info = ConnectionInfo :: anonymous ( env. get_connection_info ( ) . origin ) ;
146+
147+ let response = Client :: new ( connection_info)
136148 . unwrap ( )
137149 . get_request_with_query (
138150 "stats" ,
139- Query :: params ( [ QueryParam :: new ( "token" , "" ) ] . to_vec ( ) ) ,
151+ Query :: params ( [ QueryParam :: new ( TOKEN_PARAM_NAME , "" ) ] . to_vec ( ) ) ,
140152 Some ( headers_with_request_id ( request_id) ) ,
141153 )
142154 . await ;
@@ -159,11 +171,13 @@ mod given_that_the_token_is_only_provided_in_the_query_param {
159171
160172 let request_id = Uuid :: new_v4 ( ) ;
161173
162- let response = Client :: new ( env. get_connection_info ( ) )
174+ let connection_info = ConnectionInfo :: anonymous ( env. get_connection_info ( ) . origin ) ;
175+
176+ let response = Client :: new ( connection_info)
163177 . unwrap ( )
164178 . get_request_with_query (
165179 "stats" ,
166- Query :: params ( [ QueryParam :: new ( "token" , "INVALID TOKEN" ) ] . to_vec ( ) ) ,
180+ Query :: params ( [ QueryParam :: new ( TOKEN_PARAM_NAME , "INVALID TOKEN" ) ] . to_vec ( ) ) ,
167181 Some ( headers_with_request_id ( request_id) ) ,
168182 )
169183 . await ;
@@ -186,8 +200,10 @@ mod given_that_the_token_is_only_provided_in_the_query_param {
186200
187201 let token = env. get_connection_info ( ) . api_token . unwrap ( ) ;
188202
203+ let connection_info = ConnectionInfo :: anonymous ( env. get_connection_info ( ) . origin ) ;
204+
189205 // At the beginning of the query component
190- let response = Client :: new ( env . get_connection_info ( ) )
206+ let response = Client :: new ( connection_info )
191207 . unwrap ( )
192208 . get_request ( & format ! ( "torrents?token={token}&limit=1" ) )
193209 . await ;
@@ -210,6 +226,7 @@ mod given_that_not_token_is_provided {
210226
211227 use torrust_axum_rest_tracker_api_server:: environment:: Started ;
212228 use torrust_rest_tracker_api_client:: common:: http:: Query ;
229+ use torrust_rest_tracker_api_client:: connection_info:: ConnectionInfo ;
213230 use torrust_rest_tracker_api_client:: v1:: client:: { headers_with_request_id, Client } ;
214231 use torrust_tracker_test_helpers:: logging:: logs_contains_a_line_with;
215232 use torrust_tracker_test_helpers:: { configuration, logging} ;
@@ -225,7 +242,9 @@ mod given_that_not_token_is_provided {
225242
226243 let request_id = Uuid :: new_v4 ( ) ;
227244
228- let response = Client :: new ( env. get_connection_info ( ) )
245+ let connection_info = ConnectionInfo :: anonymous ( env. get_connection_info ( ) . origin ) ;
246+
247+ let response = Client :: new ( connection_info)
229248 . unwrap ( )
230249 . get_request_with_query ( "stats" , Query :: default ( ) , Some ( headers_with_request_id ( request_id) ) )
231250 . await ;
0 commit comments