tests/oci-registry-client.py: Parse URL parameter

This commit is contained in:
Owen W. Taylor 2024-12-17 15:41:53 +01:00 committed by Georges Basile Stavracas Neto
parent 82706e6d28
commit 34acb5799e
2 changed files with 8 additions and 3 deletions

View File

@ -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)

View File

@ -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