mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 05:31:47 +00:00
Prevent user from deleting pre-defined networks
Signed-off-by: Madhu Venugopal <madhu@docker.com> (cherry picked from commit ead62b59522bba132b9a14712e4350439e7fa2a5) Conflicts: integration-cli/docker_api_network_test.go
This commit is contained in:
committed by
Tibor Vass
parent
c57d1e026d
commit
22cf3df4c0
@@ -189,6 +189,23 @@ func (s *DockerSuite) TestApiNetworkIpamMultipleBridgeNetworks(c *check.C) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestApiCreateDeletePredefinedNetworks(c *check.C) {
|
||||
createDeletePredefinedNetwork(c, "bridge")
|
||||
createDeletePredefinedNetwork(c, "none")
|
||||
createDeletePredefinedNetwork(c, "host")
|
||||
}
|
||||
|
||||
func createDeletePredefinedNetwork(c *check.C, name string) {
|
||||
// Create pre-defined network
|
||||
config := types.NetworkCreate{
|
||||
Name: name,
|
||||
CheckDuplicate: true,
|
||||
}
|
||||
shouldSucceed := false
|
||||
createNetwork(c, config, shouldSucceed)
|
||||
deleteNetwork(c, name, shouldSucceed)
|
||||
}
|
||||
|
||||
func isNetworkAvailable(c *check.C, name string) bool {
|
||||
status, body, err := sockRequest("GET", "/networks", nil)
|
||||
c.Assert(status, check.Equals, http.StatusOK)
|
||||
@@ -280,7 +297,6 @@ func deleteNetwork(c *check.C, id string, shouldSucceed bool) {
|
||||
status, _, err := sockRequest("DELETE", "/networks/"+id, nil)
|
||||
if !shouldSucceed {
|
||||
c.Assert(status, check.Not(check.Equals), http.StatusOK)
|
||||
c.Assert(err, check.NotNil)
|
||||
return
|
||||
}
|
||||
c.Assert(status, check.Equals, http.StatusOK)
|
||||
|
||||
Reference in New Issue
Block a user