@@ -2,6 +2,7 @@ mod given_that_the_token_is_only_provided_in_the_authentication_header {
2
2
use hyper:: header;
3
3
use torrust_axum_rest_tracker_api_server:: environment:: Started ;
4
4
use torrust_rest_tracker_api_client:: common:: http:: Query ;
5
+ use torrust_rest_tracker_api_client:: connection_info:: ConnectionInfo ;
5
6
use torrust_rest_tracker_api_client:: v1:: client:: {
6
7
headers_with_auth_token, headers_with_request_id, Client , AUTH_BEARER_TOKEN_HEADER_PREFIX ,
7
8
} ;
@@ -80,7 +81,9 @@ mod given_that_the_token_is_only_provided_in_the_authentication_header {
80
81
. expect ( "the auth token is not a valid header value" ) ,
81
82
) ;
82
83
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)
84
87
. unwrap ( )
85
88
. get_request_with_query ( "stats" , Query :: default ( ) , Some ( headers) )
86
89
. await ;
@@ -99,7 +102,8 @@ mod given_that_the_token_is_only_provided_in_the_query_param {
99
102
100
103
use torrust_axum_rest_tracker_api_server:: environment:: Started ;
101
104
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 } ;
103
107
use torrust_tracker_test_helpers:: logging:: logs_contains_a_line_with;
104
108
use torrust_tracker_test_helpers:: { configuration, logging} ;
105
109
use uuid:: Uuid ;
@@ -114,9 +118,15 @@ mod given_that_the_token_is_only_provided_in_the_query_param {
114
118
115
119
let token = env. get_connection_info ( ) . api_token . unwrap ( ) ;
116
120
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)
118
124
. 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
+ )
120
130
. await ;
121
131
122
132
assert_eq ! ( response. status( ) , 200 ) ;
@@ -132,11 +142,13 @@ mod given_that_the_token_is_only_provided_in_the_query_param {
132
142
133
143
let request_id = Uuid :: new_v4 ( ) ;
134
144
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)
136
148
. unwrap ( )
137
149
. get_request_with_query (
138
150
"stats" ,
139
- Query :: params ( [ QueryParam :: new ( "token" , "" ) ] . to_vec ( ) ) ,
151
+ Query :: params ( [ QueryParam :: new ( TOKEN_PARAM_NAME , "" ) ] . to_vec ( ) ) ,
140
152
Some ( headers_with_request_id ( request_id) ) ,
141
153
)
142
154
. await ;
@@ -159,11 +171,13 @@ mod given_that_the_token_is_only_provided_in_the_query_param {
159
171
160
172
let request_id = Uuid :: new_v4 ( ) ;
161
173
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)
163
177
. unwrap ( )
164
178
. get_request_with_query (
165
179
"stats" ,
166
- Query :: params ( [ QueryParam :: new ( "token" , "INVALID TOKEN" ) ] . to_vec ( ) ) ,
180
+ Query :: params ( [ QueryParam :: new ( TOKEN_PARAM_NAME , "INVALID TOKEN" ) ] . to_vec ( ) ) ,
167
181
Some ( headers_with_request_id ( request_id) ) ,
168
182
)
169
183
. await ;
@@ -186,8 +200,10 @@ mod given_that_the_token_is_only_provided_in_the_query_param {
186
200
187
201
let token = env. get_connection_info ( ) . api_token . unwrap ( ) ;
188
202
203
+ let connection_info = ConnectionInfo :: anonymous ( env. get_connection_info ( ) . origin ) ;
204
+
189
205
// At the beginning of the query component
190
- let response = Client :: new ( env . get_connection_info ( ) )
206
+ let response = Client :: new ( connection_info )
191
207
. unwrap ( )
192
208
. get_request ( & format ! ( "torrents?token={token}&limit=1" ) )
193
209
. await ;
@@ -210,6 +226,7 @@ mod given_that_not_token_is_provided {
210
226
211
227
use torrust_axum_rest_tracker_api_server:: environment:: Started ;
212
228
use torrust_rest_tracker_api_client:: common:: http:: Query ;
229
+ use torrust_rest_tracker_api_client:: connection_info:: ConnectionInfo ;
213
230
use torrust_rest_tracker_api_client:: v1:: client:: { headers_with_request_id, Client } ;
214
231
use torrust_tracker_test_helpers:: logging:: logs_contains_a_line_with;
215
232
use torrust_tracker_test_helpers:: { configuration, logging} ;
@@ -225,7 +242,9 @@ mod given_that_not_token_is_provided {
225
242
226
243
let request_id = Uuid :: new_v4 ( ) ;
227
244
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)
229
248
. unwrap ( )
230
249
. get_request_with_query ( "stats" , Query :: default ( ) , Some ( headers_with_request_id ( request_id) ) )
231
250
. await ;
0 commit comments