@@ -147,6 +147,8 @@ func TestJA4H_B(t *testing.T) {
147
147
}
148
148
149
149
func TestJA4H_C (t * testing.T ) {
150
+ ctx := t .Context ()
151
+
150
152
tests := []struct {
151
153
name string
152
154
cookies func () []* http.Cookie
@@ -155,15 +157,15 @@ func TestJA4H_C(t *testing.T) {
155
157
{
156
158
name : "no cookies" ,
157
159
cookies : func () []* http.Cookie {
158
- req , _ := http .NewRequest ( http .MethodGet , "http://example.com" , http .NoBody )
160
+ req , _ := http .NewRequestWithContext ( ctx , http .MethodGet , "http://example.com" , http .NoBody )
159
161
return req .Cookies ()
160
162
},
161
163
expectedResult : "000000000000" ,
162
164
},
163
165
{
164
166
name : "one cookie" ,
165
167
cookies : func () []* http.Cookie {
166
- req , _ := http .NewRequest ( http .MethodGet , "http://example.com" , http .NoBody )
168
+ req , _ := http .NewRequestWithContext ( ctx , http .MethodGet , "http://example.com" , http .NoBody )
167
169
req .AddCookie (& http.Cookie {Name : "foo" , Value : "bar" })
168
170
return req .Cookies ()
169
171
},
@@ -172,7 +174,7 @@ func TestJA4H_C(t *testing.T) {
172
174
{
173
175
name : "duplicate cookies" ,
174
176
cookies : func () []* http.Cookie {
175
- req , _ := http .NewRequest ( http .MethodGet , "http://example.com" , http .NoBody )
177
+ req , _ := http .NewRequestWithContext ( ctx , http .MethodGet , "http://example.com" , http .NoBody )
176
178
req .AddCookie (& http.Cookie {Name : "foo" , Value : "bar" })
177
179
req .AddCookie (& http.Cookie {Name : "foo" , Value : "bar2" })
178
180
return req .Cookies ()
@@ -182,7 +184,7 @@ func TestJA4H_C(t *testing.T) {
182
184
{
183
185
name : "multiple cookies" ,
184
186
cookies : func () []* http.Cookie {
185
- req , _ := http .NewRequest ( http .MethodGet , "http://example.com" , http .NoBody )
187
+ req , _ := http .NewRequestWithContext ( ctx , http .MethodGet , "http://example.com" , http .NoBody )
186
188
req .AddCookie (& http.Cookie {Name : "foo" , Value : "bar" })
187
189
req .AddCookie (& http.Cookie {Name : "bar" , Value : "foo" })
188
190
cookies := req .Cookies ()
@@ -206,6 +208,8 @@ func TestJA4H_C(t *testing.T) {
206
208
}
207
209
208
210
func TestJA4H_D (t * testing.T ) {
211
+ ctx := t .Context ()
212
+
209
213
tests := []struct {
210
214
name string
211
215
cookies func () []* http.Cookie
@@ -214,15 +218,15 @@ func TestJA4H_D(t *testing.T) {
214
218
{
215
219
name : "no cookies" ,
216
220
cookies : func () []* http.Cookie {
217
- req , _ := http .NewRequest ( http .MethodGet , "http://example.com" , http .NoBody )
221
+ req , _ := http .NewRequestWithContext ( ctx , http .MethodGet , "http://example.com" , http .NoBody )
218
222
return req .Cookies ()
219
223
},
220
224
expectedResult : "000000000000" ,
221
225
},
222
226
{
223
227
name : "one cookie" ,
224
228
cookies : func () []* http.Cookie {
225
- req , _ := http .NewRequest ( http .MethodGet , "http://example.com" , http .NoBody )
229
+ req , _ := http .NewRequestWithContext ( ctx , http .MethodGet , "http://example.com" , http .NoBody )
226
230
req .AddCookie (& http.Cookie {Name : "foo" , Value : "bar" })
227
231
return req .Cookies ()
228
232
},
@@ -231,7 +235,7 @@ func TestJA4H_D(t *testing.T) {
231
235
{
232
236
name : "duplicate cookies" ,
233
237
cookies : func () []* http.Cookie {
234
- req , _ := http .NewRequest ( http .MethodGet , "http://example.com" , http .NoBody )
238
+ req , _ := http .NewRequestWithContext ( ctx , http .MethodGet , "http://example.com" , http .NoBody )
235
239
req .AddCookie (& http.Cookie {Name : "foo" , Value : "bar" })
236
240
req .AddCookie (& http.Cookie {Name : "foo" , Value : "bar2" })
237
241
return req .Cookies ()
@@ -241,7 +245,7 @@ func TestJA4H_D(t *testing.T) {
241
245
{
242
246
name : "multiple cookies" ,
243
247
cookies : func () []* http.Cookie {
244
- req , _ := http .NewRequest ( http .MethodGet , "http://example.com" , http .NoBody )
248
+ req , _ := http .NewRequestWithContext ( ctx , http .MethodGet , "http://example.com" , http .NoBody )
245
249
req .AddCookie (& http.Cookie {Name : "foo" , Value : "bar" })
246
250
req .AddCookie (& http.Cookie {Name : "bar" , Value : "foo" })
247
251
cookies := req .Cookies ()
0 commit comments