summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2021-02-10 15:48:14 -0600
committerbaude <bbaude@redhat.com>2021-02-10 15:48:14 -0600
commitf28b08fe969b90f6823ec3001cc7472738a1bffc (patch)
tree28d86cb9799b7e824464777975d39b357126143a
parent4d604c10897da33b7b3677631d219481cec11c7f (diff)
downloadpodman-f28b08fe969b90f6823ec3001cc7472738a1bffc.tar.gz
podman-f28b08fe969b90f6823ec3001cc7472738a1bffc.tar.bz2
podman-f28b08fe969b90f6823ec3001cc7472738a1bffc.zip
Correct compat network prune response
Correcting the structure of the compat network prune response. They should follow {"NetworksDeleted": [<network_name>",...]} Fixes: #9310 Signed-off-by: baude <bbaude@redhat.com>
-rw-r--r--pkg/api/handlers/compat/networks.go5
-rw-r--r--test/apiv2/rest_api/test_rest_v2_0_0.py8
2 files changed, 12 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/networks.go b/pkg/api/handlers/compat/networks.go
index 85d2db87e..83c80aac9 100644
--- a/pkg/api/handlers/compat/networks.go
+++ b/pkg/api/handlers/compat/networks.go
@@ -400,6 +400,9 @@ func Prune(w http.ResponseWriter, r *http.Request) {
utils.Error(w, "Something went wrong.", http.StatusInternalServerError, err)
return
}
+ type response struct {
+ NetworksDeleted []string
+ }
var prunedNetworks []string //nolint
for _, pr := range pruneReports {
if pr.Error != nil {
@@ -408,5 +411,5 @@ func Prune(w http.ResponseWriter, r *http.Request) {
}
prunedNetworks = append(prunedNetworks, pr.Name)
}
- utils.WriteResponse(w, http.StatusOK, prunedNetworks)
+ utils.WriteResponse(w, http.StatusOK, response{NetworksDeleted: prunedNetworks})
}
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 73db35cc1..05c24f2ea 100644
--- a/test/apiv2/rest_api/test_rest_v2_0_0.py
+++ b/test/apiv2/rest_api/test_rest_v2_0_0.py
@@ -483,8 +483,16 @@ class TestApi(unittest.TestCase):
inspect = requests.get(PODMAN_URL + f"/v1.40/networks/{ident}")
self.assertEqual(inspect.status_code, 404, inspect.content)
+ # network prune
+ prune_name = "Network_" + "".join(random.choice(string.ascii_letters) for i in range(10))
+ prune_create = requests.post(PODMAN_URL + "/v1.40/networks/create", json={"Name": prune_name})
+ self.assertEqual(create.status_code, 201, prune_create.content)
+
prune = requests.post(PODMAN_URL + "/v1.40/networks/prune")
self.assertEqual(prune.status_code, 200, prune.content)
+ obj = json.loads(prune.content)
+ self.assertTrue(prune_name in obj["NetworksDeleted"])
+
def test_volumes_compat(self):
name = "Volume_" + "".join(random.choice(string.ascii_letters) for i in range(10))