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:
Madhu Venugopal
2015-10-30 20:27:44 -04:00
committed by Tibor Vass
parent c57d1e026d
commit 22cf3df4c0
4 changed files with 39 additions and 1 deletions
+17 -1
View File
@@ -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)