0s autopkgtest [16:08:16]: starting date and time: 2024-07-26 16:08:16+0000 0s autopkgtest [16:08:16]: git checkout: fd3bed09 nova: allow more retries for quota issues 0s autopkgtest [16:08:16]: host juju-7f2275-prod-proposed-migration-environment-3; command line: /home/ubuntu/autopkgtest/runner/autopkgtest --output-dir /tmp/autopkgtest-work.7lf0e5hp/out --timeout-copy=6000 --setup-commands /home/ubuntu/autopkgtest-cloud/worker-config-production/setup-canonical.sh --apt-pocket=proposed=src:httpx --apt-upgrade python-authlib --timeout-short=300 --timeout-copy=20000 --timeout-build=20000 --env=ADT_TEST_TRIGGERS=httpx/0.27.0-1 -- ssh -s /home/ubuntu/autopkgtest/ssh-setup/nova -- --flavor autopkgtest --security-groups autopkgtest-juju-7f2275-prod-proposed-migration-environment-3@bos03-arm64-42.secgroup --name adt-oracular-arm64-python-authlib-20240726-160816-juju-7f2275-prod-proposed-migration-environment-3-724b2caf-e19b-4c54-b83b-5650efeb2c5d --image adt/ubuntu-oracular-arm64-server --keyname testbed-juju-7f2275-prod-proposed-migration-environment-3 --net-id=net_prod-proposed-migration -e TERM=linux -e ''"'"'http_proxy=http://squid.internal:3128'"'"'' -e ''"'"'https_proxy=http://squid.internal:3128'"'"'' -e ''"'"'no_proxy=127.0.0.1,127.0.1.1,login.ubuntu.com,localhost,localdomain,novalocal,internal,archive.ubuntu.com,ports.ubuntu.com,security.ubuntu.com,ddebs.ubuntu.com,changelogs.ubuntu.com,keyserver.ubuntu.com,launchpadlibrarian.net,launchpadcontent.net,launchpad.net,10.24.0.0/24,keystone.ps5.canonical.com,objectstorage.prodstack5.canonical.com'"'"'' --mirror=http://ftpmaster.internal/ubuntu/ 119s autopkgtest [16:10:15]: testbed dpkg architecture: arm64 120s autopkgtest [16:10:16]: testbed apt version: 2.9.6 120s autopkgtest [16:10:16]: @@@@@@@@@@@@@@@@@@@@ test bed setup 121s Get:1 http://ftpmaster.internal/ubuntu oracular-proposed InRelease [126 kB] 122s Get:2 http://ftpmaster.internal/ubuntu oracular-proposed/main Sources [50.6 kB] 122s Get:3 http://ftpmaster.internal/ubuntu oracular-proposed/restricted Sources [8548 B] 122s Get:4 http://ftpmaster.internal/ubuntu oracular-proposed/universe Sources [436 kB] 122s Get:5 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse Sources [4288 B] 122s Get:6 http://ftpmaster.internal/ubuntu oracular-proposed/main arm64 Packages [88.6 kB] 122s Get:7 http://ftpmaster.internal/ubuntu oracular-proposed/main arm64 c-n-f Metadata [2116 B] 122s Get:8 http://ftpmaster.internal/ubuntu oracular-proposed/restricted arm64 Packages [43.9 kB] 122s Get:9 http://ftpmaster.internal/ubuntu oracular-proposed/restricted arm64 c-n-f Metadata [364 B] 122s Get:10 http://ftpmaster.internal/ubuntu oracular-proposed/universe arm64 Packages [482 kB] 122s Get:11 http://ftpmaster.internal/ubuntu oracular-proposed/universe arm64 c-n-f Metadata [8752 B] 122s Get:12 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse arm64 Packages [8744 B] 122s Get:13 http://ftpmaster.internal/ubuntu oracular-proposed/multiverse arm64 c-n-f Metadata [276 B] 124s Fetched 1261 kB in 1s (1179 kB/s) 124s Reading package lists... 127s Reading package lists... 127s Building dependency tree... 127s Reading state information... 127s Calculating upgrade... 128s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 128s Reading package lists... 128s Building dependency tree... 128s Reading state information... 129s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 130s Hit:1 http://ftpmaster.internal/ubuntu oracular-proposed InRelease 130s Hit:2 http://ftpmaster.internal/ubuntu oracular InRelease 130s Hit:3 http://ftpmaster.internal/ubuntu oracular-updates InRelease 130s Hit:4 http://ftpmaster.internal/ubuntu oracular-security InRelease 132s Reading package lists... 132s Reading package lists... 132s Building dependency tree... 132s Reading state information... 133s Calculating upgrade... 134s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 134s Reading package lists... 134s Building dependency tree... 134s Reading state information... 136s 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 141s autopkgtest [16:10:37]: testbed running kernel: Linux 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 02:32:42 UTC 2024 142s autopkgtest [16:10:38]: @@@@@@@@@@@@@@@@@@@@ apt-source python-authlib 146s Get:1 http://ftpmaster.internal/ubuntu oracular/universe python-authlib 1.3.1-1 (dsc) [2494 B] 146s Get:2 http://ftpmaster.internal/ubuntu oracular/universe python-authlib 1.3.1-1 (tar) [320 kB] 146s Get:3 http://ftpmaster.internal/ubuntu oracular/universe python-authlib 1.3.1-1 (diff) [5564 B] 146s gpgv: Signature made Thu Jun 6 10:39:37 2024 UTC 146s gpgv: using EDDSA key EE9AD6F90520FA11F69F4824477B0DB0263A54D8 146s gpgv: issuer "stefanor@debian.org" 146s gpgv: Can't check signature: No public key 146s dpkg-source: warning: cannot verify inline signature for ./python-authlib_1.3.1-1.dsc: no acceptable signature found 147s autopkgtest [16:10:43]: testing package python-authlib version 1.3.1-1 147s autopkgtest [16:10:43]: build not needed 147s autopkgtest [16:10:43]: test unittests3: preparing testbed 149s Reading package lists... 149s Building dependency tree... 149s Reading state information... 149s Starting pkgProblemResolver with broken count: 0 149s Starting 2 pkgProblemResolver with broken count: 0 149s Done 150s The following additional packages will be installed: 150s libjs-jquery python3-all python3-anyio python3-asgiref 150s python3-async-generator python3-authlib python3-cachelib python3-click 150s python3-colorama python3-django python3-flask python3-flask-sqlalchemy 150s python3-greenlet python3-h11 python3-httpcore python3-httpx 150s python3-iniconfig python3-itsdangerous python3-packaging python3-pluggy 150s python3-pycryptodome python3-pytest python3-pytest-asyncio 150s python3-pytest-django python3-sniffio python3-sqlalchemy python3-sqlparse 150s python3-starlette python3-werkzeug 150s Suggested packages: 150s python-cachelib-doc bpython3 geoip-database-contrib gettext ipython3 150s libgdal20 libsqlite3-mod-spatialite python-django-doc python3-bcrypt 150s python3-flup python3-memcache python3-mysqldb python3-pil python3-psycopg2 150s python3-selenium python3-sqlite python3-dotenv python-flask-doc 150s python-greenlet-dev python-greenlet-doc python-sqlalchemy-doc python3-fdb 150s python3-pymssql python3-asyncpg python3-aiosqlite python-sqlparse-doc 150s python3-databases python-werkzeug-doc python3-lxml python3-watchdog 150s Recommended packages: 150s javascript-common python3-tz python3-simplejson python3-sqlalchemy-ext 150s python3-uvicorn | python3-daphne python3-aiofiles python3-multipart 150s python3-pyinotify 150s The following NEW packages will be installed: 150s autopkgtest-satdep libjs-jquery python3-all python3-anyio python3-asgiref 150s python3-async-generator python3-authlib python3-cachelib python3-click 150s python3-colorama python3-django python3-flask python3-flask-sqlalchemy 150s python3-greenlet python3-h11 python3-httpcore python3-httpx 150s python3-iniconfig python3-itsdangerous python3-packaging python3-pluggy 150s python3-pycryptodome python3-pytest python3-pytest-asyncio 150s python3-pytest-django python3-sniffio python3-sqlalchemy python3-sqlparse 150s python3-starlette python3-werkzeug 150s 0 upgraded, 30 newly installed, 0 to remove and 0 not upgraded. 150s Need to get 6792 kB/6793 kB of archives. 150s After this operation, 46.2 MB of additional disk space will be used. 150s Get:1 /tmp/autopkgtest.7zVo1T/1-autopkgtest-satdep.deb autopkgtest-satdep arm64 0 [808 B] 150s Get:2 http://ftpmaster.internal/ubuntu oracular/main arm64 libjs-jquery all 3.6.1+dfsg+~3.5.14-1 [328 kB] 151s Get:3 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-all arm64 3.12.3-0ubuntu1 [888 B] 151s Get:4 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-sniffio all 1.3.1-1 [7262 B] 151s Get:5 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-anyio all 4.3.0-1 [56.6 kB] 151s Get:6 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-asgiref all 3.8.1-1 [24.8 kB] 151s Get:7 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-async-generator all 1.10-4 [17.5 kB] 151s Get:8 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-pycryptodome arm64 3.20.0+dfsg-1 [1088 kB] 151s Get:9 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-authlib all 1.3.1-1 [112 kB] 151s Get:10 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-cachelib all 0.13.0-2 [20.7 kB] 151s Get:11 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-colorama all 0.4.6-4 [32.1 kB] 151s Get:12 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-click all 8.1.7-1 [79.1 kB] 151s Get:13 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-sqlparse all 0.5.1-1 [32.6 kB] 151s Get:14 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-django all 3:4.2.14-1 [2917 kB] 151s Get:15 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-itsdangerous all 2.2.0-1 [15.2 kB] 151s Get:16 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-werkzeug all 3.0.3-1 [170 kB] 151s Get:17 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-flask all 3.0.3-1ubuntu1 [83.2 kB] 151s Get:18 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-greenlet arm64 3.0.3-0ubuntu5 [153 kB] 151s Get:19 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-sqlalchemy all 1.4.50+ds1-1build1 [1020 kB] 151s Get:20 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-flask-sqlalchemy all 3.0.3-1 [30.9 kB] 151s Get:21 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-h11 all 0.14.0-1 [51.1 kB] 151s Get:22 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-httpcore all 1.0.4-1 [38.8 kB] 151s Get:23 http://ftpmaster.internal/ubuntu oracular-proposed/universe arm64 python3-httpx all 0.27.0-1 [60.9 kB] 151s Get:24 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-iniconfig all 1.1.1-2 [6024 B] 151s Get:25 http://ftpmaster.internal/ubuntu oracular/main arm64 python3-packaging all 24.1-1 [41.4 kB] 151s Get:26 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-pluggy all 1.5.0-1 [21.0 kB] 151s Get:27 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-pytest all 7.4.4-1 [305 kB] 151s Get:28 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-pytest-asyncio all 0.20.3-1.3 [10.7 kB] 151s Get:29 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-pytest-django all 4.5.2-3 [18.5 kB] 151s Get:30 http://ftpmaster.internal/ubuntu oracular/universe arm64 python3-starlette all 0.31.1-1 [49.4 kB] 153s Fetched 6792 kB in 1s (6550 kB/s) 153s Selecting previously unselected package libjs-jquery. 153s (Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 78607 files and directories currently installed.) 153s Preparing to unpack .../00-libjs-jquery_3.6.1+dfsg+~3.5.14-1_all.deb ... 153s Unpacking libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 153s Selecting previously unselected package python3-all. 153s Preparing to unpack .../01-python3-all_3.12.3-0ubuntu1_arm64.deb ... 153s Unpacking python3-all (3.12.3-0ubuntu1) ... 153s Selecting previously unselected package python3-sniffio. 153s Preparing to unpack .../02-python3-sniffio_1.3.1-1_all.deb ... 153s Unpacking python3-sniffio (1.3.1-1) ... 153s Selecting previously unselected package python3-anyio. 153s Preparing to unpack .../03-python3-anyio_4.3.0-1_all.deb ... 153s Unpacking python3-anyio (4.3.0-1) ... 153s Selecting previously unselected package python3-asgiref. 153s Preparing to unpack .../04-python3-asgiref_3.8.1-1_all.deb ... 153s Unpacking python3-asgiref (3.8.1-1) ... 153s Selecting previously unselected package python3-async-generator. 153s Preparing to unpack .../05-python3-async-generator_1.10-4_all.deb ... 153s Unpacking python3-async-generator (1.10-4) ... 153s Selecting previously unselected package python3-pycryptodome. 153s Preparing to unpack .../06-python3-pycryptodome_3.20.0+dfsg-1_arm64.deb ... 153s Unpacking python3-pycryptodome (3.20.0+dfsg-1) ... 154s Selecting previously unselected package python3-authlib. 154s Preparing to unpack .../07-python3-authlib_1.3.1-1_all.deb ... 154s Unpacking python3-authlib (1.3.1-1) ... 154s Selecting previously unselected package python3-cachelib. 154s Preparing to unpack .../08-python3-cachelib_0.13.0-2_all.deb ... 154s Unpacking python3-cachelib (0.13.0-2) ... 154s Selecting previously unselected package python3-colorama. 154s Preparing to unpack .../09-python3-colorama_0.4.6-4_all.deb ... 154s Unpacking python3-colorama (0.4.6-4) ... 154s Selecting previously unselected package python3-click. 154s Preparing to unpack .../10-python3-click_8.1.7-1_all.deb ... 154s Unpacking python3-click (8.1.7-1) ... 154s Selecting previously unselected package python3-sqlparse. 154s Preparing to unpack .../11-python3-sqlparse_0.5.1-1_all.deb ... 154s Unpacking python3-sqlparse (0.5.1-1) ... 154s Selecting previously unselected package python3-django. 154s Preparing to unpack .../12-python3-django_3%3a4.2.14-1_all.deb ... 154s Unpacking python3-django (3:4.2.14-1) ... 156s Selecting previously unselected package python3-itsdangerous. 156s Preparing to unpack .../13-python3-itsdangerous_2.2.0-1_all.deb ... 156s Unpacking python3-itsdangerous (2.2.0-1) ... 156s Selecting previously unselected package python3-werkzeug. 156s Preparing to unpack .../14-python3-werkzeug_3.0.3-1_all.deb ... 156s Unpacking python3-werkzeug (3.0.3-1) ... 156s Selecting previously unselected package python3-flask. 156s Preparing to unpack .../15-python3-flask_3.0.3-1ubuntu1_all.deb ... 156s Unpacking python3-flask (3.0.3-1ubuntu1) ... 156s Selecting previously unselected package python3-greenlet. 156s Preparing to unpack .../16-python3-greenlet_3.0.3-0ubuntu5_arm64.deb ... 156s Unpacking python3-greenlet (3.0.3-0ubuntu5) ... 156s Selecting previously unselected package python3-sqlalchemy. 156s Preparing to unpack .../17-python3-sqlalchemy_1.4.50+ds1-1build1_all.deb ... 156s Unpacking python3-sqlalchemy (1.4.50+ds1-1build1) ... 157s Selecting previously unselected package python3-flask-sqlalchemy. 157s Preparing to unpack .../18-python3-flask-sqlalchemy_3.0.3-1_all.deb ... 157s Unpacking python3-flask-sqlalchemy (3.0.3-1) ... 157s Selecting previously unselected package python3-h11. 157s Preparing to unpack .../19-python3-h11_0.14.0-1_all.deb ... 157s Unpacking python3-h11 (0.14.0-1) ... 157s Selecting previously unselected package python3-httpcore. 157s Preparing to unpack .../20-python3-httpcore_1.0.4-1_all.deb ... 157s Unpacking python3-httpcore (1.0.4-1) ... 157s Selecting previously unselected package python3-httpx. 157s Preparing to unpack .../21-python3-httpx_0.27.0-1_all.deb ... 157s Unpacking python3-httpx (0.27.0-1) ... 157s Selecting previously unselected package python3-iniconfig. 157s Preparing to unpack .../22-python3-iniconfig_1.1.1-2_all.deb ... 157s Unpacking python3-iniconfig (1.1.1-2) ... 157s Selecting previously unselected package python3-packaging. 157s Preparing to unpack .../23-python3-packaging_24.1-1_all.deb ... 157s Unpacking python3-packaging (24.1-1) ... 158s Selecting previously unselected package python3-pluggy. 158s Preparing to unpack .../24-python3-pluggy_1.5.0-1_all.deb ... 158s Unpacking python3-pluggy (1.5.0-1) ... 158s Selecting previously unselected package python3-pytest. 158s Preparing to unpack .../25-python3-pytest_7.4.4-1_all.deb ... 158s Unpacking python3-pytest (7.4.4-1) ... 158s Selecting previously unselected package python3-pytest-asyncio. 158s Preparing to unpack .../26-python3-pytest-asyncio_0.20.3-1.3_all.deb ... 158s Unpacking python3-pytest-asyncio (0.20.3-1.3) ... 158s Selecting previously unselected package python3-pytest-django. 158s Preparing to unpack .../27-python3-pytest-django_4.5.2-3_all.deb ... 158s Unpacking python3-pytest-django (4.5.2-3) ... 158s Selecting previously unselected package python3-starlette. 158s Preparing to unpack .../28-python3-starlette_0.31.1-1_all.deb ... 158s Unpacking python3-starlette (0.31.1-1) ... 158s Selecting previously unselected package autopkgtest-satdep. 158s Preparing to unpack .../29-1-autopkgtest-satdep.deb ... 158s Unpacking autopkgtest-satdep (0) ... 159s Setting up python3-iniconfig (1.1.1-2) ... 159s Setting up python3-sniffio (1.3.1-1) ... 159s Setting up python3-async-generator (1.10-4) ... 159s Setting up python3-anyio (4.3.0-1) ... 160s Setting up python3-colorama (0.4.6-4) ... 160s Setting up python3-pycryptodome (3.20.0+dfsg-1) ... 162s Setting up python3-itsdangerous (2.2.0-1) ... 162s Setting up python3-all (3.12.3-0ubuntu1) ... 162s Setting up python3-starlette (0.31.1-1) ... 163s Setting up python3-click (8.1.7-1) ... 163s Setting up python3-packaging (24.1-1) ... 163s Setting up python3-sqlparse (0.5.1-1) ... 164s Setting up python3-greenlet (3.0.3-0ubuntu5) ... 164s Setting up python3-h11 (0.14.0-1) ... 164s Setting up python3-pluggy (1.5.0-1) ... 164s Setting up python3-cachelib (0.13.0-2) ... 164s Setting up libjs-jquery (3.6.1+dfsg+~3.5.14-1) ... 164s Setting up python3-asgiref (3.8.1-1) ... 165s Setting up python3-authlib (1.3.1-1) ... 165s Setting up python3-httpcore (1.0.4-1) ... 166s Setting up python3-django (3:4.2.14-1) ... 168s Setting up python3-pytest (7.4.4-1) ... 169s Setting up python3-pytest-django (4.5.2-3) ... 169s Setting up python3-sqlalchemy (1.4.50+ds1-1build1) ... 171s Setting up python3-httpx (0.27.0-1) ... 172s Setting up python3-werkzeug (3.0.3-1) ... 172s Setting up python3-pytest-asyncio (0.20.3-1.3) ... 172s Setting up python3-flask (3.0.3-1ubuntu1) ... 173s Setting up python3-flask-sqlalchemy (3.0.3-1) ... 173s Setting up autopkgtest-satdep (0) ... 173s Processing triggers for man-db (2.12.1-2) ... 180s (Reading database ... 86441 files and directories currently installed.) 180s Removing autopkgtest-satdep (0) ... 181s autopkgtest [16:11:17]: test unittests3: [----------------------- 183s === python3.12 === 185s ============================= test session starts ============================== 185s platform linux -- Python 3.12.4, pytest-7.4.4, pluggy-1.5.0 185s rootdir: /tmp/autopkgtest.7zVo1T/autopkgtest_tmp 185s configfile: setup.cfg 185s plugins: anyio-4.3.0, django-4.5.2, asyncio-0.20.3 185s asyncio: mode=Mode.STRICT 185s collected 101 items 185s 185s tests/core/test_oauth2/test_rfc6749_misc.py ...... [ 5%] 186s tests/core/test_oauth2/test_rfc7523.py ........................ [ 29%] 186s tests/core/test_oauth2/test_rfc7591.py ...... [ 35%] 186s tests/core/test_oauth2/test_rfc7662.py ...... [ 41%] 186s tests/core/test_oauth2/test_rfc8414.py .......................... [ 67%] 186s tests/core/test_oidc/test_core.py .......... [ 77%] 186s tests/core/test_oidc/test_discovery.py ....................... [100%] 186s 186s ============================= 101 passed in 2.10s ============================== 188s ============================= test session starts ============================== 188s platform linux -- Python 3.12.4, pytest-7.4.4, pluggy-1.5.0 188s django: settings: tests.clients.test_django.settings (from env) 188s rootdir: /tmp/autopkgtest.7zVo1T/autopkgtest_tmp 188s configfile: setup.cfg 188s plugins: anyio-4.3.0, django-4.5.2, asyncio-0.20.3 188s asyncio: mode=Mode.STRICT 188s collected 167 items 188s 188s tests/clients/test_django/test_oauth_client.py ............. [ 7%] 188s tests/clients/test_flask/test_oauth_client.py .................... [ 19%] 188s tests/clients/test_flask/test_user_mixin.py ..... [ 22%] 188s tests/clients/test_httpx/test_assertion_client.py .. [ 23%] 189s tests/clients/test_httpx/test_async_assertion_client.py F. [ 25%] 194s tests/clients/test_httpx/test_async_oauth1_client.py FFFFFFF [ 29%] 202s tests/clients/test_httpx/test_async_oauth2_client.py FFFFFFss...FFFFFFF. [ 40%] 204s FFFFF. [ 44%] 204s tests/clients/test_httpx/test_oauth1_client.py ....... [ 48%] 205s tests/clients/test_httpx/test_oauth2_client.py ...................... [ 61%] 205s tests/clients/test_requests/test_assertion_session.py .. [ 62%] 205s tests/clients/test_requests/test_oauth1_session.py ................ [ 72%] 206s tests/clients/test_requests/test_oauth2_session.py ..................... [ 85%] 206s ......... [ 90%] 211s tests/clients/test_starlette/test_oauth_client.py ...FF.FFFF.F [ 97%] 212s tests/clients/test_starlette/test_user_mixin.py F..F [100%] 212s 212s =================================== FAILURES =================================== 212s ______________________________ test_refresh_token ______________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_refresh_token(): 212s async def verifier(request): 212s content = await request.body() 212s if str(request.url) == 'https://i.b/token': 212s assert b'assertion=' in content 212s 212s async with AsyncAssertionClient( 212s 'https://i.b/token', 212s grant_type=AsyncAssertionClient.JWT_BEARER_GRANT_TYPE, 212s issuer='foo', 212s subject='foo', 212s audience='foo', 212s alg='HS256', 212s key='secret', 212s app=AsyncMockDispatch(default_token, assert_func=verifier) 212s ) as client: 212s > await client.get('https://i.b') 212s 212s tests/clients/test_httpx/test_async_assertion_client.py:33: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_client.py:1801: in get 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/assertion_client.py:38: in request 212s await self.refresh_token() 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/assertion_client.py:45: in _refresh_token 212s resp = await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/assertion_client.py:41: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s _____________________ test_fetch_request_token_via_header ______________________ 212s 212s @pytest.mark.asyncio 212s async def test_fetch_request_token_via_header(): 212s request_token = {'oauth_token': '1', 'oauth_token_secret': '2'} 212s 212s async def assert_func(request): 212s auth_header = request.headers.get('authorization') 212s assert 'oauth_consumer_key="id"' in auth_header 212s assert 'oauth_signature=' in auth_header 212s 212s app = AsyncMockDispatch(request_token, assert_func=assert_func) 212s async with AsyncOAuth1Client('id', 'secret', app=app) as client: 212s > response = await client.fetch_request_token(oauth_url) 212s 212s tests/clients/test_httpx/test_async_oauth1_client.py:24: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth1_client.py:70: in _fetch_token 212s token = self.parse_response_token(resp.status_code, to_unicode(text)) 212s /usr/lib/python3/dist-packages/authlib/oauth1/client.py:152: in parse_response_token 212s self.handle_error('fetch_token_denied', message) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s error_type = 'fetch_token_denied' 212s error_description = 'Token request failed with code 404, response was \'\n\n\t\t\n\t\n\n\'.' 212s 212s @staticmethod 212s def handle_error(error_type, error_description): 212s > raise OAuthError(error_type, error_description) 212s E authlib.integrations.base_client.errors.OAuthError: fetch_token_denied: Token request failed with code 404, response was ' 212s E 212s E 212s E 212s E 404 - Not Found 212s E 212s E 212s E

404 - Not Found

212s E 212s E 212s E 212s E '. 212s 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth1_client.py:76: OAuthError 212s ______________________ test_fetch_request_token_via_body _______________________ 212s 212s @pytest.mark.asyncio 212s async def test_fetch_request_token_via_body(): 212s request_token = {'oauth_token': '1', 'oauth_token_secret': '2'} 212s 212s async def assert_func(request): 212s auth_header = request.headers.get('authorization') 212s assert auth_header is None 212s 212s content = await request.body() 212s assert b'oauth_consumer_key=id' in content 212s assert b'&oauth_signature=' in content 212s 212s mock_response = AsyncMockDispatch(request_token, assert_func=assert_func) 212s 212s async with AsyncOAuth1Client( 212s 'id', 'secret', signature_type=SIGNATURE_TYPE_BODY, 212s app=mock_response, 212s ) as client: 212s > response = await client.fetch_request_token(oauth_url) 212s 212s tests/clients/test_httpx/test_async_oauth1_client.py:47: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth1_client.py:70: in _fetch_token 212s token = self.parse_response_token(resp.status_code, to_unicode(text)) 212s /usr/lib/python3/dist-packages/authlib/oauth1/client.py:152: in parse_response_token 212s self.handle_error('fetch_token_denied', message) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s error_type = 'fetch_token_denied' 212s error_description = 'Token request failed with code 404, response was \'\n\n\t\t\n\t\n\n\'.' 212s 212s @staticmethod 212s def handle_error(error_type, error_description): 212s > raise OAuthError(error_type, error_description) 212s E authlib.integrations.base_client.errors.OAuthError: fetch_token_denied: Token request failed with code 404, response was ' 212s E 212s E 212s E 212s E 404 - Not Found 212s E 212s E 212s E

404 - Not Found

212s E 212s E 212s E 212s E '. 212s 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth1_client.py:76: OAuthError 212s ______________________ test_fetch_request_token_via_query ______________________ 212s 212s @pytest.mark.asyncio 212s async def test_fetch_request_token_via_query(): 212s request_token = {'oauth_token': '1', 'oauth_token_secret': '2'} 212s 212s async def assert_func(request): 212s auth_header = request.headers.get('authorization') 212s assert auth_header is None 212s 212s url = str(request.url) 212s assert 'oauth_consumer_key=id' in url 212s assert '&oauth_signature=' in url 212s 212s mock_response = AsyncMockDispatch(request_token, assert_func=assert_func) 212s 212s async with AsyncOAuth1Client( 212s 'id', 'secret', signature_type=SIGNATURE_TYPE_QUERY, 212s app=mock_response, 212s ) as client: 212s > response = await client.fetch_request_token(oauth_url) 212s 212s tests/clients/test_httpx/test_async_oauth1_client.py:70: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth1_client.py:70: in _fetch_token 212s token = self.parse_response_token(resp.status_code, to_unicode(text)) 212s /usr/lib/python3/dist-packages/authlib/oauth1/client.py:152: in parse_response_token 212s self.handle_error('fetch_token_denied', message) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s error_type = 'fetch_token_denied' 212s error_description = 'Token request failed with code 404, response was \'\n\n\t\t\n\t\n\n\'.' 212s 212s @staticmethod 212s def handle_error(error_type, error_description): 212s > raise OAuthError(error_type, error_description) 212s E authlib.integrations.base_client.errors.OAuthError: fetch_token_denied: Token request failed with code 404, response was ' 212s E 212s E 212s E 212s E 404 - Not Found 212s E 212s E 212s E

404 - Not Found

212s E 212s E 212s E 212s E '. 212s 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth1_client.py:76: OAuthError 212s ___________________________ test_fetch_access_token ____________________________ 212s 212s @pytest.mark.asyncio 212s async def test_fetch_access_token(): 212s request_token = {'oauth_token': '1', 'oauth_token_secret': '2'} 212s 212s async def assert_func(request): 212s auth_header = request.headers.get('authorization') 212s assert 'oauth_verifier="d"' in auth_header 212s assert 'oauth_token="foo"' in auth_header 212s assert 'oauth_consumer_key="id"' in auth_header 212s assert 'oauth_signature=' in auth_header 212s 212s mock_response = AsyncMockDispatch(request_token, assert_func=assert_func) 212s async with AsyncOAuth1Client( 212s 'id', 'secret', token='foo', token_secret='bar', 212s app=mock_response, 212s ) as client: 212s with pytest.raises(OAuthError): 212s await client.fetch_access_token(oauth_url) 212s 212s > response = await client.fetch_access_token(oauth_url, verifier='d') 212s 212s tests/clients/test_httpx/test_async_oauth1_client.py:94: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth1_client.py:63: in fetch_access_token 212s token = await self._fetch_token(url, **kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth1_client.py:70: in _fetch_token 212s token = self.parse_response_token(resp.status_code, to_unicode(text)) 212s /usr/lib/python3/dist-packages/authlib/oauth1/client.py:152: in parse_response_token 212s self.handle_error('fetch_token_denied', message) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s error_type = 'fetch_token_denied' 212s error_description = 'Token request failed with code 404, response was \'\n\n\t\t\n\t\n\n\'.' 212s 212s @staticmethod 212s def handle_error(error_type, error_description): 212s > raise OAuthError(error_type, error_description) 212s E authlib.integrations.base_client.errors.OAuthError: fetch_token_denied: Token request failed with code 404, response was ' 212s E 212s E 212s E 212s E 404 - Not Found 212s E 212s E 212s E

404 - Not Found

212s E 212s E 212s E 212s E '. 212s 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth1_client.py:76: OAuthError 212s _____________________________ test_get_via_header ______________________________ 212s 212s @pytest.mark.asyncio 212s async def test_get_via_header(): 212s mock_response = AsyncMockDispatch(b'hello') 212s async with AsyncOAuth1Client( 212s 'id', 'secret', token='foo', token_secret='bar', 212s app=mock_response, 212s ) as client: 212s response = await client.get('https://example.com/') 212s 212s > assert response.content == b'hello' 212s E AssertionError: assert b'\n\n' == b'hello' 212s E At index 0 diff: b'<' != b'h' 212s E Use -v to get more diff 212s 212s tests/clients/test_httpx/test_async_oauth1_client.py:108: AssertionError 212s ______________________________ test_get_via_body _______________________________ 212s 212s @pytest.mark.asyncio 212s async def test_get_via_body(): 212s async def assert_func(request): 212s content = await request.body() 212s assert b'oauth_token=foo' in content 212s assert b'oauth_consumer_key=id' in content 212s assert b'oauth_signature=' in content 212s 212s mock_response = AsyncMockDispatch(b'hello', assert_func=assert_func) 212s async with AsyncOAuth1Client( 212s 'id', 'secret', token='foo', token_secret='bar', 212s signature_type=SIGNATURE_TYPE_BODY, 212s app=mock_response, 212s ) as client: 212s response = await client.post('https://example.com/') 212s 212s > assert response.content == b'hello' 212s E AssertionError: assert b'\n\n' == b'hello' 212s E At index 0 diff: b'<' != b'h' 212s E Use -v to get more diff 212s 212s tests/clients/test_httpx/test_async_oauth1_client.py:132: AssertionError 212s ______________________________ test_get_via_query ______________________________ 212s 212s @pytest.mark.asyncio 212s async def test_get_via_query(): 212s mock_response = AsyncMockDispatch(b'hello') 212s async with AsyncOAuth1Client( 212s 'id', 'secret', token='foo', token_secret='bar', 212s signature_type=SIGNATURE_TYPE_QUERY, 212s app=mock_response, 212s ) as client: 212s response = await client.get('https://example.com/') 212s 212s > assert response.content == b'hello' 212s E AssertionError: assert b'\n\n' == b'hello' 212s E At index 0 diff: b'<' != b'h' 212s E Use -v to get more diff 212s 212s tests/clients/test_httpx/test_async_oauth1_client.py:149: AssertionError 212s __________ test_add_token_get_request[assert_token_in_header-header] ___________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s assert_func = 212s token_placement = 'header' 212s 212s @pytest.mark.asyncio 212s @pytest.mark.parametrize( 212s "assert_func, token_placement", 212s [ 212s (assert_token_in_header, "header"), 212s (assert_token_in_body, "body"), 212s (assert_token_in_uri, "uri") 212s ] 212s ) 212s async def test_add_token_get_request(assert_func, token_placement): 212s mock_response = AsyncMockDispatch({'a': 'a'}, assert_func=assert_func) 212s async with AsyncOAuth2Client( 212s 'foo', 212s token=default_token, 212s token_placement=token_placement, 212s app=mock_response 212s ) as client: 212s > resp = await client.get('https://i.b') 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:62: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_client.py:1801: in get 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ____________ test_add_token_get_request[assert_token_in_body-body] _____________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s assert_func = 212s token_placement = 'body' 212s 212s @pytest.mark.asyncio 212s @pytest.mark.parametrize( 212s "assert_func, token_placement", 212s [ 212s (assert_token_in_header, "header"), 212s (assert_token_in_body, "body"), 212s (assert_token_in_uri, "uri") 212s ] 212s ) 212s async def test_add_token_get_request(assert_func, token_placement): 212s mock_response = AsyncMockDispatch({'a': 'a'}, assert_func=assert_func) 212s async with AsyncOAuth2Client( 212s 'foo', 212s token=default_token, 212s token_placement=token_placement, 212s app=mock_response 212s ) as client: 212s > resp = await client.get('https://i.b') 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:62: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_client.py:1801: in get 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s _____________ test_add_token_get_request[assert_token_in_uri-uri] ______________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s assert_func = 212s token_placement = 'uri' 212s 212s @pytest.mark.asyncio 212s @pytest.mark.parametrize( 212s "assert_func, token_placement", 212s [ 212s (assert_token_in_header, "header"), 212s (assert_token_in_body, "body"), 212s (assert_token_in_uri, "uri") 212s ] 212s ) 212s async def test_add_token_get_request(assert_func, token_placement): 212s mock_response = AsyncMockDispatch({'a': 'a'}, assert_func=assert_func) 212s async with AsyncOAuth2Client( 212s 'foo', 212s token=default_token, 212s token_placement=token_placement, 212s app=mock_response 212s ) as client: 212s > resp = await client.get('https://i.b') 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:62: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_client.py:1801: in get 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ______ test_add_token_to_streaming_request[assert_token_in_header-header] ______ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s assert_func = 212s token_placement = 'header' 212s 212s @pytest.mark.asyncio 212s @pytest.mark.parametrize( 212s "assert_func, token_placement", 212s [ 212s (assert_token_in_header, "header"), 212s (assert_token_in_body, "body"), 212s (assert_token_in_uri, "uri") 212s ] 212s ) 212s async def test_add_token_to_streaming_request(assert_func, token_placement): 212s mock_response = AsyncMockDispatch({'a': 'a'}, assert_func=assert_func) 212s async with AsyncOAuth2Client( 212s 'foo', 212s token=default_token, 212s token_placement=token_placement, 212s app=mock_response 212s ) as client: 212s > async with client.stream("GET", 'https://i.b') as stream: 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:85: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3.12/contextlib.py:210: in __aenter__ 212s return await anext(self.gen) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:103: in stream 212s async with super().stream( 212s /usr/lib/python3.12/contextlib.py:210: in __aenter__ 212s return await anext(self.gen) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1617: in stream 212s response = await self.send( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ________ test_add_token_to_streaming_request[assert_token_in_body-body] ________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s assert_func = 212s token_placement = 'body' 212s 212s @pytest.mark.asyncio 212s @pytest.mark.parametrize( 212s "assert_func, token_placement", 212s [ 212s (assert_token_in_header, "header"), 212s (assert_token_in_body, "body"), 212s (assert_token_in_uri, "uri") 212s ] 212s ) 212s async def test_add_token_to_streaming_request(assert_func, token_placement): 212s mock_response = AsyncMockDispatch({'a': 'a'}, assert_func=assert_func) 212s async with AsyncOAuth2Client( 212s 'foo', 212s token=default_token, 212s token_placement=token_placement, 212s app=mock_response 212s ) as client: 212s > async with client.stream("GET", 'https://i.b') as stream: 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:85: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3.12/contextlib.py:210: in __aenter__ 212s return await anext(self.gen) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:103: in stream 212s async with super().stream( 212s /usr/lib/python3.12/contextlib.py:210: in __aenter__ 212s return await anext(self.gen) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1617: in stream 212s response = await self.send( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s _________ test_add_token_to_streaming_request[assert_token_in_uri-uri] _________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s assert_func = 212s token_placement = 'uri' 212s 212s @pytest.mark.asyncio 212s @pytest.mark.parametrize( 212s "assert_func, token_placement", 212s [ 212s (assert_token_in_header, "header"), 212s (assert_token_in_body, "body"), 212s (assert_token_in_uri, "uri") 212s ] 212s ) 212s async def test_add_token_to_streaming_request(assert_func, token_placement): 212s mock_response = AsyncMockDispatch({'a': 'a'}, assert_func=assert_func) 212s async with AsyncOAuth2Client( 212s 'foo', 212s token=default_token, 212s token_placement=token_placement, 212s app=mock_response 212s ) as client: 212s > async with client.stream("GET", 'https://i.b') as stream: 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:85: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3.12/contextlib.py:210: in __aenter__ 212s return await anext(self.gen) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:103: in stream 212s async with super().stream( 212s /usr/lib/python3.12/contextlib.py:210: in __aenter__ 212s return await anext(self.gen) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1617: in stream 212s response = await self.send( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ____________________________ test_fetch_token_post _____________________________ 212s 212s @pytest.mark.asyncio 212s async def test_fetch_token_post(): 212s url = 'https://example.com/token' 212s 212s async def assert_func(request): 212s content = await request.body() 212s content = content.decode() 212s assert 'code=v' in content 212s assert 'client_id=' in content 212s assert 'grant_type=authorization_code' in content 212s 212s mock_response = AsyncMockDispatch(default_token, assert_func=assert_func) 212s async with AsyncOAuth2Client('foo', app=mock_response) as client: 212s > token = await client.fetch_token(url, authorization_response='https://i.b/?code=v') 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:156: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:138: in _fetch_token 212s return self.parse_response_token(resp) 212s /usr/lib/python3/dist-packages/authlib/oauth2/client.py:342: in parse_response_token 212s token = resp.json() 212s /usr/lib/python3/dist-packages/httpx/_models.py:764: in json 212s return jsonlib.loads(self.content, **kwargs) 212s /usr/lib/python3.12/json/__init__.py:346: in loads 212s return _default_decoder.decode(s) 212s /usr/lib/python3.12/json/decoder.py:337: in decode 212s obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s s = '\n\n\t\t\n\t\n\n' 212s idx = 0 212s 212s def raw_decode(self, s, idx=0): 212s """Decode a JSON document from ``s`` (a ``str`` beginning with 212s a JSON document) and return a 2-tuple of the Python 212s representation and the index in ``s`` where the document ended. 212s 212s This can be used to decode a JSON document from a string that may 212s have extraneous data at the end. 212s 212s """ 212s try: 212s obj, end = self.scan_once(s, idx) 212s except StopIteration as err: 212s > raise JSONDecodeError("Expecting value", s, err.value) from None 212s E json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 212s 212s /usr/lib/python3.12/json/decoder.py:355: JSONDecodeError 212s _____________________________ test_fetch_token_get _____________________________ 212s 212s @pytest.mark.asyncio 212s async def test_fetch_token_get(): 212s url = 'https://example.com/token' 212s 212s async def assert_func(request): 212s url = str(request.url) 212s assert 'code=v' in url 212s assert 'client_id=' in url 212s assert 'grant_type=authorization_code' in url 212s 212s mock_response = AsyncMockDispatch(default_token, assert_func=assert_func) 212s async with AsyncOAuth2Client('foo', app=mock_response) as client: 212s authorization_response = 'https://i.b/?code=v' 212s > token = await client.fetch_token( 212s url, authorization_response=authorization_response, method='GET') 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:186: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:138: in _fetch_token 212s return self.parse_response_token(resp) 212s /usr/lib/python3/dist-packages/authlib/oauth2/client.py:342: in parse_response_token 212s token = resp.json() 212s /usr/lib/python3/dist-packages/httpx/_models.py:764: in json 212s return jsonlib.loads(self.content, **kwargs) 212s /usr/lib/python3.12/json/__init__.py:346: in loads 212s return _default_decoder.decode(s) 212s /usr/lib/python3.12/json/decoder.py:337: in decode 212s obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s s = '\n\n\n Example Domain\n\n \n \n

More information...

\n\n\n\n' 212s idx = 0 212s 212s def raw_decode(self, s, idx=0): 212s """Decode a JSON document from ``s`` (a ``str`` beginning with 212s a JSON document) and return a 2-tuple of the Python 212s representation and the index in ``s`` where the document ended. 212s 212s This can be used to decode a JSON document from a string that may 212s have extraneous data at the end. 212s 212s """ 212s try: 212s obj, end = self.scan_once(s, idx) 212s except StopIteration as err: 212s > raise JSONDecodeError("Expecting value", s, err.value) from None 212s E json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 212s 212s /usr/lib/python3.12/json/decoder.py:355: JSONDecodeError 212s __________________ test_token_auth_method_client_secret_post ___________________ 212s 212s @pytest.mark.asyncio 212s async def test_token_auth_method_client_secret_post(): 212s url = 'https://example.com/token' 212s 212s async def assert_func(request): 212s content = await request.body() 212s content = content.decode() 212s assert 'code=v' in content 212s assert 'client_id=' in content 212s assert 'client_secret=bar' in content 212s assert 'grant_type=authorization_code' in content 212s 212s mock_response = AsyncMockDispatch(default_token, assert_func=assert_func) 212s async with AsyncOAuth2Client( 212s 'foo', 'bar', 212s token_endpoint_auth_method='client_secret_post', 212s app=mock_response 212s ) as client: 212s > token = await client.fetch_token(url, code='v') 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:220: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:138: in _fetch_token 212s return self.parse_response_token(resp) 212s /usr/lib/python3/dist-packages/authlib/oauth2/client.py:342: in parse_response_token 212s token = resp.json() 212s /usr/lib/python3/dist-packages/httpx/_models.py:764: in json 212s return jsonlib.loads(self.content, **kwargs) 212s /usr/lib/python3.12/json/__init__.py:346: in loads 212s return _default_decoder.decode(s) 212s /usr/lib/python3.12/json/decoder.py:337: in decode 212s obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s s = '\n\n\t\t\n\t\n\n' 212s idx = 0 212s 212s def raw_decode(self, s, idx=0): 212s """Decode a JSON document from ``s`` (a ``str`` beginning with 212s a JSON document) and return a 2-tuple of the Python 212s representation and the index in ``s`` where the document ended. 212s 212s This can be used to decode a JSON document from a string that may 212s have extraneous data at the end. 212s 212s """ 212s try: 212s obj, end = self.scan_once(s, idx) 212s except StopIteration as err: 212s > raise JSONDecodeError("Expecting value", s, err.value) from None 212s E json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 212s 212s /usr/lib/python3.12/json/decoder.py:355: JSONDecodeError 212s _______________________ test_access_token_response_hook ________________________ 212s 212s @pytest.mark.asyncio 212s async def test_access_token_response_hook(): 212s url = 'https://example.com/token' 212s 212s def _access_token_response_hook(resp): 212s assert resp.json() == default_token 212s return resp 212s 212s access_token_response_hook = mock.Mock(side_effect=_access_token_response_hook) 212s app = AsyncMockDispatch(default_token) 212s async with AsyncOAuth2Client('foo', token=default_token, app=app) as sess: 212s sess.register_compliance_hook( 212s 'access_token_response', 212s access_token_response_hook 212s ) 212s > assert await sess.fetch_token(url) == default_token 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:240: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:136: in _fetch_token 212s resp = hook(resp) 212s /usr/lib/python3.12/unittest/mock.py:1134: in __call__ 212s return self._mock_call(*args, **kwargs) 212s /usr/lib/python3.12/unittest/mock.py:1138: in _mock_call 212s return self._execute_mock_call(*args, **kwargs) 212s /usr/lib/python3.12/unittest/mock.py:1199: in _execute_mock_call 212s result = effect(*args, **kwargs) 212s tests/clients/test_httpx/test_async_oauth2_client.py:230: in _access_token_response_hook 212s assert resp.json() == default_token 212s /usr/lib/python3/dist-packages/httpx/_models.py:764: in json 212s return jsonlib.loads(self.content, **kwargs) 212s /usr/lib/python3.12/json/__init__.py:346: in loads 212s return _default_decoder.decode(s) 212s /usr/lib/python3.12/json/decoder.py:337: in decode 212s obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s s = '\n\n\t\t\n\t\n\n' 212s idx = 0 212s 212s def raw_decode(self, s, idx=0): 212s """Decode a JSON document from ``s`` (a ``str`` beginning with 212s a JSON document) and return a 2-tuple of the Python 212s representation and the index in ``s`` where the document ended. 212s 212s This can be used to decode a JSON document from a string that may 212s have extraneous data at the end. 212s 212s """ 212s try: 212s obj, end = self.scan_once(s, idx) 212s except StopIteration as err: 212s > raise JSONDecodeError("Expecting value", s, err.value) from None 212s E json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 212s 212s /usr/lib/python3.12/json/decoder.py:355: JSONDecodeError 212s ___________________________ test_password_grant_type ___________________________ 212s 212s @pytest.mark.asyncio 212s async def test_password_grant_type(): 212s url = 'https://example.com/token' 212s 212s async def assert_func(request): 212s content = await request.body() 212s content = content.decode() 212s assert 'username=v' in content 212s assert 'scope=profile' in content 212s assert 'grant_type=password' in content 212s 212s app = AsyncMockDispatch(default_token, assert_func=assert_func) 212s async with AsyncOAuth2Client('foo', scope='profile', app=app) as sess: 212s > token = await sess.fetch_token(url, username='v', password='v') 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:257: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:138: in _fetch_token 212s return self.parse_response_token(resp) 212s /usr/lib/python3/dist-packages/authlib/oauth2/client.py:342: in parse_response_token 212s token = resp.json() 212s /usr/lib/python3/dist-packages/httpx/_models.py:764: in json 212s return jsonlib.loads(self.content, **kwargs) 212s /usr/lib/python3.12/json/__init__.py:346: in loads 212s return _default_decoder.decode(s) 212s /usr/lib/python3.12/json/decoder.py:337: in decode 212s obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s s = '\n\n\t\t\n\t\n\n' 212s idx = 0 212s 212s def raw_decode(self, s, idx=0): 212s """Decode a JSON document from ``s`` (a ``str`` beginning with 212s a JSON document) and return a 2-tuple of the Python 212s representation and the index in ``s`` where the document ended. 212s 212s This can be used to decode a JSON document from a string that may 212s have extraneous data at the end. 212s 212s """ 212s try: 212s obj, end = self.scan_once(s, idx) 212s except StopIteration as err: 212s > raise JSONDecodeError("Expecting value", s, err.value) from None 212s E json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 212s 212s /usr/lib/python3.12/json/decoder.py:355: JSONDecodeError 212s _________________________ test_client_credentials_type _________________________ 212s 212s @pytest.mark.asyncio 212s async def test_client_credentials_type(): 212s url = 'https://example.com/token' 212s 212s async def assert_func(request): 212s content = await request.body() 212s content = content.decode() 212s assert 'scope=profile' in content 212s assert 'grant_type=client_credentials' in content 212s 212s app = AsyncMockDispatch(default_token, assert_func=assert_func) 212s async with AsyncOAuth2Client('foo', scope='profile', app=app) as sess: 212s > token = await sess.fetch_token(url) 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:277: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:138: in _fetch_token 212s return self.parse_response_token(resp) 212s /usr/lib/python3/dist-packages/authlib/oauth2/client.py:342: in parse_response_token 212s token = resp.json() 212s /usr/lib/python3/dist-packages/httpx/_models.py:764: in json 212s return jsonlib.loads(self.content, **kwargs) 212s /usr/lib/python3.12/json/__init__.py:346: in loads 212s return _default_decoder.decode(s) 212s /usr/lib/python3.12/json/decoder.py:337: in decode 212s obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s s = '\n\n\t\t\n\t\n\n' 212s idx = 0 212s 212s def raw_decode(self, s, idx=0): 212s """Decode a JSON document from ``s`` (a ``str`` beginning with 212s a JSON document) and return a 2-tuple of the Python 212s representation and the index in ``s`` where the document ended. 212s 212s This can be used to decode a JSON document from a string that may 212s have extraneous data at the end. 212s 212s """ 212s try: 212s obj, end = self.scan_once(s, idx) 212s except StopIteration as err: 212s > raise JSONDecodeError("Expecting value", s, err.value) from None 212s E json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 212s 212s /usr/lib/python3.12/json/decoder.py:355: JSONDecodeError 212s ______________ test_cleans_previous_token_before_fetching_new_one ______________ 212s 212s @pytest.mark.asyncio 212s async def test_cleans_previous_token_before_fetching_new_one(): 212s now = int(time.time()) 212s new_token = deepcopy(default_token) 212s past = now - 7200 212s default_token['expires_at'] = past 212s new_token['expires_at'] = now + 3600 212s url = 'https://example.com/token' 212s 212s app = AsyncMockDispatch(new_token) 212s with mock.patch('time.time', lambda: now): 212s async with AsyncOAuth2Client('foo', token=default_token, app=app) as sess: 212s > assert await sess.fetch_token(url) == new_token 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:296: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:138: in _fetch_token 212s return self.parse_response_token(resp) 212s /usr/lib/python3/dist-packages/authlib/oauth2/client.py:342: in parse_response_token 212s token = resp.json() 212s /usr/lib/python3/dist-packages/httpx/_models.py:764: in json 212s return jsonlib.loads(self.content, **kwargs) 212s /usr/lib/python3.12/json/__init__.py:346: in loads 212s return _default_decoder.decode(s) 212s /usr/lib/python3.12/json/decoder.py:337: in decode 212s obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s s = '\n\n\t\t\n\t\n\n' 212s idx = 0 212s 212s def raw_decode(self, s, idx=0): 212s """Decode a JSON document from ``s`` (a ``str`` beginning with 212s a JSON document) and return a 2-tuple of the Python 212s representation and the index in ``s`` where the document ended. 212s 212s This can be used to decode a JSON document from a string that may 212s have extraneous data at the end. 212s 212s """ 212s try: 212s obj, end = self.scan_once(s, idx) 212s except StopIteration as err: 212s > raise JSONDecodeError("Expecting value", s, err.value) from None 212s E json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) 212s 212s /usr/lib/python3.12/json/decoder.py:355: JSONDecodeError 212s ___________________________ test_auto_refresh_token ____________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_auto_refresh_token(): 212s 212s async def _update_token(token, refresh_token=None, access_token=None): 212s assert refresh_token == 'b' 212s assert token == default_token 212s 212s update_token = mock.Mock(side_effect=_update_token) 212s 212s old_token = dict( 212s access_token='a', refresh_token='b', 212s token_type='bearer', expires_at=100 212s ) 212s 212s app = AsyncMockDispatch(default_token) 212s async with AsyncOAuth2Client( 212s 'foo', token=old_token, token_endpoint='https://i.b/token', 212s update_token=update_token, app=app 212s ) as sess: 212s > await sess.get('https://i.b/user') 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:324: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_client.py:1801: in get 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:86: in request 212s await self.ensure_active_token(self.token) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:113: in ensure_active_token 212s await self.refresh_token(url, refresh_token=refresh_token) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:142: in _refresh_token 212s resp = await self.post( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ___________________________ test_auto_refresh_token2 ___________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_auto_refresh_token2(): 212s 212s async def _update_token(token, refresh_token=None, access_token=None): 212s assert access_token == 'a' 212s assert token == default_token 212s 212s update_token = mock.Mock(side_effect=_update_token) 212s 212s old_token = dict( 212s access_token='a', 212s token_type='bearer', 212s expires_at=100 212s ) 212s 212s app = AsyncMockDispatch(default_token) 212s 212s async with AsyncOAuth2Client( 212s 'foo', token=old_token, 212s token_endpoint='https://i.b/token', 212s grant_type='client_credentials', 212s app=app, 212s ) as client: 212s > await client.get('https://i.b/user') 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:363: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_client.py:1801: in get 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:86: in request 212s await self.ensure_active_token(self.token) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:116: in ensure_active_token 212s new_token = await self.fetch_token(url, grant_type='client_credentials') 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:125: in _fetch_token 212s resp = await self.post( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ___________________________ test_auto_refresh_token3 ___________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_auto_refresh_token3(): 212s async def _update_token(token, refresh_token=None, access_token=None): 212s assert access_token == 'a' 212s assert token == default_token 212s 212s update_token = mock.Mock(side_effect=_update_token) 212s 212s old_token = dict( 212s access_token='a', 212s token_type='bearer', 212s expires_at=100 212s ) 212s 212s app = AsyncMockDispatch(default_token) 212s 212s async with AsyncOAuth2Client( 212s 'foo', token=old_token, token_endpoint='https://i.b/token', 212s update_token=update_token, grant_type='client_credentials', 212s app=app, 212s ) as client: 212s > await client.post('https://i.b/user', json={'foo': 'bar'}) 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:396: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:86: in request 212s await self.ensure_active_token(self.token) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:116: in ensure_active_token 212s new_token = await self.fetch_token(url, grant_type='client_credentials') 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:125: in _fetch_token 212s resp = await self.post( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ___________________________ test_auto_refresh_token4 ___________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_auto_refresh_token4(): 212s async def _update_token(token, refresh_token=None, access_token=None): 212s # This test only makes sense if the expired token is refreshed 212s token["expires_at"] = int(time.time()) + 3600 212s # artificial sleep to force other coroutines to wake 212s await asyncio.sleep(0.1) 212s 212s update_token = mock.Mock(side_effect=_update_token) 212s 212s old_token = dict( 212s access_token='old', 212s token_type='bearer', 212s expires_at=100 212s ) 212s 212s app = AsyncMockDispatch(default_token) 212s 212s async with AsyncOAuth2Client( 212s 'foo', token=old_token, token_endpoint='https://i.b/token', 212s update_token=update_token, grant_type='client_credentials', 212s app=app, 212s ) as client: 212s coroutines = [client.get('https://i.b/user') for x in range(10)] 212s > await asyncio.gather(*coroutines) 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:423: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_client.py:1801: in get 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:86: in request 212s await self.ensure_active_token(self.token) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:116: in ensure_active_token 212s new_token = await self.fetch_token(url, grant_type='client_credentials') 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:125: in _fetch_token 212s resp = await self.post( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ______________________________ test_revoke_token _______________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_revoke_token(): 212s answer = {'status': 'ok'} 212s app = AsyncMockDispatch(answer) 212s 212s async with AsyncOAuth2Client('a', app=app) as sess: 212s > resp = await sess.revoke_token('https://i.b/token', 'hi') 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py:432: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ____________________________ test_oauth1_authorize _____________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_oauth1_authorize(): 212s oauth = OAuth() 212s app = AsyncPathMapDispatch({ 212s '/request-token': {'body': 'oauth_token=foo&oauth_verifier=baz'}, 212s '/token': {'body': 'oauth_token=a&oauth_token_secret=b'}, 212s }) 212s client = oauth.register( 212s 'dev', 212s client_id='dev', 212s client_secret='dev', 212s request_token_url='https://i.b/request-token', 212s api_base_url='https://i.b/api', 212s access_token_url='https://i.b/token', 212s authorize_url='https://i.b/authorize', 212s client_kwargs={ 212s 'app': app, 212s } 212s ) 212s 212s req_scope = {'type': 'http', 'session': {}} 212s req = Request(req_scope) 212s > resp = await client.authorize_redirect(req, 'https://b.com/bar') 212s 212s tests/clients/test_starlette/test_oauth_client.py:62: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/starlette_client/apps.py:34: in authorize_redirect 212s rv = await self.create_authorization_url(redirect_uri, **kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:38: in create_authorization_url 212s request_token = await client.fetch_request_token(self.request_token_url, **params) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth1_client.py:68: in _fetch_token 212s resp = await self.post(url, **kwargs) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post 212s return await self.request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ____________________________ test_oauth2_authorize _____________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_oauth2_authorize(): 212s oauth = OAuth() 212s app = AsyncPathMapDispatch({ 212s '/token': {'body': get_bearer_token()} 212s }) 212s client = oauth.register( 212s 'dev', 212s client_id='dev', 212s client_secret='dev', 212s api_base_url='https://i.b/api', 212s access_token_url='https://i.b/token', 212s authorize_url='https://i.b/authorize', 212s client_kwargs={ 212s 'app': app, 212s } 212s ) 212s 212s req_scope = {'type': 'http', 'session': {}} 212s req = Request(req_scope) 212s resp = await client.authorize_redirect(req, 'https://b.com/bar') 212s assert resp.status_code == 302 212s url = resp.headers.get('Location') 212s assert 'state=' in url 212s state = dict(url_decode(urlparse.urlparse(url).query))['state'] 212s 212s assert f'_state_dev_{state}' in req.session 212s 212s req_scope.update( 212s { 212s 'path': '/', 212s 'query_string': f'code=a&state={state}', 212s 'session': req.session, 212s } 212s ) 212s req = Request(req_scope) 212s > token = await client.authorize_access_token(req) 212s 212s tests/clients/test_starlette/test_oauth_client.py:108: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/starlette_client/apps.py:81: in authorize_access_token 212s token = await self.fetch_access_token(**params, **kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:125: in fetch_access_token 212s token = await client.fetch_token(token_endpoint, **params) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:125: in _fetch_token 212s resp = await self.post( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s _____________________ test_oauth2_authorize_code_challenge _____________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_oauth2_authorize_code_challenge(): 212s app = AsyncPathMapDispatch({ 212s '/token': {'body': get_bearer_token()} 212s }) 212s oauth = OAuth() 212s client = oauth.register( 212s 'dev', 212s client_id='dev', 212s api_base_url='https://i.b/api', 212s access_token_url='https://i.b/token', 212s authorize_url='https://i.b/authorize', 212s client_kwargs={ 212s 'code_challenge_method': 'S256', 212s 'app': app, 212s }, 212s ) 212s 212s req_scope = {'type': 'http', 'session': {}} 212s req = Request(req_scope) 212s 212s resp = await client.authorize_redirect(req, redirect_uri='https://b.com/bar') 212s assert resp.status_code == 302 212s 212s url = resp.headers.get('Location') 212s assert 'code_challenge=' in url 212s assert 'code_challenge_method=S256' in url 212s 212s state = dict(url_decode(urlparse.urlparse(url).query))['state'] 212s state_data = req.session[f'_state_dev_{state}']['data'] 212s 212s verifier = state_data['code_verifier'] 212s assert verifier is not None 212s 212s req_scope.update( 212s { 212s 'path': '/', 212s 'query_string': f'code=a&state={state}'.encode(), 212s 'session': req.session, 212s } 212s ) 212s req = Request(req_scope) 212s 212s > token = await client.authorize_access_token(req) 212s 212s tests/clients/test_starlette/test_oauth_client.py:183: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/starlette_client/apps.py:81: in authorize_access_token 212s token = await self.fetch_access_token(**params, **kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:125: in fetch_access_token 212s token = await client.fetch_token(token_endpoint, **params) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:125: in _fetch_token 212s resp = await self.post( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1892: in post 212s return await self.request( 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ______________________ test_with_fetch_token_in_register _______________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_with_fetch_token_in_register(): 212s async def fetch_token(request): 212s return {'access_token': 'dev', 'token_type': 'bearer'} 212s 212s app = AsyncPathMapDispatch({ 212s '/user': {'body': {'sub': '123'}} 212s }) 212s oauth = OAuth() 212s client = oauth.register( 212s 'dev', 212s client_id='dev', 212s client_secret='dev', 212s api_base_url='https://i.b/api', 212s access_token_url='https://i.b/token', 212s authorize_url='https://i.b/authorize', 212s fetch_token=fetch_token, 212s client_kwargs={ 212s 'app': app, 212s } 212s ) 212s 212s req_scope = {'type': 'http', 'session': {}} 212s req = Request(req_scope) 212s > resp = await client.get('/user', request=req) 212s 212s tests/clients/test_starlette/test_oauth_client.py:211: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:86: in request 212s return await _http_request(self, session, method, url, token, kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:144: in _http_request 212s return await session.request(method, url, **kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s ________________________ test_with_fetch_token_in_oauth ________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_with_fetch_token_in_oauth(): 212s async def fetch_token(name, request): 212s return {'access_token': 'dev', 'token_type': 'bearer'} 212s 212s app = AsyncPathMapDispatch({ 212s '/user': {'body': {'sub': '123'}} 212s }) 212s oauth = OAuth(fetch_token=fetch_token) 212s client = oauth.register( 212s 'dev', 212s client_id='dev', 212s client_secret='dev', 212s api_base_url='https://i.b/api', 212s access_token_url='https://i.b/token', 212s authorize_url='https://i.b/authorize', 212s client_kwargs={ 212s 'app': app, 212s } 212s ) 212s 212s req_scope = {'type': 'http', 'session': {}} 212s req = Request(req_scope) 212s > resp = await client.get('/user', request=req) 212s 212s tests/clients/test_starlette/test_oauth_client.py:238: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:86: in request 212s return await _http_request(self, session, method, url, token, kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:144: in _http_request 212s return await session.request(method, url, **kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s _________________________ test_request_withhold_token __________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_request_withhold_token(): 212s oauth = OAuth() 212s app = AsyncPathMapDispatch({ 212s '/user': {'body': {'sub': '123'}} 212s }) 212s client = oauth.register( 212s "dev", 212s client_id="dev", 212s client_secret="dev", 212s api_base_url="https://i.b/api", 212s access_token_url="https://i.b/token", 212s authorize_url="https://i.b/authorize", 212s client_kwargs={ 212s 'app': app, 212s } 212s ) 212s req_scope = {'type': 'http', 'session': {}} 212s req = Request(req_scope) 212s > resp = await client.get('/user', request=req, withhold_token=True) 212s 212s tests/clients/test_starlette/test_oauth_client.py:261: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:86: in request 212s return await _http_request(self, session, method, url, token, kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:136: in _http_request 212s return await session.request(method, url, **kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s _____________________ test_oauth2_authorize_with_metadata ______________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_oauth2_authorize_with_metadata(): 212s oauth = OAuth() 212s app = AsyncPathMapDispatch({ 212s '/.well-known/openid-configuration': {'body': { 212s 'authorization_endpoint': 'https://i.b/authorize' 212s }} 212s }) 212s client = oauth.register( 212s 'dev', 212s client_id='dev', 212s client_secret='dev', 212s api_base_url='https://i.b/api', 212s access_token_url='https://i.b/token', 212s server_metadata_url='https://i.b/.well-known/openid-configuration', 212s client_kwargs={ 212s 'app': app, 212s } 212s ) 212s req_scope = {'type': 'http', 'session': {}} 212s req = Request(req_scope) 212s > resp = await client.authorize_redirect(req, 'https://b.com/bar') 212s 212s tests/clients/test_starlette/test_oauth_client.py:302: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/starlette_client/apps.py:34: in authorize_redirect 212s rv = await self.create_authorization_url(redirect_uri, **kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:95: in create_authorization_url 212s metadata = await self.load_server_metadata() 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:76: in load_server_metadata 212s resp = await client.request('GET', self._server_metadata_url, withhold_token=True) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s _____________________________ test_fetch_userinfo ______________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_fetch_userinfo(): 212s > await run_fetch_userinfo({'sub': '123'}) 212s 212s tests/clients/test_starlette/test_user_mixin.py:42: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s tests/clients/test_starlette/test_user_mixin.py:36: in run_fetch_userinfo 212s user = await client.userinfo(request=req) 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_openid.py:29: in userinfo 212s resp = await self.get(metadata['userinfo_endpoint'], **kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:86: in request 212s return await _http_request(self, session, method, url, token, kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_app.py:144: in _http_request 212s return await session.request(method, url, **kwargs) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s __________________________ test_force_fetch_jwks_uri ___________________________ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s > yield 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:69: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:373: in handle_async_request 212s resp = await self._pool.handle_async_request(req) 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:216: in handle_async_request 212s raise exc from None 212s /usr/lib/python3/dist-packages/httpcore/_async/connection_pool.py:196: in handle_async_request 212s response = await connection.handle_async_request( 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s self = 212s request = 212s 212s async def handle_async_request(self, request: Request) -> Response: 212s timeouts = request.extensions.get("timeout", {}) 212s timeout = timeouts.get("connect", None) 212s 212s async with self._connect_lock: 212s if not self._connected: 212s target = b"%b:%d" % (self._remote_origin.host, self._remote_origin.port) 212s 212s connect_url = URL( 212s scheme=self._proxy_origin.scheme, 212s host=self._proxy_origin.host, 212s port=self._proxy_origin.port, 212s target=target, 212s ) 212s connect_headers = merge_headers( 212s [(b"Host", target), (b"Accept", b"*/*")], self._proxy_headers 212s ) 212s connect_request = Request( 212s method=b"CONNECT", 212s url=connect_url, 212s headers=connect_headers, 212s extensions=request.extensions, 212s ) 212s connect_response = await self._connection.handle_async_request( 212s connect_request 212s ) 212s 212s if connect_response.status < 200 or connect_response.status > 299: 212s reason_bytes = connect_response.extensions.get("reason_phrase", b"") 212s reason_str = reason_bytes.decode("ascii", errors="ignore") 212s msg = "%d %s" % (connect_response.status, reason_str) 212s await self._connection.aclose() 212s > raise ProxyError(msg) 212s E httpcore.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpcore/_async/http_proxy.py:298: ProxyError 212s 212s The above exception was the direct cause of the following exception: 212s 212s @pytest.mark.asyncio 212s async def test_force_fetch_jwks_uri(): 212s secret_keys = read_key_file('jwks_private.json') 212s token = get_bearer_token() 212s id_token = generate_id_token( 212s token, {'sub': '123'}, secret_keys, 212s alg='RS256', iss='https://i.b', 212s aud='dev', exp=3600, nonce='n', 212s ) 212s token['id_token'] = id_token 212s 212s app = AsyncPathMapDispatch({ 212s '/jwks': {'body': read_key_file('jwks_public.json')} 212s }) 212s 212s oauth = OAuth() 212s client = oauth.register( 212s 'dev', 212s client_id='dev', 212s client_secret='dev', 212s fetch_token=get_bearer_token, 212s jwks_uri='https://i.b/jwks', 212s issuer='https://i.b', 212s client_kwargs={ 212s 'app': app, 212s } 212s ) 212s > user = await client.parse_id_token(token, nonce='n') 212s 212s tests/clients/test_starlette/test_user_mixin.py:129: 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_openid.py:56: in parse_id_token 212s jwk_set = await self.fetch_jwk_set() 212s /usr/lib/python3/dist-packages/authlib/integrations/base_client/async_openid.py:19: in fetch_jwk_set 212s resp = await client.request('GET', uri, withhold_token=True) 212s /usr/lib/python3/dist-packages/authlib/integrations/httpx_client/oauth2_client.py:90: in request 212s return await super().request( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1574: in request 212s return await self.send(request, auth=auth, follow_redirects=follow_redirects) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1661: in send 212s response = await self._send_handling_auth( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1689: in _send_handling_auth 212s response = await self._send_handling_redirects( 212s /usr/lib/python3/dist-packages/httpx/_client.py:1726: in _send_handling_redirects 212s response = await self._send_single_request(request) 212s /usr/lib/python3/dist-packages/httpx/_client.py:1763: in _send_single_request 212s response = await transport.handle_async_request(request) 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:372: in handle_async_request 212s with map_httpcore_exceptions(): 212s /usr/lib/python3.12/contextlib.py:158: in __exit__ 212s self.gen.throw(value) 212s _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 212s 212s @contextlib.contextmanager 212s def map_httpcore_exceptions() -> typing.Iterator[None]: 212s try: 212s yield 212s except Exception as exc: 212s mapped_exc = None 212s 212s for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): 212s if not isinstance(exc, from_exc): 212s continue 212s # We want to map to the most specific exception we can find. 212s # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to 212s # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. 212s if mapped_exc is None or issubclass(to_exc, mapped_exc): 212s mapped_exc = to_exc 212s 212s if mapped_exc is None: # pragma: no cover 212s raise 212s 212s message = str(exc) 212s > raise mapped_exc(message) from exc 212s E httpx.ProxyError: 503 Service Unavailable 212s 212s /usr/lib/python3/dist-packages/httpx/_transports/default.py:86: ProxyError 212s =============================== warnings summary =============================== 212s ../../../usr/lib/python3/dist-packages/httpx/_client.py:1426: 2 warnings 212s tests/clients/test_httpx/test_async_assertion_client.py: 2 warnings 212s tests/clients/test_httpx/test_async_oauth1_client.py: 7 warnings 212s tests/clients/test_httpx/test_async_oauth2_client.py: 19 warnings 212s tests/clients/test_starlette/test_oauth_client.py: 9 warnings 212s tests/clients/test_starlette/test_user_mixin.py: 2 warnings 212s /usr/lib/python3/dist-packages/httpx/_client.py:1426: DeprecationWarning: The 'app' shortcut is now deprecated. Use the explicit style 'transport=ASGITransport(app=...)' instead. 212s warnings.warn(message, DeprecationWarning) 212s 212s tests/clients/test_flask/test_oauth_client.py::FlaskOAuthTest::test_openid_authorize 212s /usr/lib/python3/dist-packages/authlib/jose/jwk.py:14: AuthlibDeprecationWarning: Please use ``JsonWebKey`` directly. 212s deprecate('Please use ``JsonWebKey`` directly.') 212s 212s tests/clients/test_httpx/test_assertion_client.py: 3 warnings 212s tests/clients/test_httpx/test_oauth1_client.py: 7 warnings 212s tests/clients/test_httpx/test_oauth2_client.py: 23 warnings 212s /usr/lib/python3/dist-packages/httpx/_client.py:680: DeprecationWarning: The 'app' shortcut is now deprecated. Use the explicit style 'transport=WSGITransport(app=...)' instead. 212s warnings.warn(message, DeprecationWarning) 212s 212s tests/clients/test_httpx/test_async_oauth2_client.py::test_httpx_client_stream_match[client0] 212s tests/clients/test_httpx/test_async_oauth2_client.py::test_httpx_client_stream_match[client1] 212s /usr/lib/python3/dist-packages/_pytest/python.py:183: PytestUnhandledCoroutineWarning: async def functions are not natively supported and have been skipped. 212s You need to install a suitable plugin for your async framework, for example: 212s - anyio 212s - pytest-asyncio 212s - pytest-tornasync 212s - pytest-trio 212s - pytest-twisted 212s warnings.warn(PytestUnhandledCoroutineWarning(msg.format(nodeid))) 212s 212s -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html 212s =========================== short test summary info ============================ 212s FAILED tests/clients/test_httpx/test_async_assertion_client.py::test_refresh_token 212s FAILED tests/clients/test_httpx/test_async_oauth1_client.py::test_fetch_request_token_via_header 212s FAILED tests/clients/test_httpx/test_async_oauth1_client.py::test_fetch_request_token_via_body 212s FAILED tests/clients/test_httpx/test_async_oauth1_client.py::test_fetch_request_token_via_query 212s FAILED tests/clients/test_httpx/test_async_oauth1_client.py::test_fetch_access_token 212s FAILED tests/clients/test_httpx/test_async_oauth1_client.py::test_get_via_header 212s FAILED tests/clients/test_httpx/test_async_oauth1_client.py::test_get_via_body 212s FAILED tests/clients/test_httpx/test_async_oauth1_client.py::test_get_via_query 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_add_token_get_request[assert_token_in_header-header] 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_add_token_get_request[assert_token_in_body-body] 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_add_token_get_request[assert_token_in_uri-uri] 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_add_token_to_streaming_request[assert_token_in_header-header] 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_add_token_to_streaming_request[assert_token_in_body-body] 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_add_token_to_streaming_request[assert_token_in_uri-uri] 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_fetch_token_post 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_fetch_token_get 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_token_auth_method_client_secret_post 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_access_token_response_hook 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_password_grant_type 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_client_credentials_type 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_cleans_previous_token_before_fetching_new_one 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_auto_refresh_token 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_auto_refresh_token2 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_auto_refresh_token3 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_auto_refresh_token4 212s FAILED tests/clients/test_httpx/test_async_oauth2_client.py::test_revoke_token 212s FAILED tests/clients/test_starlette/test_oauth_client.py::test_oauth1_authorize 212s FAILED tests/clients/test_starlette/test_oauth_client.py::test_oauth2_authorize 212s FAILED tests/clients/test_starlette/test_oauth_client.py::test_oauth2_authorize_code_challenge 212s FAILED tests/clients/test_starlette/test_oauth_client.py::test_with_fetch_token_in_register 212s FAILED tests/clients/test_starlette/test_oauth_client.py::test_with_fetch_token_in_oauth 212s FAILED tests/clients/test_starlette/test_oauth_client.py::test_request_withhold_token 212s FAILED tests/clients/test_starlette/test_oauth_client.py::test_oauth2_authorize_with_metadata 212s FAILED tests/clients/test_starlette/test_user_mixin.py::test_fetch_userinfo 212s FAILED tests/clients/test_starlette/test_user_mixin.py::test_force_fetch_jwks_uri 212s =========== 35 failed, 130 passed, 2 skipped, 77 warnings in 25.41s ============ 215s autopkgtest [16:11:51]: test unittests3: -----------------------] 216s autopkgtest [16:11:52]: test unittests3: - - - - - - - - - - results - - - - - - - - - - 216s unittests3 FAIL non-zero exit status 1 216s autopkgtest [16:11:52]: @@@@@@@@@@@@@@@@@@@@ summary 216s unittests3 FAIL non-zero exit status 1 235s nova [W] Skipping flock in bos03-arm64 235s Creating nova instance adt-oracular-arm64-python-authlib-20240726-160816-juju-7f2275-prod-proposed-migration-environment-3-724b2caf-e19b-4c54-b83b-5650efeb2c5d from image adt/ubuntu-oracular-arm64-server-20240726.img (UUID 33caccb7-bc3b-4ecc-9e17-59d67995dc9e)...