Browse code

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 <github@gone.nl>

Sebastiaan van Stijn authored on 2023/07/19 17:23:08
Showing 4 changed files
... ...
@@ -126,7 +126,7 @@ func setupPlugin(t *testing.T, ec map[string]*graphEventsCounter, ext string, mu
126 126
 	}
127 127
 
128 128
 	respond := func(w http.ResponseWriter, data interface{}) {
129
-		w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
129
+		w.Header().Set("Content-Type", plugins.VersionMimetype)
130 130
 		switch t := data.(type) {
131 131
 		case error:
132 132
 			fmt.Fprintf(w, "{\"Err\": %q}\n", t.Error())
... ...
@@ -66,7 +66,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
66 66
 	}
67 67
 
68 68
 	mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
69
-		w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
69
+		w.Header().Set("Content-Type", plugins.VersionMimetype)
70 70
 		fmt.Fprintf(w, `{"Implements": ["%s"]}`, driverapi.NetworkPluginEndpointType)
71 71
 	})
72 72
 
... ...
@@ -61,7 +61,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
61 61
 	}
62 62
 
63 63
 	mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
64
-		w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
64
+		w.Header().Set("Content-Type", plugins.VersionMimetype)
65 65
 		fmt.Fprintf(w, `{"Implements": ["%s"]}`, ipamapi.PluginEndpointType)
66 66
 	})
67 67
 
... ...
@@ -1164,7 +1164,7 @@ func TestInvalidRemoteDriver(t *testing.T) {
1164 1164
 	defer server.Close()
1165 1165
 
1166 1166
 	mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
1167
-		w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
1167
+		w.Header().Set("Content-Type", plugins.VersionMimetype)
1168 1168
 		fmt.Fprintln(w, `{"Implements": ["InvalidDriver"]}`)
1169 1169
 	})
1170 1170
 
... ...
@@ -1207,19 +1207,19 @@ func TestValidRemoteDriver(t *testing.T) {
1207 1207
 	defer server.Close()
1208 1208
 
1209 1209
 	mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
1210
-		w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
1210
+		w.Header().Set("Content-Type", plugins.VersionMimetype)
1211 1211
 		fmt.Fprintf(w, `{"Implements": ["%s"]}`, driverapi.NetworkPluginEndpointType)
1212 1212
 	})
1213 1213
 	mux.HandleFunc(fmt.Sprintf("/%s.GetCapabilities", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
1214
-		w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
1214
+		w.Header().Set("Content-Type", plugins.VersionMimetype)
1215 1215
 		fmt.Fprintf(w, `{"Scope":"local"}`)
1216 1216
 	})
1217 1217
 	mux.HandleFunc(fmt.Sprintf("/%s.CreateNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
1218
-		w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
1218
+		w.Header().Set("Content-Type", plugins.VersionMimetype)
1219 1219
 		fmt.Fprintf(w, "null")
1220 1220
 	})
1221 1221
 	mux.HandleFunc(fmt.Sprintf("/%s.DeleteNetwork", driverapi.NetworkPluginEndpointType), func(w http.ResponseWriter, r *http.Request) {
1222
-		w.Header().Set("Content-Type", "application/vnd.docker.plugins.v1+json")
1222
+		w.Header().Set("Content-Type", plugins.VersionMimetype)
1223 1223
 		fmt.Fprintf(w, "null")
1224 1224
 	})
1225 1225