From 34acb5799e509cb30b82802d7938ba3f5362f89e Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Tue, 17 Dec 2024 15:41:53 +0100 Subject: [PATCH] tests/oci-registry-client.py: Parse URL parameter --- tests/oci-registry-client.py | 9 +++++++-- tests/test-oci-registry.sh | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/oci-registry-client.py b/tests/oci-registry-client.py index b9ca63d7..cd835609 100644 --- a/tests/oci-registry-client.py +++ b/tests/oci-registry-client.py @@ -6,6 +6,11 @@ import http.client import urllib.parse +def get_conn(url): + parsed = urllib.parse.urlparse(url) + return http.client.HTTPConnection(host=parsed.hostname, port=parsed.port) + + if sys.argv[2] == 'add': detach_icons = '--detach-icons' in sys.argv if detach_icons: @@ -14,7 +19,7 @@ if sys.argv[2] == 'add': if detach_icons: params['detach-icons'] = 1 query = urllib.parse.urlencode(params) - conn = http.client.HTTPConnection(sys.argv[1]) + conn = get_conn(sys.argv[1]) path = "/testing/{repo}/{tag}?{query}".format(repo=sys.argv[3], tag=sys.argv[4], query=query) @@ -25,7 +30,7 @@ if sys.argv[2] == 'add': print("Failed: status={}".format(response.status), file=sys.stderr) sys.exit(1) elif sys.argv[2] == 'delete': - conn = http.client.HTTPConnection(sys.argv[1]) + conn = get_conn(sys.argv[1]) path = "/testing/{repo}/{ref}".format(repo=sys.argv[3], ref=sys.argv[4]) conn.request("DELETE", path) diff --git a/tests/test-oci-registry.sh b/tests/test-oci-registry.sh index 8eb154f5..51a6142f 100755 --- a/tests/test-oci-registry.sh +++ b/tests/test-oci-registry.sh @@ -29,7 +29,7 @@ echo "1..14" httpd oci-registry-server.py . port=$(cat httpd-port) -client="python3 $test_srcdir/oci-registry-client.py 127.0.0.1:$port" +client="python3 $test_srcdir/oci-registry-client.py http://127.0.0.1:$port" setup_repo_no_add oci