From 481dde8b70d9ce1f865a87c1d4492e12483fdcdc Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 19 Jul 2023 10:23:08 +0200 Subject: [PATCH] libnetwork: use plugin Content-Type headers v1.2 The MediaType was changed twice in; - b3b7eb2723461b1eb4be692f4bced0ae8ea9cb58 ("application/vnd.docker.plugins.v1+json" -> "application/vnd.docker.plugins.v1.1+json") - 54587d861d6664d6d32bc62a46c0c7ea0c7853e6 ("application/vnd.docker.plugins.v1.1+json" -> "application/vnd.docker.plugins.v1.2+json") But the (integration) tests were still using the old version, so let's use the VersionMimeType const that's defined, and use the updated version. Signed-off-by: Sebastiaan van Stijn --- integration/plugin/graphdriver/external_test.go | 2 +- libnetwork/drivers/remote/driver_test.go | 2 +- libnetwork/ipams/remote/remote_test.go | 2 +- libnetwork/libnetwork_test.go | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/integration/plugin/graphdriver/external_test.go b/integration/plugin/graphdriver/external_test.go index 4ae77ca3df..1113502638 100644 --- a/integration/plugin/graphdriver/external_test.go +++ b/integration/plugin/graphdriver/external_test.go @@ -126,7 +126,7 @@ func setupPlugin(t *testing.T, ec map[string]*graphEventsCounter, ext string, mu } respond := func(w http.ResponseWriter, data interface{}) { - w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") + w.Header().Set("Content-Type", plugins.VersionMimetype) switch t := data.(type) { case error: fmt.Fprintf(w, "{\"Err\": %q}\n", t.Error()) diff --git a/libnetwork/drivers/remote/driver_test.go b/libnetwork/drivers/remote/driver_test.go index 0c19212b8b..6ef0bc1152 100644 --- a/libnetwork/drivers/remote/driver_test.go +++ b/libnetwork/drivers/remote/driver_test.go @@ -66,7 +66,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() { } mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") + w.Header().Set("Content-Type", plugins.VersionMimetype) fmt.Fprintf(w, `{"Implements": ["%s"]}`, driverapi.NetworkPluginEndpointType) }) diff --git a/libnetwork/ipams/remote/remote_test.go b/libnetwork/ipams/remote/remote_test.go index cfac9fa5ef..af4943a246 100644 --- a/libnetwork/ipams/remote/remote_test.go +++ b/libnetwork/ipams/remote/remote_test.go @@ -61,7 +61,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() { } mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") + w.Header().Set("Content-Type", plugins.VersionMimetype) fmt.Fprintf(w, `{"Implements": ["%s"]}`, ipamapi.PluginEndpointType) }) diff --git a/libnetwork/libnetwork_test.go b/libnetwork/libnetwork_test.go index 50057dadec..d30de8f73e 100644 --- a/libnetwork/libnetwork_test.go +++ b/libnetwork/libnetwork_test.go @@ -1164,7 +1164,7 @@ func TestInvalidRemoteDriver(t *testing.T) { defer server.Close() mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") + w.Header().Set("Content-Type", plugins.VersionMimetype) fmt.Fprintln(w, `{"Implements": ["InvalidDriver"]}`) }) @@ -1207,19 +1207,19 @@ func TestValidRemoteDriver(t *testing.T) { defer server.Close() mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") + w.Header().Set("Content-Type", plugins.VersionMimetype) fmt.Fprintf(w, `{"Implements": ["%s"]}`, driverapi.NetworkPluginEndpointType) }) mux.HandleFunc(fmt.Sprintf("/%s.GetCapabilities", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") + w.Header().Set("Content-Type", plugins.VersionMimetype) fmt.Fprintf(w, `{"Scope":"local"}`) }) mux.HandleFunc(fmt.Sprintf("/%s.CreateNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") + w.Header().Set("Content-Type", plugins.VersionMimetype) fmt.Fprintf(w, "null") }) mux.HandleFunc(fmt.Sprintf("/%s.DeleteNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json") + w.Header().Set("Content-Type", plugins.VersionMimetype) fmt.Fprintf(w, "null") })