diff options
author | Jhon Honce <jhonce@redhat.com> | 2020-12-04 13:44:33 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2020-12-04 13:44:33 -0700 |
commit | 53c8bc5a5e48f02fb0c1f1a87ec5214fb47f0b93 (patch) | |
tree | 02832295349dfbff4ea821320ccd8f59cbfba72c /test/apiv2 | |
parent | f01630acf35a11aecdbfb9b77b249dcec85e67b5 (diff) | |
download | podman-53c8bc5a5e48f02fb0c1f1a87ec5214fb47f0b93.tar.gz podman-53c8bc5a5e48f02fb0c1f1a87ec5214fb47f0b93.tar.bz2 podman-53c8bc5a5e48f02fb0c1f1a87ec5214fb47f0b93.zip |
Jira RUN-1106 Network handlers updates
* Add network API tests
* Update network create endpoint to return ID not Name
Audit:
- GET /networks ListNetworks
- GET /networks/{id} InspectNetwork
- DELETE /networks/{id} RemoveNetwork
- POST /networks/create CreateNetwork
- POST /networks/prune 405 not implemented
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'test/apiv2')
-rw-r--r-- | test/apiv2/rest_api/test_rest_v2_0_0.py | 43 |
1 files changed, 41 insertions, 2 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 dc92a2966..d4608a5f7 100644 --- a/test/apiv2/rest_api/test_rest_v2_0_0.py +++ b/test/apiv2/rest_api/test_rest_v2_0_0.py @@ -1,11 +1,13 @@ import json +import random +import string import subprocess -import sys -import time import unittest from multiprocessing import Process import requests +import sys +import time from dateutil.parser import parse from test.apiv2.rest_api import Podman @@ -384,6 +386,43 @@ class TestApi(unittest.TestCase): for k in required_keys: self.assertIn(k, o) + def test_network_compat(self): + name = "Network_" + "".join(random.choice(string.ascii_letters) for i in range(10)) + + # Cannot test for 0 existing networks because default "podman" network always exists + + create = requests.post(PODMAN_URL + "/v1.40/networks/create", json={"Name": name}) + self.assertEqual(create.status_code, 201, create.content) + obj = json.loads(create.content) + self.assertIn(type(obj), (dict,)) + self.assertIn("Id", obj) + ident = obj["Id"] + self.assertNotEqual(name, ident) + + ls = requests.get(PODMAN_URL + "/v1.40/networks") + self.assertEqual(ls.status_code, 200, ls.content) + objs = json.loads(ls.content) + self.assertIn(type(objs), (list,)) + + found = False + for network in objs: + if network["Name"] == name: + found = True + self.assertTrue(found, f"Network {name} not found") + + inspect = requests.get(PODMAN_URL + f"/v1.40/networks/{ident}") + self.assertEqual(inspect.status_code, 200, inspect.content) + obj = json.loads(create.content) + self.assertIn(type(obj), (dict,)) + + inspect = requests.delete(PODMAN_URL + f"/v1.40/networks/{ident}") + self.assertEqual(inspect.status_code, 204, inspect.content) + inspect = requests.get(PODMAN_URL + f"/v1.40/networks/{ident}") + self.assertEqual(inspect.status_code, 404, inspect.content) + + prune = requests.post(PODMAN_URL + "/v1.40/networks/prune") + self.assertEqual(prune.status_code, 405, prune.content) + if __name__ == "__main__": unittest.main() |