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

/datasets correctly return an error when no 'nodes' parameter. #202

Merged
merged 2 commits into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion peregrine/blueprints/datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def get_datasets():
anonymous users
"""
nodes = flask.request.args.get("nodes", "")
nodes = nodes.split(",")
if not nodes:
raise UserError("Need to provide target nodes in query param")
nodes = nodes.split(",")
if os.environ.get("PUBLIC_DATASETS", "false").lower() == "true":
set_read_access_projects_for_public_endpoint()
else:
Expand Down
9 changes: 9 additions & 0 deletions tests/graphql/test_datasets.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,12 @@ def test_get_projects_anonymous(
{"dbgap_accession_number": "phsid", "code": "OTHER", "name": "name"},
]
}


def test_no_nodes_parameter(client, submitter):
"""
The endpoint should require the `nodes` query parameter
"""
r = client.get("/datasets", headers=submitter)
assert r.status_code == 400, r.text
assert r.json["message"] == "Need to provide target nodes in query param"
Loading