From 4f2bb0653c133b44deb4e541d75bbb6682a0c703 Mon Sep 17 00:00:00 2001 From: shabbywu Date: Fri, 26 Jan 2024 16:28:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20is=5Fsecure=5Frepos?= =?UTF-8?q?itory=20=E5=9C=A8=20timeout=20=E6=97=B6=E4=BC=9A=E5=90=9E?= =?UTF-8?q?=E8=B0=83=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- moby_distribution/__init__.py | 2 +- moby_distribution/spec/endpoint.py | 2 +- pyproject.toml | 2 +- tests/spec/test_endpoint.py | 8 +++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/moby_distribution/__init__.py b/moby_distribution/__init__.py index 4aa9b7c..64fd988 100644 --- a/moby_distribution/__init__.py +++ b/moby_distribution/__init__.py @@ -7,7 +7,7 @@ from moby_distribution.spec.image_json import ImageJSON from moby_distribution.spec.manifest import ManifestSchema1, ManifestSchema2, OCIManifestSchema1 -__version__ = "0.5.7" +__version__ = "0.5.8" __ALL__ = [ "DockerRegistryV2Client", "Blob", diff --git a/moby_distribution/spec/endpoint.py b/moby_distribution/spec/endpoint.py index 210f4ea..5976d79 100644 --- a/moby_distribution/spec/endpoint.py +++ b/moby_distribution/spec/endpoint.py @@ -41,7 +41,7 @@ def is_secure_repository(self) -> Tuple[bool, bool]: return False, False return False, False except socket.timeout: - return False, False + raise except OSError: return False, False return True, True diff --git a/pyproject.toml b/pyproject.toml index ebcf346..17f85cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "moby-distribution" -version = "0.5.7" +version = "0.5.8" description = "Yet another moby(docker) distribution implement by python." authors = ["shabbywu "] license = "Apache-2.0" diff --git a/tests/spec/test_endpoint.py b/tests/spec/test_endpoint.py index e82ed40..db125af 100644 --- a/tests/spec/test_endpoint.py +++ b/tests/spec/test_endpoint.py @@ -2,6 +2,7 @@ import datetime import pathlib import random +import socket import ssl import threading from http.server import HTTPServer, SimpleHTTPRequestHandler @@ -130,9 +131,10 @@ def test_is_secure_repository(server, expected): def test_is_secure_repository_timeout(blocking_https_server): - assert APIEndpoint( - url=f"{blocking_https_server[0]}:{blocking_https_server[1]}", default_timeout=10 - ).is_secure_repository() == (False, False) + with pytest.raises(socket.timeout): + assert APIEndpoint( + url=f"{blocking_https_server[0]}:{blocking_https_server[1]}", default_timeout=10 + ).is_secure_repository() @pytest.mark.parametrize(