Skip to content

Commit

Permalink
add initial tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Jan 16, 2024
1 parent 7494b2c commit c92f26a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
5 changes: 0 additions & 5 deletions plugins/quetz_googleiap/quetz_googleiap/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ async def dispatch(self, request, call_next):
response = await call_next(request)
return response

# Check if the session has a specific key, for example 'count'.
# If it does, increment its value. If it doesn't, set it to 1.
count = request.session.get("count", 0)
request.session["count"] = count + 1

user_id = request.headers.get("x-goog-authenticated-user-id")
email = request.headers.get("x-goog-authenticated-user-email")

Expand Down
14 changes: 14 additions & 0 deletions plugins/quetz_googleiap/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest

pytest_plugins = "quetz.testing.fixtures"


@pytest.fixture
def plugins():
# defines plugins to enable for testing
return ['quetz-googleiap']

@pytest.fixture
def sqlite_in_memory():
# use sqlite on disk so that we can modify it in a different process
return False
23 changes: 23 additions & 0 deletions plugins/quetz_googleiap/tests/test_googleiap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pytest


@pytest.mark.parametrize(
"config_extra", ['[googleiam]\nserver_admin_emails=["[email protected]"]']
)
def test_authentication(client, db):
response = client.get("/api/me")
assert response.status_code == 401

# add headers
headers = {
'X-Goog-Authenticated-User-Email': 'accounts.google.com:[email protected]',
'X-Goog-Authenticated-User-Id': 'accounts.google.com:[email protected]',
}

response = client.get("/api/me", headers=headers)
assert response.status_code == 200

# # check if channel was created
# response = client.get("/api/channels", headers=headers)
# assert response.status_code == 200
# assert response.json()['channels'][0]['name'] == 'someone'

0 comments on commit c92f26a

Please sign in to comment.