Andrew Geissler | 8f84068 | 2023-07-21 09:09:43 -0500 | [diff] [blame] | 1 | From 720240501dca0b4eacc3295665d7ced8719e11d2 Mon Sep 17 00:00:00 2001 |
| 2 | From: Quentin Pradet <quentin.pradet@gmail.com> |
| 3 | Date: Fri, 28 Apr 2023 23:28:43 +0400 |
| 4 | Subject: [PATCH] Test urllib3 2.0 |
| 5 | |
| 6 | Upstream-Status: Submitted [https://github.com/requests/toolbelt/pull/356] |
| 7 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 8 | --- |
| 9 | .../redirect_request_for_dump_all.json | 302 +++++++++++++----- |
| 10 | tests/cassettes/simple_get_request.json | 16 +- |
| 11 | tox.ini | 11 +- |
| 12 | 3 files changed, 239 insertions(+), 90 deletions(-) |
| 13 | |
| 14 | diff --git a/tests/cassettes/redirect_request_for_dump_all.json b/tests/cassettes/redirect_request_for_dump_all.json |
| 15 | index f713ff3..dc8fefe 100644 |
| 16 | --- a/tests/cassettes/redirect_request_for_dump_all.json |
| 17 | +++ b/tests/cassettes/redirect_request_for_dump_all.json |
| 18 | @@ -1,17 +1,25 @@ |
| 19 | { |
| 20 | "http_interactions": [ |
| 21 | { |
| 22 | - "recorded_at": "2015-11-14T22:53:20", |
| 23 | + "recorded_at": "2023-04-28T18:04:50", |
| 24 | "request": { |
| 25 | "body": { |
| 26 | "encoding": "utf-8", |
| 27 | "string": "" |
| 28 | }, |
| 29 | "headers": { |
| 30 | - "Accept": "*/*", |
| 31 | - "Accept-Encoding": "gzip, deflate", |
| 32 | - "Connection": "keep-alive", |
| 33 | - "User-Agent": "python-requests/2.8.1" |
| 34 | + "Accept": [ |
| 35 | + "*/*" |
| 36 | + ], |
| 37 | + "Accept-Encoding": [ |
| 38 | + "gzip, deflate" |
| 39 | + ], |
| 40 | + "Connection": [ |
| 41 | + "keep-alive" |
| 42 | + ], |
| 43 | + "User-Agent": [ |
| 44 | + "python-requests/2.28.1" |
| 45 | + ] |
| 46 | }, |
| 47 | "method": "GET", |
| 48 | "uri": "https://httpbin.org/redirect/5" |
| 49 | @@ -22,14 +30,30 @@ |
| 50 | "string": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n<title>Redirecting...</title>\n<h1>Redirecting...</h1>\n<p>You should be redirected automatically to target URL: <a href=\"/relative-redirect/4\">/relative-redirect/4</a>. If not click the link." |
| 51 | }, |
| 52 | "headers": { |
| 53 | - "Access-Control-Allow-Credentials": "true", |
| 54 | - "Access-Control-Allow-Origin": "*", |
| 55 | - "Connection": "keep-alive", |
| 56 | - "Content-Length": "247", |
| 57 | - "Content-Type": "text/html; charset=utf-8", |
| 58 | - "Date": "Sat, 14 Nov 2015 22:53:18 GMT", |
| 59 | - "Location": "/relative-redirect/4", |
| 60 | - "Server": "nginx" |
| 61 | + "Access-Control-Allow-Credentials": [ |
| 62 | + "true" |
| 63 | + ], |
| 64 | + "Access-Control-Allow-Origin": [ |
| 65 | + "*" |
| 66 | + ], |
| 67 | + "Connection": [ |
| 68 | + "keep-alive" |
| 69 | + ], |
| 70 | + "Content-Length": [ |
| 71 | + "247" |
| 72 | + ], |
| 73 | + "Content-Type": [ |
| 74 | + "text/html; charset=utf-8" |
| 75 | + ], |
| 76 | + "Date": [ |
| 77 | + "Fri, 28 Apr 2023 18:04:50 GMT" |
| 78 | + ], |
| 79 | + "Location": [ |
| 80 | + "/relative-redirect/4" |
| 81 | + ], |
| 82 | + "Server": [ |
| 83 | + "gunicorn/19.9.0" |
| 84 | + ] |
| 85 | }, |
| 86 | "status": { |
| 87 | "code": 302, |
| 88 | @@ -39,17 +63,25 @@ |
| 89 | } |
| 90 | }, |
| 91 | { |
| 92 | - "recorded_at": "2015-11-14T22:53:20", |
| 93 | + "recorded_at": "2023-04-28T18:04:52", |
| 94 | "request": { |
| 95 | "body": { |
| 96 | "encoding": "utf-8", |
| 97 | "string": "" |
| 98 | }, |
| 99 | "headers": { |
| 100 | - "Accept": "*/*", |
| 101 | - "Accept-Encoding": "gzip, deflate", |
| 102 | - "Connection": "keep-alive", |
| 103 | - "User-Agent": "python-requests/2.8.1" |
| 104 | + "Accept": [ |
| 105 | + "*/*" |
| 106 | + ], |
| 107 | + "Accept-Encoding": [ |
| 108 | + "gzip, deflate" |
| 109 | + ], |
| 110 | + "Connection": [ |
| 111 | + "keep-alive" |
| 112 | + ], |
| 113 | + "User-Agent": [ |
| 114 | + "python-requests/2.28.1" |
| 115 | + ] |
| 116 | }, |
| 117 | "method": "GET", |
| 118 | "uri": "https://httpbin.org/relative-redirect/4" |
| 119 | @@ -60,14 +92,30 @@ |
| 120 | "string": "" |
| 121 | }, |
| 122 | "headers": { |
| 123 | - "Access-Control-Allow-Credentials": "true", |
| 124 | - "Access-Control-Allow-Origin": "*", |
| 125 | - "Connection": "keep-alive", |
| 126 | - "Content-Length": "0", |
| 127 | - "Content-Type": "text/html; charset=utf-8", |
| 128 | - "Date": "Sat, 14 Nov 2015 22:53:18 GMT", |
| 129 | - "Location": "/relative-redirect/3", |
| 130 | - "Server": "nginx" |
| 131 | + "Access-Control-Allow-Credentials": [ |
| 132 | + "true" |
| 133 | + ], |
| 134 | + "Access-Control-Allow-Origin": [ |
| 135 | + "*" |
| 136 | + ], |
| 137 | + "Connection": [ |
| 138 | + "keep-alive" |
| 139 | + ], |
| 140 | + "Content-Length": [ |
| 141 | + "0" |
| 142 | + ], |
| 143 | + "Content-Type": [ |
| 144 | + "text/html; charset=utf-8" |
| 145 | + ], |
| 146 | + "Date": [ |
| 147 | + "Fri, 28 Apr 2023 18:04:52 GMT" |
| 148 | + ], |
| 149 | + "Location": [ |
| 150 | + "/relative-redirect/3" |
| 151 | + ], |
| 152 | + "Server": [ |
| 153 | + "gunicorn/19.9.0" |
| 154 | + ] |
| 155 | }, |
| 156 | "status": { |
| 157 | "code": 302, |
| 158 | @@ -77,17 +125,25 @@ |
| 159 | } |
| 160 | }, |
| 161 | { |
| 162 | - "recorded_at": "2015-11-14T22:53:20", |
| 163 | + "recorded_at": "2023-04-28T18:04:53", |
| 164 | "request": { |
| 165 | "body": { |
| 166 | "encoding": "utf-8", |
| 167 | "string": "" |
| 168 | }, |
| 169 | "headers": { |
| 170 | - "Accept": "*/*", |
| 171 | - "Accept-Encoding": "gzip, deflate", |
| 172 | - "Connection": "keep-alive", |
| 173 | - "User-Agent": "python-requests/2.8.1" |
| 174 | + "Accept": [ |
| 175 | + "*/*" |
| 176 | + ], |
| 177 | + "Accept-Encoding": [ |
| 178 | + "gzip, deflate" |
| 179 | + ], |
| 180 | + "Connection": [ |
| 181 | + "keep-alive" |
| 182 | + ], |
| 183 | + "User-Agent": [ |
| 184 | + "python-requests/2.28.1" |
| 185 | + ] |
| 186 | }, |
| 187 | "method": "GET", |
| 188 | "uri": "https://httpbin.org/relative-redirect/3" |
| 189 | @@ -98,14 +154,30 @@ |
| 190 | "string": "" |
| 191 | }, |
| 192 | "headers": { |
| 193 | - "Access-Control-Allow-Credentials": "true", |
| 194 | - "Access-Control-Allow-Origin": "*", |
| 195 | - "Connection": "keep-alive", |
| 196 | - "Content-Length": "0", |
| 197 | - "Content-Type": "text/html; charset=utf-8", |
| 198 | - "Date": "Sat, 14 Nov 2015 22:53:18 GMT", |
| 199 | - "Location": "/relative-redirect/2", |
| 200 | - "Server": "nginx" |
| 201 | + "Access-Control-Allow-Credentials": [ |
| 202 | + "true" |
| 203 | + ], |
| 204 | + "Access-Control-Allow-Origin": [ |
| 205 | + "*" |
| 206 | + ], |
| 207 | + "Connection": [ |
| 208 | + "keep-alive" |
| 209 | + ], |
| 210 | + "Content-Length": [ |
| 211 | + "0" |
| 212 | + ], |
| 213 | + "Content-Type": [ |
| 214 | + "text/html; charset=utf-8" |
| 215 | + ], |
| 216 | + "Date": [ |
| 217 | + "Fri, 28 Apr 2023 18:04:53 GMT" |
| 218 | + ], |
| 219 | + "Location": [ |
| 220 | + "/relative-redirect/2" |
| 221 | + ], |
| 222 | + "Server": [ |
| 223 | + "gunicorn/19.9.0" |
| 224 | + ] |
| 225 | }, |
| 226 | "status": { |
| 227 | "code": 302, |
| 228 | @@ -115,17 +187,25 @@ |
| 229 | } |
| 230 | }, |
| 231 | { |
| 232 | - "recorded_at": "2015-11-14T22:53:20", |
| 233 | + "recorded_at": "2023-04-28T18:04:55", |
| 234 | "request": { |
| 235 | "body": { |
| 236 | "encoding": "utf-8", |
| 237 | "string": "" |
| 238 | }, |
| 239 | "headers": { |
| 240 | - "Accept": "*/*", |
| 241 | - "Accept-Encoding": "gzip, deflate", |
| 242 | - "Connection": "keep-alive", |
| 243 | - "User-Agent": "python-requests/2.8.1" |
| 244 | + "Accept": [ |
| 245 | + "*/*" |
| 246 | + ], |
| 247 | + "Accept-Encoding": [ |
| 248 | + "gzip, deflate" |
| 249 | + ], |
| 250 | + "Connection": [ |
| 251 | + "keep-alive" |
| 252 | + ], |
| 253 | + "User-Agent": [ |
| 254 | + "python-requests/2.28.1" |
| 255 | + ] |
| 256 | }, |
| 257 | "method": "GET", |
| 258 | "uri": "https://httpbin.org/relative-redirect/2" |
| 259 | @@ -136,14 +216,30 @@ |
| 260 | "string": "" |
| 261 | }, |
| 262 | "headers": { |
| 263 | - "Access-Control-Allow-Credentials": "true", |
| 264 | - "Access-Control-Allow-Origin": "*", |
| 265 | - "Connection": "keep-alive", |
| 266 | - "Content-Length": "0", |
| 267 | - "Content-Type": "text/html; charset=utf-8", |
| 268 | - "Date": "Sat, 14 Nov 2015 22:53:18 GMT", |
| 269 | - "Location": "/relative-redirect/1", |
| 270 | - "Server": "nginx" |
| 271 | + "Access-Control-Allow-Credentials": [ |
| 272 | + "true" |
| 273 | + ], |
| 274 | + "Access-Control-Allow-Origin": [ |
| 275 | + "*" |
| 276 | + ], |
| 277 | + "Connection": [ |
| 278 | + "keep-alive" |
| 279 | + ], |
| 280 | + "Content-Length": [ |
| 281 | + "0" |
| 282 | + ], |
| 283 | + "Content-Type": [ |
| 284 | + "text/html; charset=utf-8" |
| 285 | + ], |
| 286 | + "Date": [ |
| 287 | + "Fri, 28 Apr 2023 18:04:55 GMT" |
| 288 | + ], |
| 289 | + "Location": [ |
| 290 | + "/relative-redirect/1" |
| 291 | + ], |
| 292 | + "Server": [ |
| 293 | + "gunicorn/19.9.0" |
| 294 | + ] |
| 295 | }, |
| 296 | "status": { |
| 297 | "code": 302, |
| 298 | @@ -153,17 +249,25 @@ |
| 299 | } |
| 300 | }, |
| 301 | { |
| 302 | - "recorded_at": "2015-11-14T22:53:20", |
| 303 | + "recorded_at": "2023-04-28T18:04:56", |
| 304 | "request": { |
| 305 | "body": { |
| 306 | "encoding": "utf-8", |
| 307 | "string": "" |
| 308 | }, |
| 309 | "headers": { |
| 310 | - "Accept": "*/*", |
| 311 | - "Accept-Encoding": "gzip, deflate", |
| 312 | - "Connection": "keep-alive", |
| 313 | - "User-Agent": "python-requests/2.8.1" |
| 314 | + "Accept": [ |
| 315 | + "*/*" |
| 316 | + ], |
| 317 | + "Accept-Encoding": [ |
| 318 | + "gzip, deflate" |
| 319 | + ], |
| 320 | + "Connection": [ |
| 321 | + "keep-alive" |
| 322 | + ], |
| 323 | + "User-Agent": [ |
| 324 | + "python-requests/2.28.1" |
| 325 | + ] |
| 326 | }, |
| 327 | "method": "GET", |
| 328 | "uri": "https://httpbin.org/relative-redirect/1" |
| 329 | @@ -174,14 +278,30 @@ |
| 330 | "string": "" |
| 331 | }, |
| 332 | "headers": { |
| 333 | - "Access-Control-Allow-Credentials": "true", |
| 334 | - "Access-Control-Allow-Origin": "*", |
| 335 | - "Connection": "keep-alive", |
| 336 | - "Content-Length": "0", |
| 337 | - "Content-Type": "text/html; charset=utf-8", |
| 338 | - "Date": "Sat, 14 Nov 2015 22:53:18 GMT", |
| 339 | - "Location": "/get", |
| 340 | - "Server": "nginx" |
| 341 | + "Access-Control-Allow-Credentials": [ |
| 342 | + "true" |
| 343 | + ], |
| 344 | + "Access-Control-Allow-Origin": [ |
| 345 | + "*" |
| 346 | + ], |
| 347 | + "Connection": [ |
| 348 | + "keep-alive" |
| 349 | + ], |
| 350 | + "Content-Length": [ |
| 351 | + "0" |
| 352 | + ], |
| 353 | + "Content-Type": [ |
| 354 | + "text/html; charset=utf-8" |
| 355 | + ], |
| 356 | + "Date": [ |
| 357 | + "Fri, 28 Apr 2023 18:04:56 GMT" |
| 358 | + ], |
| 359 | + "Location": [ |
| 360 | + "/get" |
| 361 | + ], |
| 362 | + "Server": [ |
| 363 | + "gunicorn/19.9.0" |
| 364 | + ] |
| 365 | }, |
| 366 | "status": { |
| 367 | "code": 302, |
| 368 | @@ -191,34 +311,56 @@ |
| 369 | } |
| 370 | }, |
| 371 | { |
| 372 | - "recorded_at": "2015-11-14T22:53:20", |
| 373 | + "recorded_at": "2023-04-28T18:04:58", |
| 374 | "request": { |
| 375 | "body": { |
| 376 | "encoding": "utf-8", |
| 377 | "string": "" |
| 378 | }, |
| 379 | "headers": { |
| 380 | - "Accept": "*/*", |
| 381 | - "Accept-Encoding": "gzip, deflate", |
| 382 | - "Connection": "keep-alive", |
| 383 | - "User-Agent": "python-requests/2.8.1" |
| 384 | + "Accept": [ |
| 385 | + "*/*" |
| 386 | + ], |
| 387 | + "Accept-Encoding": [ |
| 388 | + "gzip, deflate" |
| 389 | + ], |
| 390 | + "Connection": [ |
| 391 | + "keep-alive" |
| 392 | + ], |
| 393 | + "User-Agent": [ |
| 394 | + "python-requests/2.28.1" |
| 395 | + ] |
| 396 | }, |
| 397 | "method": "GET", |
| 398 | "uri": "https://httpbin.org/get" |
| 399 | }, |
| 400 | "response": { |
| 401 | "body": { |
| 402 | - "encoding": null, |
| 403 | - "string": "{\n \"args\": {}, \n \"headers\": {\n \"Accept\": \"*/*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Host\": \"httpbin.org\", \n \"User-Agent\": \"python-requests/2.8.1\"\n }, \n \"origin\": \"<IPADDR>\", \n \"url\": \"https://httpbin.org/get\"\n}\n" |
| 404 | + "encoding": "utf-8", |
| 405 | + "string": "{\n \"args\": {}, \n \"headers\": {\n \"Accept\": \"*/*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Host\": \"httpbin.org\", \n \"User-Agent\": \"python-requests/2.28.1\", \n \"X-Amzn-Trace-Id\": \"Root=1-644c0ac8-450daa2735c478ca518c5c8d\"\n }, \n \"origin\": \"83.198.52.66\", \n \"url\": \"https://httpbin.org/get\"\n}\n" |
| 406 | }, |
| 407 | "headers": { |
| 408 | - "Access-Control-Allow-Credentials": "true", |
| 409 | - "Access-Control-Allow-Origin": "*", |
| 410 | - "Connection": "keep-alive", |
| 411 | - "Content-Length": "239", |
| 412 | - "Content-Type": "application/json", |
| 413 | - "Date": "Sat, 14 Nov 2015 22:53:18 GMT", |
| 414 | - "Server": "nginx" |
| 415 | + "Access-Control-Allow-Credentials": [ |
| 416 | + "true" |
| 417 | + ], |
| 418 | + "Access-Control-Allow-Origin": [ |
| 419 | + "*" |
| 420 | + ], |
| 421 | + "Connection": [ |
| 422 | + "keep-alive" |
| 423 | + ], |
| 424 | + "Content-Length": [ |
| 425 | + "306" |
| 426 | + ], |
| 427 | + "Content-Type": [ |
| 428 | + "application/json" |
| 429 | + ], |
| 430 | + "Date": [ |
| 431 | + "Fri, 28 Apr 2023 18:04:58 GMT" |
| 432 | + ], |
| 433 | + "Server": [ |
| 434 | + "gunicorn/19.9.0" |
| 435 | + ] |
| 436 | }, |
| 437 | "status": { |
| 438 | "code": 200, |
| 439 | @@ -228,5 +370,5 @@ |
| 440 | } |
| 441 | } |
| 442 | ], |
| 443 | - "recorded_with": "betamax/0.5.1" |
| 444 | + "recorded_with": "betamax/0.8.2" |
| 445 | } |
| 446 | \ No newline at end of file |
| 447 | diff --git a/tests/cassettes/simple_get_request.json b/tests/cassettes/simple_get_request.json |
| 448 | index 68378cd..a97bcf1 100644 |
| 449 | --- a/tests/cassettes/simple_get_request.json |
| 450 | +++ b/tests/cassettes/simple_get_request.json |
| 451 | @@ -1,7 +1,7 @@ |
| 452 | { |
| 453 | "http_interactions": [ |
| 454 | { |
| 455 | - "recorded_at": "2015-11-14T22:33:32", |
| 456 | + "recorded_at": "2023-04-28T18:04:48", |
| 457 | "request": { |
| 458 | "body": { |
| 459 | "encoding": "utf-8", |
| 460 | @@ -18,7 +18,7 @@ |
| 461 | "keep-alive" |
| 462 | ], |
| 463 | "User-Agent": [ |
| 464 | - "python-requests/2.8.1" |
| 465 | + "python-requests/2.28.1" |
| 466 | ] |
| 467 | }, |
| 468 | "method": "GET", |
| 469 | @@ -26,8 +26,8 @@ |
| 470 | }, |
| 471 | "response": { |
| 472 | "body": { |
| 473 | - "encoding": null, |
| 474 | - "string": "{\n \"args\": {}, \n \"headers\": {\n \"Accept\": \"*/*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Host\": \"httpbin.org\", \n \"User-Agent\": \"python-requests/2.8.1\"\n }, \n \"origin\": \"<IPADDR>\", \n \"url\": \"https://httpbin.org/get\"\n}\n" |
| 475 | + "encoding": "utf-8", |
| 476 | + "string": "{\n \"args\": {}, \n \"headers\": {\n \"Accept\": \"*/*\", \n \"Accept-Encoding\": \"gzip, deflate\", \n \"Host\": \"httpbin.org\", \n \"User-Agent\": \"python-requests/2.28.1\", \n \"X-Amzn-Trace-Id\": \"Root=1-644c0ac0-4986bed42b965a007af785e1\"\n }, \n \"origin\": \"83.198.52.66\", \n \"url\": \"https://httpbin.org/get\"\n}\n" |
| 477 | }, |
| 478 | "headers": { |
| 479 | "Access-Control-Allow-Credentials": [ |
| 480 | @@ -40,16 +40,16 @@ |
| 481 | "keep-alive" |
| 482 | ], |
| 483 | "Content-Length": [ |
| 484 | - "239" |
| 485 | + "306" |
| 486 | ], |
| 487 | "Content-Type": [ |
| 488 | "application/json" |
| 489 | ], |
| 490 | "Date": [ |
| 491 | - "Sat, 14 Nov 2015 22:33:30 GMT" |
| 492 | + "Fri, 28 Apr 2023 18:04:48 GMT" |
| 493 | ], |
| 494 | "Server": [ |
| 495 | - "nginx" |
| 496 | + "gunicorn/19.9.0" |
| 497 | ] |
| 498 | }, |
| 499 | "status": { |
| 500 | @@ -60,5 +60,5 @@ |
| 501 | } |
| 502 | } |
| 503 | ], |
| 504 | - "recorded_with": "betamax/0.5.1" |
| 505 | + "recorded_with": "betamax/0.8.2" |
| 506 | } |
| 507 | \ No newline at end of file |
| 508 | diff --git a/tox.ini b/tox.ini |
| 509 | index 64b6ab3..e27c275 100644 |
| 510 | --- a/tox.ini |
| 511 | +++ b/tox.ini |
| 512 | @@ -1,5 +1,5 @@ |
| 513 | [tox] |
| 514 | -envlist = py{27,37,38,39,310,311,py,py3},py{27,37}-flake8,noopenssl,docstrings |
| 515 | +envlist = py{27,37,38,39,310,311,py,py3},py{27,37}-flake8,noopenssl,docstrings,urllib3-2.0 |
| 516 | |
| 517 | [gh-actions] |
| 518 | python = |
| 519 | @@ -8,12 +8,13 @@ python = |
| 520 | 3.8: py38 |
| 521 | 3.9: py39 |
| 522 | 3.10: py310 |
| 523 | - 3.11: py311 |
| 524 | + 3.11: py311, urllib3-2.0 |
| 525 | |
| 526 | [testenv] |
| 527 | pip_pre = False |
| 528 | deps = |
| 529 | requests{env:REQUESTS_VERSION:>=2.0.1,<3.0.0} |
| 530 | + urllib3<2.0.0 |
| 531 | pytest |
| 532 | mock;python_version<"3.3" |
| 533 | pyopenssl |
| 534 | @@ -34,6 +35,12 @@ deps = |
| 535 | commands = |
| 536 | pytest -W error::DeprecationWarning {posargs} |
| 537 | |
| 538 | +[testenv:urllib3-2.0] |
| 539 | +basepython = python3.11 |
| 540 | +commands = |
| 541 | + pip install -U urllib3>=2.0.0 |
| 542 | + pytest -W error::DeprecationWarning {posargs} |
| 543 | + |
| 544 | [testenv:py27-flake8] |
| 545 | basepython = python2.7 |
| 546 | deps = |