Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions tests/test_remote_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,22 @@

import pytest

import pyisolate
import pyisolate.policy as policy


@pytest.fixture
def policy_token():
# refresh_remote ends in Supervisor.reload_policy, which authorizes against
# the global supervisor's policy token. Set it here (and restore afterwards)
# so this file does not depend on an earlier test file having set it.
sup = pyisolate.supervisor._get_supervisor()
old = sup._policy_token
pyisolate.set_policy_token("tok")
yield "tok"
sup._policy_token = old


class PolicyHandler(BaseHTTPRequestHandler):
def do_GET(self):
doc = "version: 0.1\n"
Expand All @@ -25,7 +38,7 @@ def log_message(self, format, *args): # pragma: no cover - quiet test output
return


def test_refresh_remote(tmp_path):
def test_refresh_remote(tmp_path, policy_token):
addr = ("127.0.0.1", 0)
httpd = HTTPServer(addr, PolicyHandler)
port = httpd.server_address[1]
Expand Down Expand Up @@ -66,7 +79,7 @@ def log_message(self, format, *args): # pragma: no cover - quiet test output
return


def test_refresh_remote_retries_on_timeout(tmp_path):
def test_refresh_remote_retries_on_timeout(tmp_path, policy_token):
addr = ("127.0.0.1", 0)
httpd = ThreadingHTTPServer(addr, SlowFirstHandler)
port = httpd.server_address[1]
Expand Down
Loading