Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trailing slash to the graphql URLs #3389

Merged
merged 7 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
16 changes: 8 additions & 8 deletions pontoon/api/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_projects(client):
}"""
}

response = client.get("/graphql", body, HTTP_ACCEPT="application/json")
response = client.get("/graphql/", body, HTTP_ACCEPT="application/json")

ProjectFactory.create(visibility=Project.Visibility.PRIVATE)
assert response.status_code == 200
Expand Down Expand Up @@ -111,7 +111,7 @@ def test_project_filters(
}
if is_admin:
client.force_login(admin)
response = client.get("/graphql", body, HTTP_ACCEPT="application/json")
response = client.get("/graphql/", body, HTTP_ACCEPT="application/json")

assert response.status_code == 200
assert response.json() == {
Expand Down Expand Up @@ -143,7 +143,7 @@ def test_project_localizations(client):
}"""
}

response = client.get("/graphql", body, HTTP_ACCEPT="application/json")
response = client.get("/graphql/", body, HTTP_ACCEPT="application/json")

assert response.status_code == 200
assert response.json() == {
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_localization_filters(
if is_admin:
client.force_login(admin)

response = client.get("/graphql", body, HTTP_ACCEPT="application/json")
response = client.get("/graphql/", body, HTTP_ACCEPT="application/json")

assert response.status_code == 200
assert response.json() == {
Expand Down Expand Up @@ -246,7 +246,7 @@ def test_projects_localizations_cyclic(client):
}"""
}

response = client.get("/graphql", body, HTTP_ACCEPT="application/json")
response = client.get("/graphql/", body, HTTP_ACCEPT="application/json")

assert response.status_code == 200
assert b"Cyclic queries are forbidden" in response.content
Expand All @@ -268,7 +268,7 @@ def test_project_localizations_cyclic(client):
}"""
}

response = client.get("/graphql", body, HTTP_ACCEPT="application/json")
response = client.get("/graphql/", body, HTTP_ACCEPT="application/json")

assert response.status_code == 200
assert b"Cyclic queries are forbidden" in response.content
Expand All @@ -290,7 +290,7 @@ def test_locales_localizations_cyclic(client):
}"""
}

response = client.get("/graphql", body, HTTP_ACCEPT="application/json")
response = client.get("/graphql/", body, HTTP_ACCEPT="application/json")

assert response.status_code == 200
assert b"Cyclic queries are forbidden" in response.content
Expand All @@ -312,7 +312,7 @@ def test_locale_localizations_cyclic(client):
}"""
}

response = client.get("/graphql", body, HTTP_ACCEPT="application/json")
response = client.get("/graphql/", body, HTTP_ACCEPT="application/json")

assert response.status_code == 200
assert b"Cyclic queries are forbidden" in response.content
16 changes: 8 additions & 8 deletions pontoon/api/tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ def projects_query():
def test_graphql_dev_get(settings, projects_query, client):
settings.DEV = True

response = client.get("/graphql", projects_query, HTTP_ACCEPT="application/json")
response = client.get("/graphql/", projects_query, HTTP_ACCEPT="application/json")
assert response.status_code == 200


@pytest.mark.django_db
def test_graphql_dev_post(settings, projects_query, client):
settings.DEV = True

response = client.post("/graphql", projects_query, HTTP_ACCEPT="application/json")
response = client.post("/graphql/", projects_query, HTTP_ACCEPT="application/json")
assert response.status_code == 200


Expand All @@ -38,7 +38,7 @@ def test_graphql_dev_post(settings, projects_query, client):
def test_graphql_prod_get(settings, projects_query, client):
settings.DEV = True

response = client.get("/graphql", projects_query, HTTP_ACCEPT="application/json")
response = client.get("/graphql/", projects_query, HTTP_ACCEPT="application/json")
assert response.status_code == 200


Expand All @@ -47,22 +47,22 @@ def test_graphql_prod_get(settings, projects_query, client):
def test_graphql_prod_post(settings, projects_query, client):
settings.DEV = False

response = client.post("/graphql", projects_query, HTTP_ACCEPT="appication/json")
response = client.post("/graphql/", projects_query, HTTP_ACCEPT="appication/json")
mathjazz marked this conversation as resolved.
Show resolved Hide resolved
assert response.status_code == 200


@pytest.mark.django_db
def test_graphiql_dev_get(settings, projects_query, client):
settings.DEV = True

response = client.get("/graphql", projects_query, HTTP_ACCEPT="text/html")
response = client.get("/graphql/", projects_query, HTTP_ACCEPT="text/html")
assert response.status_code == 200


@pytest.mark.django_db
def test_graphiql_dev_post(settings, projects_query, client):
settings.DEV = True
response = client.post("/graphql", projects_query, HTTP_ACCEPT="text/html")
response = client.post("/graphql/", projects_query, HTTP_ACCEPT="text/html")
assert response.status_code == 200


Expand All @@ -71,7 +71,7 @@ def test_graphiql_dev_post(settings, projects_query, client):
def test_graphiql_prod_get(settings, projects_query, client):
settings.DEV = False
reload_urls(settings)
response = client.get("/graphql", projects_query, HTTP_ACCEPT="text/html")
response = client.get("/graphql/", projects_query, HTTP_ACCEPT="text/html")
assert response.status_code == 400


Expand All @@ -80,5 +80,5 @@ def test_graphiql_prod_get(settings, projects_query, client):
def test_graphiql_prod_post(projects_query, client, settings):
settings.DEV = False
reload_urls(settings)
response = client.post("/graphql", projects_query, HTTP_ACCEPT="text/html")
response = client.post("/graphql/", projects_query, HTTP_ACCEPT="text/html")
assert response.status_code == 400
2 changes: 1 addition & 1 deletion pontoon/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
urlpatterns = [
# GraphQL endpoint. In DEV mode it serves the GraphiQL IDE if accessed with Accept: text/html
path(
"graphql",
"graphql/",
GraphQLView.as_view(schema=schema, graphiql=DEV),
),
]