Skip to content

Commit

Permalink
Don't test peercreds lookup under macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
webknjaz committed Dec 31, 2018
1 parent 48aeb04 commit 2232d5d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cheroot/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,8 @@ def get_peer_creds(self): # LRU cached on per-instance basis, see __init__

try:
peer_creds = self.socket.getsockopt(
# FIXME: Use LOCAL_CREDS for BSD-like OSs
# Ref: https://gist.github.com/LucaFilipozzi/e4f1e118202aff27af6aadebda1b5d91 # noqa
socket.SOL_SOCKET, socket.SO_PEERCRED,
struct.calcsize(PEERCRED_STRUCT_DEF)
)
Expand Down
9 changes: 9 additions & 0 deletions cheroot/test/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import requests_unixsocket

from .._compat import bton, ntob
from .._compat import IS_MACOS
from ..server import IS_UID_GID_RESOLVABLE, Gateway, HTTPServer
from ..testing import (
ANY_INTERFACE_IPV4,
Expand All @@ -30,6 +31,12 @@
)


non_macos_sock_test = pytest.mark.skipif(
IS_MACOS,
reason='Peercreds lookup does not work under macOS/BSD currently.',
)


@pytest.fixture
def unix_sock_file():
"""Check that bound UNIX socket address is stored in server."""
Expand Down Expand Up @@ -152,6 +159,7 @@ def peercreds_enabled_server_and_client(http_server, unix_sock_file):


@non_windows_sock_test
@non_macos_sock_test
def test_peercreds_unix_sock(peercreds_enabled_server_and_client):
"""Check that peercred lookup works when enabled."""
httpserver, testclient = peercreds_enabled_server_and_client
Expand All @@ -178,6 +186,7 @@ def test_peercreds_unix_sock(peercreds_enabled_server_and_client):
'under the current platform',
)
@non_windows_sock_test
@non_macos_sock_test
def test_peercreds_unix_sock_with_lookup(peercreds_enabled_server_and_client):
"""Check that peercred resolution works when enabled."""
httpserver, testclient = peercreds_enabled_server_and_client
Expand Down

0 comments on commit 2232d5d

Please sign in to comment.