From ecea4bb0573a30f50a415fb6dee77eeb2967ecb3 Mon Sep 17 00:00:00 2001 From: Adam Williamson Date: May 18 2024 01:49:06 +0000 Subject: Update URL for image download test Signed-off-by: Adam Williamson --- diff --git a/tests/fixtures/cassettes/test_download_image.yaml b/tests/fixtures/cassettes/test_download_image.yaml index ec7885b..8c8a723 100644 --- a/tests/fixtures/cassettes/test_download_image.yaml +++ b/tests/fixtures/cassettes/test_download_image.yaml @@ -11,23 +11,46 @@ interactions: User-Agent: - python-requests/2.31.0 method: GET - uri: http://localhost:5001/test.img.xz + uri: https://pagure.io/cloud-image-uploader/blob/main/f/tests/fixtures/http/test.img.xz response: body: string: !!binary | /Td6WFoAAATm1rRGAgAhARYAAAB0L+WjAQAadGhpcyBpc24ndCByZWFsbHkgYW4gaW1hZ2UKAAAa UXdAW5qqSgABMxv3GYheH7bzfQEAAAAABFla headers: + Connection: + - Upgrade, Keep-Alive Content-Length: - '84' - Content-type: - - application/x-xz + Content-Security-Policy: + - default-src 'self';script-src 'self' 'nonce-DMilabatMzxQdMogZXtdNW08s'; style-src + 'self' 'nonce-DMilabatMzxQdMogZXtdNW08s'; object-src 'none';base-uri 'self';img-src + 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src https://docs.pagure.org;frame-ancestors + https://pagure.io; + Content-Type: + - application/octet-stream; charset=xz Date: - - Thu, 16 May 2024 19:37:30 GMT - Last-Modified: - - Wed, 15 May 2024 23:31:34 GMT + - Sat, 18 May 2024 01:48:57 GMT + Keep-Alive: + - timeout=5, max=100 + Referrer-Policy: + - same-origin Server: - - SimpleHTTP/0.6 Python/3.12.3 + - Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 Python/3.6 + Set-Cookie: + - pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZGJkNzdiYmI5OWRhOGNmNWZjODBmMTcwOTljNWY1MzM4YWI0MTUxZCJ9.GSmaiQ.9eEHxektWtA-QHw_x-PbUfkuQCs; + Expires=Tue, 18-Jun-2024 01:48:57 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Upgrade: + - h2,h2c + X-Content-Type-Options: + - nosniff + - nosniff + X-Frame-Options: + - ALLOW-FROM https://pagure.io/ + X-Xss-Protection: + - 1; mode=block status: code: 200 message: OK @@ -40,26 +63,49 @@ interactions: - gzip, deflate, br Connection: - keep-alive + Cookie: + - pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZGJkNzdiYmI5OWRhOGNmNWZjODBmMTcwOTljNWY1MzM4YWI0MTUxZCJ9.GSmaiQ.9eEHxektWtA-QHw_x-PbUfkuQCs User-Agent: - python-requests/2.31.0 method: GET - uri: http://localhost:5001/test.img.xz + uri: https://pagure.io/cloud-image-uploader/blob/main/f/tests/fixtures/http/test.img.xz response: body: string: !!binary | /Td6WFoAAATm1rRGAgAhARYAAAB0L+WjAQAadGhpcyBpc24ndCByZWFsbHkgYW4gaW1hZ2UKAAAa UXdAW5qqSgABMxv3GYheH7bzfQEAAAAABFla headers: + Connection: + - Keep-Alive Content-Length: - '84' - Content-type: - - application/x-xz + Content-Security-Policy: + - default-src 'self';script-src 'self' 'nonce-nFIhf9WqFZ3l9OZk5ZiARlMZf'; style-src + 'self' 'nonce-nFIhf9WqFZ3l9OZk5ZiARlMZf'; object-src 'none';base-uri 'self';img-src + 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src https://docs.pagure.org;frame-ancestors + https://pagure.io; + Content-Type: + - application/octet-stream; charset=xz Date: - - Thu, 16 May 2024 19:37:30 GMT - Last-Modified: - - Wed, 15 May 2024 23:31:34 GMT + - Sat, 18 May 2024 01:48:57 GMT + Keep-Alive: + - timeout=5, max=99 + Referrer-Policy: + - same-origin Server: - - SimpleHTTP/0.6 Python/3.12.3 + - Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 Python/3.6 + Set-Cookie: + - pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZGJkNzdiYmI5OWRhOGNmNWZjODBmMTcwOTljNWY1MzM4YWI0MTUxZCJ9.GSmaiQ.9eEHxektWtA-QHw_x-PbUfkuQCs; + Expires=Tue, 18-Jun-2024 01:48:57 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + X-Content-Type-Options: + - nosniff + - nosniff + X-Frame-Options: + - ALLOW-FROM https://pagure.io/ + X-Xss-Protection: + - 1; mode=block status: code: 200 message: OK @@ -72,31 +118,89 @@ interactions: - gzip, deflate, br Connection: - keep-alive + Cookie: + - pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZGJkNzdiYmI5OWRhOGNmNWZjODBmMTcwOTljNWY1MzM4YWI0MTUxZCJ9.GSmaiQ.9eEHxektWtA-QHw_x-PbUfkuQCs User-Agent: - python-requests/2.31.0 method: GET - uri: http://localhost:5001/notfound + uri: https://pagure.io/notthere/notfound response: body: - string: "\n\n \n \n - \ Error response\n \n \n

Error - response

\n

Error code: 404

\n

Message: File not - found.

\n

Error code explanation: 404 - Nothing matches the given - URI.

\n \n\n" + string: "\n\n\n\n \n Page not found :'( - Pagure.io\n + \ \n + \ \n \n \n \n\n \n + \ \n \n \n + \ \n \n \n \n\n
\n\n\n
\n
\n
\n

Page + not found (404)

\n

With the message:

\n
\n + \

Project not found

\n
\n

You have either entered + a bad URL or the page has moved, removed, or otherwise rendered unavailable.
\n + \ Please use the main navigation menu to get (re)started.

\n
\n + \
\n
\n
\n\n
\n + \
\n
\n + \
\n
Powered by Pagure 5.13.3
\n \n
\n + \
\n
© + Red Hat, Inc. and others.
\n
\n
\n + \
\n
\n\n\n \n\n \n\n + \ \n\n\n" headers: Connection: - - close + - Keep-Alive Content-Length: - - '335' + - '3488' + Content-Security-Policy: + - default-src 'self';script-src 'self' 'nonce-UJHYDiN4TzFjkkr231WHLOH4G'; style-src + 'self' 'nonce-UJHYDiN4TzFjkkr231WHLOH4G'; object-src 'none';base-uri 'self';img-src + 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src https://docs.pagure.org;frame-ancestors + https://pagure.io; Content-Type: - - text/html;charset=utf-8 + - text/html; charset=utf-8 Date: - - Thu, 16 May 2024 19:37:30 GMT + - Sat, 18 May 2024 01:48:57 GMT + Keep-Alive: + - timeout=5, max=98 + Referrer-Policy: + - same-origin Server: - - SimpleHTTP/0.6 Python/3.12.3 + - Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 Python/3.6 + Set-Cookie: + - pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZGJkNzdiYmI5OWRhOGNmNWZjODBmMTcwOTljNWY1MzM4YWI0MTUxZCJ9.GSmaiQ.9eEHxektWtA-QHw_x-PbUfkuQCs; + Expires=Tue, 18-Jun-2024 01:48:57 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - ALLOW-FROM https://pagure.io/ + X-Xss-Protection: + - 1; mode=block status: code: 404 - message: File not found + message: NOT FOUND - request: body: null headers: @@ -106,26 +210,51 @@ interactions: - gzip, deflate, br Connection: - keep-alive + Cookie: + - pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZGJkNzdiYmI5OWRhOGNmNWZjODBmMTcwOTljNWY1MzM4YWI0MTUxZCJ9.GSmaiQ.9eEHxektWtA-QHw_x-PbUfkuQCs User-Agent: - python-requests/2.31.0 method: GET - uri: http://localhost:5001/test.img.xz + uri: https://pagure.io/cloud-image-uploader/blob/main/f/tests/fixtures/http/test.img.xz response: body: string: !!binary | /Td6WFoAAATm1rRGAgAhARYAAAB0L+WjAQAadGhpcyBpc24ndCByZWFsbHkgYW4gaW1hZ2UKAAAa UXdAW5qqSgABMxv3GYheH7bzfQEAAAAABFla headers: + Connection: + - Upgrade, Keep-Alive Content-Length: - '84' - Content-type: - - application/x-xz + Content-Security-Policy: + - default-src 'self';script-src 'self' 'nonce-HhRYgnlDIgui8Q4euiXLwUZWG'; style-src + 'self' 'nonce-HhRYgnlDIgui8Q4euiXLwUZWG'; object-src 'none';base-uri 'self';img-src + 'self' https:;connect-src 'self' https://pagure.io:8088;frame-src https://docs.pagure.org;frame-ancestors + https://pagure.io; + Content-Type: + - application/octet-stream; charset=xz Date: - - Thu, 16 May 2024 19:37:30 GMT - Last-Modified: - - Wed, 15 May 2024 23:31:34 GMT + - Sat, 18 May 2024 01:48:57 GMT + Keep-Alive: + - timeout=5, max=100 + Referrer-Policy: + - same-origin Server: - - SimpleHTTP/0.6 Python/3.12.3 + - Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_wsgi/4.6.4 Python/3.6 + Set-Cookie: + - pagure=eyJfcGVybWFuZW50Ijp0cnVlLCJjc3JmX3Rva2VuIjoiZGJkNzdiYmI5OWRhOGNmNWZjODBmMTcwOTljNWY1MzM4YWI0MTUxZCJ9.GSmaiQ.9eEHxektWtA-QHw_x-PbUfkuQCs; + Expires=Tue, 18-Jun-2024 01:48:57 GMT; Secure; HttpOnly; Path=/ + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload + Upgrade: + - h2,h2c + X-Content-Type-Options: + - nosniff + - nosniff + X-Frame-Options: + - ALLOW-FROM https://pagure.io/ + X-Xss-Protection: + - 1; mode=block status: code: 200 message: OK diff --git a/tests/test_handler.py b/tests/test_handler.py index 9a47e80..9c76547 100644 --- a/tests/test_handler.py +++ b/tests/test_handler.py @@ -200,7 +200,7 @@ def test_consumer_handle_exceptions(mock_getrel, mock_relinfo, mock_sleep, fixtu def test_download_image(): """Test download_image functionality.""" image = { - "url": "http://localhost:5001/test.img.xz", + "url": "https://pagure.io/cloud-image-uploader/blob/main/f/tests/fixtures/http/test.img.xz", "path": "/path/to/test.img.xz", "checksums": { "sha256": "eba53879a0b19322b900691641e33ed4e6cb34095c8bc722f6b8d5b65a22d1d3", @@ -220,7 +220,7 @@ def test_download_image(): ret = consumer.download_image(image, tempdir, decompress=True) # and on bad URL origurl = image["url"] - image["url"] = "http://localhost:5001/notfound" + image["url"] = "https://pagure.io/notthere/notfound" with pytest.raises(exceptions.Nack): ret = consumer.download_image(image, tempdir, decompress=True) # and on bad checksum