Skip to content

Commit

Permalink
Test toggle for BENCHMARKS_DATA_PUBLIC
Browse files Browse the repository at this point in the history
  • Loading branch information
dianaclarke committed Aug 16, 2021
1 parent 5ae898c commit ec1ed40
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions conbench/tests/api/_asserts.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ def test_unauthenticated(self, client):


class ListEnforcer(Enforcer):
def test_unauthenticated(self, client):
def test_unauthenticated(self, client, monkeypatch):
if getattr(self, "public", False):
monkeypatch.setenv("BENCHMARKS_DATA_PUBLIC", "off")
response = client.get(self.url)
self.assert_401_unauthorized(response)

monkeypatch.setenv("BENCHMARKS_DATA_PUBLIC", "on")
response = client.get(self.url)
self.assert_200_ok(response)
else:
Expand All @@ -87,12 +92,17 @@ def test_unauthenticated(self, client):


class GetEnforcer(Enforcer):
def test_unauthenticated(self, client):
def test_unauthenticated(self, client, monkeypatch):
if getattr(self, "public", False):
entity = self._create()
response = client.get(self.url.format(entity.id))
# TODO: compare _expected_entity too
# self.assert_200_ok(response, _expected_entity(entity))
entity_url = self.url.format(entity.id)

monkeypatch.setenv("BENCHMARKS_DATA_PUBLIC", "off")
response = client.get(entity_url)
self.assert_401_unauthorized(response)

monkeypatch.setenv("BENCHMARKS_DATA_PUBLIC", "on")
response = client.get(entity_url)
self.assert_200_ok(response)
else:
response = client.get(self.url.format("id"))
Expand Down

0 comments on commit ec1ed40

Please sign in to comment.