Skip to content

Commit

Permalink
/datasets correctly return an error when no 'nodes' parameter. (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulineribeyre authored Jul 27, 2023
1 parent 2f751a8 commit 1bf2dc4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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"

0 comments on commit 1bf2dc4

Please sign in to comment.