diff --git a/src/fts3rest/fts3rest/controllers/autocomplete.py b/src/fts3rest/fts3rest/controllers/autocomplete.py index e80720e412c86631295401fcca70724c2dccdb50..51c9c901bcba898028831fa497aeb922474534f4 100644 --- a/src/fts3rest/fts3rest/controllers/autocomplete.py +++ b/src/fts3rest/fts3rest/controllers/autocomplete.py @@ -102,7 +102,7 @@ def autocomplete_vo(): """ Autocomplete VO """ - term = request.params.get("term", "srm://") + term = request.values.get("term", "srm://") matches = ( Session.query(Job.vo_name).filter(Job.vo_name.startswith(term)).distinct().all() ) diff --git a/src/fts3rest/fts3rest/tests/functional/test_autocomplete.py b/src/fts3rest/fts3rest/tests/functional/test_autocomplete.py new file mode 100644 index 0000000000000000000000000000000000000000..35944ee68fe14b9fc0c9fa37a23df28ab4bf7731 --- /dev/null +++ b/src/fts3rest/fts3rest/tests/functional/test_autocomplete.py @@ -0,0 +1,66 @@ +from fts3rest.tests import TestController + + +class TestAutocomplete(TestController): + """ + Tests for autocompleting + """ + + def setUp(self): + super().setUp() + self.setup_gridsite_environment() + + def test_autocomplete_dn(self): + """ + Test autocomplete dn + """ + autocomp = self.app.get( + url="/autocomplete/dn", + params={"user_dn": "/DC=cern", "message": "term"}, + status=200, + ).json + self.assertEqual(0, len(autocomp)) + + def test_autocomplete_source(self): + """ + Test autocomplete source + """ + autocomp = self.app.get( + url="/autocomplete/source", + params={"source": "srm://", "message": "term"}, + status=200, + ).json + self.assertEqual(0, len(autocomp)) + + def test_autocomplete_destination(self): + """ + Test autocomplete destination + """ + autocomp = self.app.get( + url="/autocomplete/destination", + params={"destination": "srm://", "message": "term"}, + status=200, + ).json + self.assertEqual(0, len(autocomp)) + + def test_autocomplete_storage(self): + """ + Test autocomplete storage + """ + autocomp = self.app.get( + url="/autocomplete/storage", + params={"storage": "srm://", "message": "term"}, + status=200, + ).json + self.assertEqual(0, len(autocomp)) + + def test_autocomplete_vo(self): + """ + Test autocomplete vo + """ + autocomp = self.app.get( + url="/autocomplete/vo", + params={"vo": "srm://", "message": "term"}, + status=200, + ).json + self.assertEqual(0, len(autocomp))