summaryrefslogtreecommitdiff
path: root/test/apiv2
diff options
context:
space:
mode:
Diffstat (limited to 'test/apiv2')
-rw-r--r--test/apiv2/rest_api/test_rest_v2_0_0.py45
1 files changed, 39 insertions, 6 deletions
diff --git a/test/apiv2/rest_api/test_rest_v2_0_0.py b/test/apiv2/rest_api/test_rest_v2_0_0.py
index cc66dd5af..77674e81b 100644
--- a/test/apiv2/rest_api/test_rest_v2_0_0.py
+++ b/test/apiv2/rest_api/test_rest_v2_0_0.py
@@ -356,17 +356,50 @@ class TestApi(unittest.TestCase):
self.assertTrue(keys["stream"], "Expected to find stream progress stanza's")
def test_search_compat(self):
+ url = PODMAN_URL + "/v1.40/images/search"
# Had issues with this test hanging when repositories not happy
- def do_search():
- r = requests.get(PODMAN_URL + "/v1.40/images/search?term=alpine", timeout=5)
+ def do_search1():
+ payload = {'term': 'alpine'}
+ r = requests.get(url, params=payload, timeout=5)
self.assertEqual(r.status_code, 200, r.text)
objs = json.loads(r.text)
self.assertIn(type(objs), (list,))
- search = Process(target=do_search)
- search.start()
- search.join(timeout=10)
- self.assertFalse(search.is_alive(), "/images/search took too long")
+ def do_search2():
+ payload = {'term': 'alpine', 'limit': 1}
+ r = requests.get(url, params=payload, timeout=5)
+ self.assertEqual(r.status_code, 200, r.text)
+ objs = json.loads(r.text)
+ self.assertIn(type(objs), (list,))
+ self.assertEqual(len(objs), 1)
+
+ def do_search3():
+ payload = {'term': 'alpine', 'filters': '{"is-official":["true"]}'}
+ r = requests.get(url, params=payload, timeout=5)
+ self.assertEqual(r.status_code, 200, r.text)
+ objs = json.loads(r.text)
+ self.assertIn(type(objs), (list,))
+ # There should be only one offical image
+ self.assertEqual(len(objs), 1)
+
+ def do_search4():
+ headers = {'X-Registry-Auth': 'null'}
+ payload = {'term': 'alpine'}
+ r = requests.get(url, params=payload, headers=headers, timeout=5)
+ self.assertEqual(r.status_code, 200, r.text)
+
+ def do_search5():
+ headers = {'X-Registry-Auth': 'invalid value'}
+ payload = {'term': 'alpine'}
+ r = requests.get(url, params=payload, headers=headers, timeout=5)
+ self.assertEqual(r.status_code, 400, r.text)
+
+ search_methods = [do_search1, do_search2, do_search3, do_search4, do_search5]
+ for search_method in search_methods:
+ search = Process(target=search_method)
+ search.start()
+ search.join(timeout=10)
+ self.assertFalse(search.is_alive(), "/images/search took too long")
def test_ping(self):
required_headers = (