Skip to content

Commit

Permalink
fix: 修复 is_secure_repository 在 timeout 时会吞调异常的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
shabbywu committed Jan 26, 2024
1 parent df9550a commit 4f2bb06
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion moby_distribution/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion moby_distribution/spec/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "Apache-2.0"
Expand Down
8 changes: 5 additions & 3 deletions tests/spec/test_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import datetime
import pathlib
import random
import socket
import ssl
import threading
from http.server import HTTPServer, SimpleHTTPRequestHandler
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 4f2bb06

Please sign in to comment.