use http consts for request methods
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>master
							parent
							
								
									7f9f86c411
								
							
						
					
					
						commit
						f9ccd2c6ea
					
				|  | @ -14,7 +14,7 @@ func TestWithRequest(t *testing.T) { | ||||||
| 	var req http.Request | 	var req http.Request | ||||||
| 
 | 
 | ||||||
| 	start := time.Now() | 	start := time.Now() | ||||||
| 	req.Method = "GET" | 	req.Method = http.MethodGet | ||||||
| 	req.Host = "example.com" | 	req.Host = "example.com" | ||||||
| 	req.RequestURI = "/test-test" | 	req.RequestURI = "/test-test" | ||||||
| 	req.Header = make(http.Header) | 	req.Header = make(http.Header) | ||||||
|  | @ -253,7 +253,7 @@ func TestRemoteAddr(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	// X-Forwarded-For set by proxy
 | 	// X-Forwarded-For set by proxy
 | ||||||
| 	expectedRemote = "127.0.0.1" | 	expectedRemote = "127.0.0.1" | ||||||
| 	proxyReq, err := http.NewRequest("GET", frontend.URL, nil) | 	proxyReq, err := http.NewRequest(http.MethodGet, frontend.URL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
|  | @ -264,7 +264,7 @@ func TestRemoteAddr(t *testing.T) { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// RemoteAddr in X-Real-Ip
 | 	// RemoteAddr in X-Real-Ip
 | ||||||
| 	getReq, err := http.NewRequest("GET", backend.URL, nil) | 	getReq, err := http.NewRequest(http.MethodGet, backend.URL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -96,8 +96,8 @@ func main() { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	router := mux.NewRouter() | 	router := mux.NewRouter() | ||||||
| 	router.Path("/token/").Methods("GET").Handler(handlerWithContext(ctx, ts.getToken)) | 	router.Path("/token/").Methods(http.MethodGet).Handler(handlerWithContext(ctx, ts.getToken)) | ||||||
| 	router.Path("/token/").Methods("POST").Handler(handlerWithContext(ctx, ts.postToken)) | 	router.Path("/token/").Methods(http.MethodPost).Handler(handlerWithContext(ctx, ts.postToken)) | ||||||
| 
 | 
 | ||||||
| 	if cert == "" { | 	if cert == "" { | ||||||
| 		err = http.ListenAndServe(addr, router) | 		err = http.ListenAndServe(addr, router) | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ var ( | ||||||
| 
 | 
 | ||||||
| // DownHandler registers a manual_http_status that always returns an Error
 | // DownHandler registers a manual_http_status that always returns an Error
 | ||||||
| func DownHandler(w http.ResponseWriter, r *http.Request) { | func DownHandler(w http.ResponseWriter, r *http.Request) { | ||||||
| 	if r.Method == "POST" { | 	if r.Method == http.MethodPost { | ||||||
| 		updater.Update(errors.New("manual Check")) | 		updater.Update(errors.New("manual Check")) | ||||||
| 	} else { | 	} else { | ||||||
| 		w.WriteHeader(http.StatusNotFound) | 		w.WriteHeader(http.StatusNotFound) | ||||||
|  | @ -22,7 +22,7 @@ func DownHandler(w http.ResponseWriter, r *http.Request) { | ||||||
| 
 | 
 | ||||||
| // UpHandler registers a manual_http_status that always returns nil
 | // UpHandler registers a manual_http_status that always returns nil
 | ||||||
| func UpHandler(w http.ResponseWriter, r *http.Request) { | func UpHandler(w http.ResponseWriter, r *http.Request) { | ||||||
| 	if r.Method == "POST" { | 	if r.Method == http.MethodPost { | ||||||
| 		updater.Update(nil) | 		updater.Update(nil) | ||||||
| 	} else { | 	} else { | ||||||
| 		w.WriteHeader(http.StatusNotFound) | 		w.WriteHeader(http.StatusNotFound) | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ import ( | ||||||
| func TestGETDownHandlerDoesNotChangeStatus(t *testing.T) { | func TestGETDownHandlerDoesNotChangeStatus(t *testing.T) { | ||||||
| 	recorder := httptest.NewRecorder() | 	recorder := httptest.NewRecorder() | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequest("GET", "https://fakeurl.com/debug/health/down", nil) | 	req, err := http.NewRequest(http.MethodGet, "https://fakeurl.com/debug/health/down", nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Failed to create request.") | 		t.Errorf("Failed to create request.") | ||||||
| 	} | 	} | ||||||
|  | @ -30,7 +30,7 @@ func TestGETDownHandlerDoesNotChangeStatus(t *testing.T) { | ||||||
| func TestGETUpHandlerDoesNotChangeStatus(t *testing.T) { | func TestGETUpHandlerDoesNotChangeStatus(t *testing.T) { | ||||||
| 	recorder := httptest.NewRecorder() | 	recorder := httptest.NewRecorder() | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequest("GET", "https://fakeurl.com/debug/health/up", nil) | 	req, err := http.NewRequest(http.MethodGet, "https://fakeurl.com/debug/health/up", nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Failed to create request.") | 		t.Errorf("Failed to create request.") | ||||||
| 	} | 	} | ||||||
|  | @ -48,7 +48,7 @@ func TestGETUpHandlerDoesNotChangeStatus(t *testing.T) { | ||||||
| func TestPOSTDownHandlerChangeStatus(t *testing.T) { | func TestPOSTDownHandlerChangeStatus(t *testing.T) { | ||||||
| 	recorder := httptest.NewRecorder() | 	recorder := httptest.NewRecorder() | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequest("POST", "https://fakeurl.com/debug/health/down", nil) | 	req, err := http.NewRequest(http.MethodPost, "https://fakeurl.com/debug/health/down", nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Failed to create request.") | 		t.Errorf("Failed to create request.") | ||||||
| 	} | 	} | ||||||
|  | @ -69,7 +69,7 @@ func TestPOSTDownHandlerChangeStatus(t *testing.T) { | ||||||
| func TestPOSTUpHandlerChangeStatus(t *testing.T) { | func TestPOSTUpHandlerChangeStatus(t *testing.T) { | ||||||
| 	recorder := httptest.NewRecorder() | 	recorder := httptest.NewRecorder() | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequest("POST", "https://fakeurl.com/debug/health/up", nil) | 	req, err := http.NewRequest(http.MethodPost, "https://fakeurl.com/debug/health/up", nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Failed to create request.") | 		t.Errorf("Failed to create request.") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -40,7 +40,7 @@ func HTTPChecker(r string, statusCode int, timeout time.Duration, headers http.H | ||||||
| 		client := http.Client{ | 		client := http.Client{ | ||||||
| 			Timeout: timeout, | 			Timeout: timeout, | ||||||
| 		} | 		} | ||||||
| 		req, err := http.NewRequest("HEAD", r, nil) | 		req, err := http.NewRequest(http.MethodHead, r, nil) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return errors.New("error creating request: " + r) | 			return errors.New("error creating request: " + r) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -242,7 +242,7 @@ func RegisterPeriodicThresholdFunc(name string, period time.Duration, threshold | ||||||
| // and their corresponding status.
 | // and their corresponding status.
 | ||||||
| // Returns 503 if any Error status exists, 200 otherwise
 | // Returns 503 if any Error status exists, 200 otherwise
 | ||||||
| func StatusHandler(w http.ResponseWriter, r *http.Request) { | func StatusHandler(w http.ResponseWriter, r *http.Request) { | ||||||
| 	if r.Method == "GET" { | 	if r.Method == http.MethodGet { | ||||||
| 		checks := CheckStatus() | 		checks := CheckStatus() | ||||||
| 		status := http.StatusOK | 		status := http.StatusOK | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -13,7 +13,7 @@ import ( | ||||||
| func TestReturns200IfThereAreNoChecks(t *testing.T) { | func TestReturns200IfThereAreNoChecks(t *testing.T) { | ||||||
| 	recorder := httptest.NewRecorder() | 	recorder := httptest.NewRecorder() | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequest("GET", "https://fakeurl.com/debug/health", nil) | 	req, err := http.NewRequest(http.MethodGet, "https://fakeurl.com/debug/health", nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Failed to create request.") | 		t.Errorf("Failed to create request.") | ||||||
| 	} | 	} | ||||||
|  | @ -30,7 +30,7 @@ func TestReturns200IfThereAreNoChecks(t *testing.T) { | ||||||
| func TestReturns503IfThereAreErrorChecks(t *testing.T) { | func TestReturns503IfThereAreErrorChecks(t *testing.T) { | ||||||
| 	recorder := httptest.NewRecorder() | 	recorder := httptest.NewRecorder() | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequest("GET", "https://fakeurl.com/debug/health", nil) | 	req, err := http.NewRequest(http.MethodGet, "https://fakeurl.com/debug/health", nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Errorf("Failed to create request.") | 		t.Errorf("Failed to create request.") | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ import ( | ||||||
| func TestHTTPSink(t *testing.T) { | func TestHTTPSink(t *testing.T) { | ||||||
| 	serverHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | 	serverHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||||||
| 		defer r.Body.Close() | 		defer r.Body.Close() | ||||||
| 		if r.Method != "POST" { | 		if r.Method != http.MethodPost { | ||||||
| 			w.WriteHeader(http.StatusMethodNotAllowed) | 			w.WriteHeader(http.StatusMethodNotAllowed) | ||||||
| 			t.Fatalf("unexpected request method: %v", r.Method) | 			t.Fatalf("unexpected request method: %v", r.Method) | ||||||
| 			return | 			return | ||||||
|  |  | ||||||
|  | @ -381,7 +381,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 		Description: `Base V2 API route. Typically, this can be used for lightweight version checks and to validate registry authentication.`, | 		Description: `Base V2 API route. Typically, this can be used for lightweight version checks and to validate registry authentication.`, | ||||||
| 		Methods: []MethodDescriptor{ | 		Methods: []MethodDescriptor{ | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "GET", | 				Method:      http.MethodGet, | ||||||
| 				Description: "Check that the endpoint implements Docker Registry API V2.", | 				Description: "Check that the endpoint implements Docker Registry API V2.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -415,7 +415,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 		Description: "Retrieve information about tags.", | 		Description: "Retrieve information about tags.", | ||||||
| 		Methods: []MethodDescriptor{ | 		Methods: []MethodDescriptor{ | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "GET", | 				Method:      http.MethodGet, | ||||||
| 				Description: "Fetch the tags under the repository identified by `name`.", | 				Description: "Fetch the tags under the repository identified by `name`.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -519,7 +519,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 		Description: "Create, update, delete and retrieve manifests.", | 		Description: "Create, update, delete and retrieve manifests.", | ||||||
| 		Methods: []MethodDescriptor{ | 		Methods: []MethodDescriptor{ | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "GET", | 				Method:      http.MethodGet, | ||||||
| 				Description: "Fetch the manifest identified by `name` and `reference` where `reference` can be a tag or digest. A `HEAD` request can also be issued to this endpoint to obtain resource information without receiving all data.", | 				Description: "Fetch the manifest identified by `name` and `reference` where `reference` can be a tag or digest. A `HEAD` request can also be issued to this endpoint to obtain resource information without receiving all data.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -566,7 +566,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "PUT", | 				Method:      http.MethodPut, | ||||||
| 				Description: "Put the manifest identified by `name` and `reference` where `reference` can be a tag or digest.", | 				Description: "Put the manifest identified by `name` and `reference` where `reference` can be a tag or digest.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -654,7 +654,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "DELETE", | 				Method:      http.MethodDelete, | ||||||
| 				Description: "Delete the manifest or tag identified by `name` and `reference` where `reference` can be a tag or digest. Note that a manifest can _only_ be deleted by digest.", | 				Description: "Delete the manifest or tag identified by `name` and `reference` where `reference` can be a tag or digest. Note that a manifest can _only_ be deleted by digest.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -724,7 +724,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 		Description: "Operations on blobs identified by `name` and `digest`. Used to fetch or delete layers by digest.", | 		Description: "Operations on blobs identified by `name` and `digest`. Used to fetch or delete layers by digest.", | ||||||
| 		Methods: []MethodDescriptor{ | 		Methods: []MethodDescriptor{ | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "GET", | 				Method:      http.MethodGet, | ||||||
| 				Description: "Retrieve the blob from the registry identified by `digest`. A `HEAD` request can also be issued to this endpoint to obtain resource information without receiving all data.", | 				Description: "Retrieve the blob from the registry identified by `digest`. A `HEAD` request can also be issued to this endpoint to obtain resource information without receiving all data.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -878,7 +878,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "DELETE", | 				Method:      http.MethodDelete, | ||||||
| 				Description: "Delete the blob identified by `name` and `digest`", | 				Description: "Delete the blob identified by `name` and `digest`", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -958,7 +958,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 		Description: "Initiate a blob upload. This endpoint can be used to create resumable uploads or monolithic uploads.", | 		Description: "Initiate a blob upload. This endpoint can be used to create resumable uploads or monolithic uploads.", | ||||||
| 		Methods: []MethodDescriptor{ | 		Methods: []MethodDescriptor{ | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "POST", | 				Method:      http.MethodPost, | ||||||
| 				Description: "Initiate a resumable blob upload. If successful, an upload location will be provided to complete the upload. Optionally, if the `digest` parameter is present, the request body will be used to complete the upload in a single request.", | 				Description: "Initiate a resumable blob upload. If successful, an upload location will be provided to complete the upload. Optionally, if the `digest` parameter is present, the request body will be used to complete the upload in a single request.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -1151,7 +1151,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 		Description: "Interact with blob uploads. Clients should never assemble URLs for this endpoint and should only take it through the `Location` header on related API requests. The `Location` header and its parameters should be preserved by clients, using the latest value returned via upload related API calls.", | 		Description: "Interact with blob uploads. Clients should never assemble URLs for this endpoint and should only take it through the `Location` header on related API requests. The `Location` header and its parameters should be preserved by clients, using the latest value returned via upload related API calls.", | ||||||
| 		Methods: []MethodDescriptor{ | 		Methods: []MethodDescriptor{ | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "GET", | 				Method:      http.MethodGet, | ||||||
| 				Description: "Retrieve status of upload identified by `uuid`. The primary purpose of this endpoint is to resolve the current status of a resumable upload.", | 				Description: "Retrieve status of upload identified by `uuid`. The primary purpose of this endpoint is to resolve the current status of a resumable upload.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -1215,7 +1215,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "PATCH", | 				Method:      http.MethodPatch, | ||||||
| 				Description: "Upload a chunk of data for the specified upload.", | 				Description: "Upload a chunk of data for the specified upload.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -1376,7 +1376,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "PUT", | 				Method:      http.MethodPut, | ||||||
| 				Description: "Complete the upload specified by `uuid`, optionally appending the body as the final chunk.", | 				Description: "Complete the upload specified by `uuid`, optionally appending the body as the final chunk.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -1467,7 +1467,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "DELETE", | 				Method:      http.MethodDelete, | ||||||
| 				Description: "Cancel outstanding upload processes, releasing associated resources. If this is not called, the unfinished uploads will eventually timeout.", | 				Description: "Cancel outstanding upload processes, releasing associated resources. If this is not called, the unfinished uploads will eventually timeout.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  | @ -1532,7 +1532,7 @@ var routeDescriptors = []RouteDescriptor{ | ||||||
| 		Description: "List a set of available repositories in the local registry cluster. Does not provide any indication of what may be available upstream. Applications can only determine if a repository is available but not if it is not available.", | 		Description: "List a set of available repositories in the local registry cluster. Does not provide any indication of what may be available upstream. Applications can only determine if a repository is available but not if it is not available.", | ||||||
| 		Methods: []MethodDescriptor{ | 		Methods: []MethodDescriptor{ | ||||||
| 			{ | 			{ | ||||||
| 				Method:      "GET", | 				Method:      http.MethodGet, | ||||||
| 				Description: "Retrieve a sorted, json list of repositories available in the registry.", | 				Description: "Retrieve a sorted, json list of repositories available in the registry.", | ||||||
| 				Requests: []RequestDescriptor{ | 				Requests: []RequestDescriptor{ | ||||||
| 					{ | 					{ | ||||||
|  |  | ||||||
|  | @ -74,7 +74,7 @@ func TestBasicAccessController(t *testing.T) { | ||||||
| 		CheckRedirect: nil, | 		CheckRedirect: nil, | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	req, _ := http.NewRequest("GET", server.URL, nil) | 	req, _ := http.NewRequest(http.MethodGet, server.URL, nil) | ||||||
| 	resp, err := client.Do(req) | 	resp, err := client.Do(req) | ||||||
| 
 | 
 | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  | @ -94,7 +94,7 @@ func TestBasicAccessController(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	for i := 0; i < len(testUsers); i++ { | 	for i := 0; i < len(testUsers); i++ { | ||||||
| 		userNumber = i | 		userNumber = i | ||||||
| 		req, err := http.NewRequest("GET", server.URL, nil) | 		req, err := http.NewRequest(http.MethodGet, server.URL, nil) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			t.Fatalf("error allocating new request: %v", err) | 			t.Fatalf("error allocating new request: %v", err) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -52,7 +52,7 @@ func TestSillyAccessController(t *testing.T) { | ||||||
| 		t.Fatalf("unexpected response status: %v != %v", resp.StatusCode, http.StatusUnauthorized) | 		t.Fatalf("unexpected response status: %v != %v", resp.StatusCode, http.StatusUnauthorized) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequest("GET", server.URL, nil) | 	req, err := http.NewRequest(http.MethodGet, server.URL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("unexpected error creating new request: %v", err) | 		t.Fatalf("unexpected error creating new request: %v", err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -342,7 +342,7 @@ func TestAccessController(t *testing.T) { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// 1. Make a mock http.Request with no token.
 | 	// 1. Make a mock http.Request with no token.
 | ||||||
| 	req, err := http.NewRequest("GET", "http://example.com/foo", nil) | 	req, err := http.NewRequest(http.MethodGet, "http://example.com/foo", nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatal(err) | 		t.Fatal(err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -109,7 +109,7 @@ func TestEndpointAuthorizeToken(t *testing.T) { | ||||||
| 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  fmt.Sprintf("/token?scope=%s&service=%s", url.QueryEscape(scope1), service), | 				Route:  fmt.Sprintf("/token?scope=%s&service=%s", url.QueryEscape(scope1), service), | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -119,7 +119,7 @@ func TestEndpointAuthorizeToken(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  fmt.Sprintf("/token?scope=%s&service=%s", url.QueryEscape(scope2), service), | 				Route:  fmt.Sprintf("/token?scope=%s&service=%s", url.QueryEscape(scope2), service), | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -134,7 +134,7 @@ func TestEndpointAuthorizeToken(t *testing.T) { | ||||||
| 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -164,7 +164,7 @@ func TestEndpointAuthorizeToken(t *testing.T) { | ||||||
| 	transport1 := transport.NewTransport(nil, NewAuthorizer(challengeManager1, NewTokenHandler(nil, nil, repo1, "pull", "push"))) | 	transport1 := transport.NewTransport(nil, NewAuthorizer(challengeManager1, NewTokenHandler(nil, nil, repo1, "pull", "push"))) | ||||||
| 	client := &http.Client{Transport: transport1} | 	client := &http.Client{Transport: transport1} | ||||||
| 
 | 
 | ||||||
| 	req, _ := http.NewRequest("GET", e+"/v2/hello", nil) | 	req, _ := http.NewRequest(http.MethodGet, e+"/v2/hello", nil) | ||||||
| 	resp, err := client.Do(req) | 	resp, err := client.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error sending get request: %s", err) | 		t.Fatalf("Error sending get request: %s", err) | ||||||
|  | @ -197,7 +197,7 @@ func TestEndpointAuthorizeToken(t *testing.T) { | ||||||
| 	transport2 := transport.NewTransport(nil, NewAuthorizer(challengeManager2, NewTokenHandler(nil, nil, repo2, "pull", "push"))) | 	transport2 := transport.NewTransport(nil, NewAuthorizer(challengeManager2, NewTokenHandler(nil, nil, repo2, "pull", "push"))) | ||||||
| 	client2 := &http.Client{Transport: transport2} | 	client2 := &http.Client{Transport: transport2} | ||||||
| 
 | 
 | ||||||
| 	req, _ = http.NewRequest("GET", e2+"/v2/hello", nil) | 	req, _ = http.NewRequest(http.MethodGet, e2+"/v2/hello", nil) | ||||||
| 	resp, err = client2.Do(req) | 	resp, err = client2.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error sending get request: %s", err) | 		t.Fatalf("Error sending get request: %s", err) | ||||||
|  | @ -219,7 +219,7 @@ func TestEndpointAuthorizeRefreshToken(t *testing.T) { | ||||||
| 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "POST", | 				Method: http.MethodPost, | ||||||
| 				Route:  "/token", | 				Route:  "/token", | ||||||
| 				Body:   []byte(fmt.Sprintf("client_id=registry-client&grant_type=refresh_token&refresh_token=%s&scope=%s&service=%s", refreshToken1, url.QueryEscape(scope1), service)), | 				Body:   []byte(fmt.Sprintf("client_id=registry-client&grant_type=refresh_token&refresh_token=%s&scope=%s&service=%s", refreshToken1, url.QueryEscape(scope1), service)), | ||||||
| 			}, | 			}, | ||||||
|  | @ -231,7 +231,7 @@ func TestEndpointAuthorizeRefreshToken(t *testing.T) { | ||||||
| 		{ | 		{ | ||||||
| 			// In the future this test may fail and require using basic auth to get a different refresh token
 | 			// In the future this test may fail and require using basic auth to get a different refresh token
 | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "POST", | 				Method: http.MethodPost, | ||||||
| 				Route:  "/token", | 				Route:  "/token", | ||||||
| 				Body:   []byte(fmt.Sprintf("client_id=registry-client&grant_type=refresh_token&refresh_token=%s&scope=%s&service=%s", refreshToken1, url.QueryEscape(scope2), service)), | 				Body:   []byte(fmt.Sprintf("client_id=registry-client&grant_type=refresh_token&refresh_token=%s&scope=%s&service=%s", refreshToken1, url.QueryEscape(scope2), service)), | ||||||
| 			}, | 			}, | ||||||
|  | @ -242,7 +242,7 @@ func TestEndpointAuthorizeRefreshToken(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "POST", | 				Method: http.MethodPost, | ||||||
| 				Route:  "/token", | 				Route:  "/token", | ||||||
| 				Body:   []byte(fmt.Sprintf("client_id=registry-client&grant_type=refresh_token&refresh_token=%s&scope=%s&service=%s", refreshToken2, url.QueryEscape(scope2), service)), | 				Body:   []byte(fmt.Sprintf("client_id=registry-client&grant_type=refresh_token&refresh_token=%s&scope=%s&service=%s", refreshToken2, url.QueryEscape(scope2), service)), | ||||||
| 			}, | 			}, | ||||||
|  | @ -258,7 +258,7 @@ func TestEndpointAuthorizeRefreshToken(t *testing.T) { | ||||||
| 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -293,7 +293,7 @@ func TestEndpointAuthorizeRefreshToken(t *testing.T) { | ||||||
| 	transport1 := transport.NewTransport(nil, NewAuthorizer(challengeManager1, NewTokenHandler(nil, creds, repo1, "pull", "push"))) | 	transport1 := transport.NewTransport(nil, NewAuthorizer(challengeManager1, NewTokenHandler(nil, creds, repo1, "pull", "push"))) | ||||||
| 	client := &http.Client{Transport: transport1} | 	client := &http.Client{Transport: transport1} | ||||||
| 
 | 
 | ||||||
| 	req, _ := http.NewRequest("GET", e+"/v2/hello", nil) | 	req, _ := http.NewRequest(http.MethodGet, e+"/v2/hello", nil) | ||||||
| 	resp, err := client.Do(req) | 	resp, err := client.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error sending get request: %s", err) | 		t.Fatalf("Error sending get request: %s", err) | ||||||
|  | @ -322,7 +322,7 @@ func TestEndpointAuthorizeRefreshToken(t *testing.T) { | ||||||
| 	transport2 := transport.NewTransport(nil, NewAuthorizer(challengeManager2, NewTokenHandler(nil, creds, repo2, "pull", "push"))) | 	transport2 := transport.NewTransport(nil, NewAuthorizer(challengeManager2, NewTokenHandler(nil, creds, repo2, "pull", "push"))) | ||||||
| 	client2 := &http.Client{Transport: transport2} | 	client2 := &http.Client{Transport: transport2} | ||||||
| 
 | 
 | ||||||
| 	req, _ = http.NewRequest("GET", e2+"/v2/hello", nil) | 	req, _ = http.NewRequest(http.MethodGet, e2+"/v2/hello", nil) | ||||||
| 	resp, err = client2.Do(req) | 	resp, err = client2.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error sending get request: %s", err) | 		t.Fatalf("Error sending get request: %s", err) | ||||||
|  | @ -352,7 +352,7 @@ func TestEndpointAuthorizeRefreshToken(t *testing.T) { | ||||||
| 	transport3 := transport.NewTransport(nil, NewAuthorizer(challengeManager3, NewTokenHandler(nil, creds, repo2, "pull", "push"))) | 	transport3 := transport.NewTransport(nil, NewAuthorizer(challengeManager3, NewTokenHandler(nil, creds, repo2, "pull", "push"))) | ||||||
| 	client3 := &http.Client{Transport: transport3} | 	client3 := &http.Client{Transport: transport3} | ||||||
| 
 | 
 | ||||||
| 	req, _ = http.NewRequest("GET", e3+"/v2/hello", nil) | 	req, _ = http.NewRequest(http.MethodGet, e3+"/v2/hello", nil) | ||||||
| 	resp, err = client3.Do(req) | 	resp, err = client3.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error sending get request: %s", err) | 		t.Fatalf("Error sending get request: %s", err) | ||||||
|  | @ -370,7 +370,7 @@ func TestEndpointAuthorizeV2RefreshToken(t *testing.T) { | ||||||
| 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "POST", | 				Method: http.MethodPost, | ||||||
| 				Route:  "/token", | 				Route:  "/token", | ||||||
| 				Body:   []byte(fmt.Sprintf("client_id=registry-client&grant_type=refresh_token&refresh_token=%s&scope=%s&service=%s", refreshToken1, url.QueryEscape(scope1), service)), | 				Body:   []byte(fmt.Sprintf("client_id=registry-client&grant_type=refresh_token&refresh_token=%s&scope=%s&service=%s", refreshToken1, url.QueryEscape(scope1), service)), | ||||||
| 			}, | 			}, | ||||||
|  | @ -386,7 +386,7 @@ func TestEndpointAuthorizeV2RefreshToken(t *testing.T) { | ||||||
| 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v1/search", | 				Route:  "/v1/search", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -430,7 +430,7 @@ func TestEndpointAuthorizeV2RefreshToken(t *testing.T) { | ||||||
| 	transport1 := transport.NewTransport(nil, NewAuthorizer(challengeManager1, NewTokenHandlerWithOptions(tho))) | 	transport1 := transport.NewTransport(nil, NewAuthorizer(challengeManager1, NewTokenHandlerWithOptions(tho))) | ||||||
| 	client := &http.Client{Transport: transport1} | 	client := &http.Client{Transport: transport1} | ||||||
| 
 | 
 | ||||||
| 	req, _ := http.NewRequest("GET", e+"/v1/search", nil) | 	req, _ := http.NewRequest(http.MethodGet, e+"/v1/search", nil) | ||||||
| 	resp, err := client.Do(req) | 	resp, err := client.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error sending get request: %s", err) | 		t.Fatalf("Error sending get request: %s", err) | ||||||
|  | @ -456,7 +456,7 @@ func TestEndpointAuthorizeTokenBasic(t *testing.T) { | ||||||
| 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  fmt.Sprintf("/token?account=%s&scope=%s&service=%s", username, url.QueryEscape(scope), service), | 				Route:  fmt.Sprintf("/token?account=%s&scope=%s&service=%s", username, url.QueryEscape(scope), service), | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -476,7 +476,7 @@ func TestEndpointAuthorizeTokenBasic(t *testing.T) { | ||||||
| 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -505,7 +505,7 @@ func TestEndpointAuthorizeTokenBasic(t *testing.T) { | ||||||
| 	transport1 := transport.NewTransport(nil, NewAuthorizer(challengeManager, NewTokenHandler(nil, creds, repo, "pull", "push"), NewBasicHandler(creds))) | 	transport1 := transport.NewTransport(nil, NewAuthorizer(challengeManager, NewTokenHandler(nil, creds, repo, "pull", "push"), NewBasicHandler(creds))) | ||||||
| 	client := &http.Client{Transport: transport1} | 	client := &http.Client{Transport: transport1} | ||||||
| 
 | 
 | ||||||
| 	req, _ := http.NewRequest("GET", e+"/v2/hello", nil) | 	req, _ := http.NewRequest(http.MethodGet, e+"/v2/hello", nil) | ||||||
| 	resp, err := client.Do(req) | 	resp, err := client.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error sending get request: %s", err) | 		t.Fatalf("Error sending get request: %s", err) | ||||||
|  | @ -526,7 +526,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresIn(t *testing.T) { | ||||||
| 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  fmt.Sprintf("/token?account=%s&scope=%s&service=%s", username, url.QueryEscape(scope), service), | 				Route:  fmt.Sprintf("/token?account=%s&scope=%s&service=%s", username, url.QueryEscape(scope), service), | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -536,7 +536,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresIn(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  fmt.Sprintf("/token?account=%s&scope=%s&service=%s", username, url.QueryEscape(scope), service), | 				Route:  fmt.Sprintf("/token?account=%s&scope=%s&service=%s", username, url.QueryEscape(scope), service), | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -558,7 +558,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresIn(t *testing.T) { | ||||||
| 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -567,7 +567,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresIn(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -576,7 +576,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresIn(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -585,7 +585,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresIn(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -594,7 +594,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresIn(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -640,7 +640,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresIn(t *testing.T) { | ||||||
| 	// Subsequent calls should recycle the token from the first request, until the expiration has lapsed.
 | 	// Subsequent calls should recycle the token from the first request, until the expiration has lapsed.
 | ||||||
| 	timeIncrement := 1000 * time.Second | 	timeIncrement := 1000 * time.Second | ||||||
| 	for i := 0; i < 4; i++ { | 	for i := 0; i < 4; i++ { | ||||||
| 		req, _ := http.NewRequest("GET", e+"/v2/hello", nil) | 		req, _ := http.NewRequest(http.MethodGet, e+"/v2/hello", nil) | ||||||
| 		resp, err := client.Do(req) | 		resp, err := client.Do(req) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			t.Fatalf("Error sending get request: %s", err) | 			t.Fatalf("Error sending get request: %s", err) | ||||||
|  | @ -655,7 +655,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresIn(t *testing.T) { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// After we've exceeded the expiration, we should see a second token exchange.
 | 	// After we've exceeded the expiration, we should see a second token exchange.
 | ||||||
| 	req, _ := http.NewRequest("GET", e+"/v2/hello", nil) | 	req, _ := http.NewRequest(http.MethodGet, e+"/v2/hello", nil) | ||||||
| 	resp, err := client.Do(req) | 	resp, err := client.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error sending get request: %s", err) | 		t.Fatalf("Error sending get request: %s", err) | ||||||
|  | @ -686,7 +686,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresInAndIssuedAt(t *testing.T) { | ||||||
| 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	tokenMap := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  fmt.Sprintf("/token?account=%s&scope=%s&service=%s", username, url.QueryEscape(scope), service), | 				Route:  fmt.Sprintf("/token?account=%s&scope=%s&service=%s", username, url.QueryEscape(scope), service), | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -696,7 +696,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresInAndIssuedAt(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  fmt.Sprintf("/token?account=%s&scope=%s&service=%s", username, url.QueryEscape(scope), service), | 				Route:  fmt.Sprintf("/token?account=%s&scope=%s&service=%s", username, url.QueryEscape(scope), service), | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -718,7 +718,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresInAndIssuedAt(t *testing.T) { | ||||||
| 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -727,7 +727,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresInAndIssuedAt(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -736,7 +736,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresInAndIssuedAt(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -745,7 +745,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresInAndIssuedAt(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -792,7 +792,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresInAndIssuedAt(t *testing.T) { | ||||||
| 	// We shaved one increment off of the equivalent logic in TestEndpointAuthorizeTokenBasicWithExpiresIn
 | 	// We shaved one increment off of the equivalent logic in TestEndpointAuthorizeTokenBasicWithExpiresIn
 | ||||||
| 	// so this loop should have one fewer iteration.
 | 	// so this loop should have one fewer iteration.
 | ||||||
| 	for i := 0; i < 3; i++ { | 	for i := 0; i < 3; i++ { | ||||||
| 		req, _ := http.NewRequest("GET", e+"/v2/hello", nil) | 		req, _ := http.NewRequest(http.MethodGet, e+"/v2/hello", nil) | ||||||
| 		resp, err := client.Do(req) | 		resp, err := client.Do(req) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			t.Fatalf("Error sending get request: %s", err) | 			t.Fatalf("Error sending get request: %s", err) | ||||||
|  | @ -807,7 +807,7 @@ func TestEndpointAuthorizeTokenBasicWithExpiresInAndIssuedAt(t *testing.T) { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// After we've exceeded the expiration, we should see a second token exchange.
 | 	// After we've exceeded the expiration, we should see a second token exchange.
 | ||||||
| 	req, _ := http.NewRequest("GET", e+"/v2/hello", nil) | 	req, _ := http.NewRequest(http.MethodGet, e+"/v2/hello", nil) | ||||||
| 	resp, err := client.Do(req) | 	resp, err := client.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error sending get request: %s", err) | 		t.Fatalf("Error sending get request: %s", err) | ||||||
|  | @ -824,7 +824,7 @@ func TestEndpointAuthorizeBasic(t *testing.T) { | ||||||
| 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/hello", | 				Route:  "/v2/hello", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -854,7 +854,7 @@ func TestEndpointAuthorizeBasic(t *testing.T) { | ||||||
| 	transport1 := transport.NewTransport(nil, NewAuthorizer(challengeManager, NewBasicHandler(creds))) | 	transport1 := transport.NewTransport(nil, NewAuthorizer(challengeManager, NewBasicHandler(creds))) | ||||||
| 	client := &http.Client{Transport: transport1} | 	client := &http.Client{Transport: transport1} | ||||||
| 
 | 
 | ||||||
| 	req, _ := http.NewRequest("GET", e+"/v2/hello", nil) | 	req, _ := http.NewRequest(http.MethodGet, e+"/v2/hello", nil) | ||||||
| 	resp, err := client.Do(req) | 	resp, err := client.Do(req) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error sending get request: %s", err) | 		t.Fatalf("Error sending get request: %s", err) | ||||||
|  |  | ||||||
|  | @ -38,7 +38,7 @@ func (hbu *httpBlobUpload) handleErrorResponse(resp *http.Response) error { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (hbu *httpBlobUpload) ReadFrom(r io.Reader) (n int64, err error) { | func (hbu *httpBlobUpload) ReadFrom(r io.Reader) (n int64, err error) { | ||||||
| 	req, err := http.NewRequestWithContext(hbu.ctx, "PATCH", hbu.location, ioutil.NopCloser(r)) | 	req, err := http.NewRequestWithContext(hbu.ctx, http.MethodPatch, hbu.location, ioutil.NopCloser(r)) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return 0, err | 		return 0, err | ||||||
| 	} | 	} | ||||||
|  | @ -71,7 +71,7 @@ func (hbu *httpBlobUpload) ReadFrom(r io.Reader) (n int64, err error) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (hbu *httpBlobUpload) Write(p []byte) (n int, err error) { | func (hbu *httpBlobUpload) Write(p []byte) (n int, err error) { | ||||||
| 	req, err := http.NewRequestWithContext(hbu.ctx, "PATCH", hbu.location, bytes.NewReader(p)) | 	req, err := http.NewRequestWithContext(hbu.ctx, http.MethodPatch, hbu.location, bytes.NewReader(p)) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return 0, err | 		return 0, err | ||||||
| 	} | 	} | ||||||
|  | @ -119,7 +119,7 @@ func (hbu *httpBlobUpload) StartedAt() time.Time { | ||||||
| 
 | 
 | ||||||
| func (hbu *httpBlobUpload) Commit(ctx context.Context, desc distribution.Descriptor) (distribution.Descriptor, error) { | func (hbu *httpBlobUpload) Commit(ctx context.Context, desc distribution.Descriptor) (distribution.Descriptor, error) { | ||||||
| 	// TODO(dmcgowan): Check if already finished, if so just fetch
 | 	// TODO(dmcgowan): Check if already finished, if so just fetch
 | ||||||
| 	req, err := http.NewRequestWithContext(hbu.ctx, "PUT", hbu.location, nil) | 	req, err := http.NewRequestWithContext(hbu.ctx, http.MethodPut, hbu.location, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return distribution.Descriptor{}, err | 		return distribution.Descriptor{}, err | ||||||
| 	} | 	} | ||||||
|  | @ -142,7 +142,7 @@ func (hbu *httpBlobUpload) Commit(ctx context.Context, desc distribution.Descrip | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (hbu *httpBlobUpload) Cancel(ctx context.Context) error { | func (hbu *httpBlobUpload) Cancel(ctx context.Context) error { | ||||||
| 	req, err := http.NewRequestWithContext(hbu.ctx, "DELETE", hbu.location, nil) | 	req, err := http.NewRequestWithContext(hbu.ctx, http.MethodDelete, hbu.location, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -24,7 +24,7 @@ func TestUploadReadFrom(t *testing.T) { | ||||||
| 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/", | 				Route:  "/v2/", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -37,7 +37,7 @@ func TestUploadReadFrom(t *testing.T) { | ||||||
| 		// Test Valid case
 | 		// Test Valid case
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -53,7 +53,7 @@ func TestUploadReadFrom(t *testing.T) { | ||||||
| 		// Test invalid range
 | 		// Test invalid range
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -69,7 +69,7 @@ func TestUploadReadFrom(t *testing.T) { | ||||||
| 		// Test 404
 | 		// Test 404
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -80,7 +80,7 @@ func TestUploadReadFrom(t *testing.T) { | ||||||
| 		// Test 400 valid json
 | 		// Test 400 valid json
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -101,7 +101,7 @@ func TestUploadReadFrom(t *testing.T) { | ||||||
| 		// Test 400 invalid json
 | 		// Test 400 invalid json
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -113,7 +113,7 @@ func TestUploadReadFrom(t *testing.T) { | ||||||
| 		// Test 500
 | 		// Test 500
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -220,7 +220,7 @@ func TestUploadSize(t *testing.T) { | ||||||
| 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/", | 				Route:  "/v2/", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -232,7 +232,7 @@ func TestUploadSize(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  readFromLocationPath, | 				Route:  readFromLocationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -247,7 +247,7 @@ func TestUploadSize(t *testing.T) { | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  writeLocationPath, | 				Route:  writeLocationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -310,7 +310,7 @@ func TestUploadWrite(t *testing.T) { | ||||||
| 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | 	m := testutil.RequestResponseMap([]testutil.RequestResponseMapping{ | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/", | 				Route:  "/v2/", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -323,7 +323,7 @@ func TestUploadWrite(t *testing.T) { | ||||||
| 		// Test Valid case
 | 		// Test Valid case
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -339,7 +339,7 @@ func TestUploadWrite(t *testing.T) { | ||||||
| 		// Test invalid range
 | 		// Test invalid range
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -355,7 +355,7 @@ func TestUploadWrite(t *testing.T) { | ||||||
| 		// Test 404
 | 		// Test 404
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -366,7 +366,7 @@ func TestUploadWrite(t *testing.T) { | ||||||
| 		// Test 400 valid json
 | 		// Test 400 valid json
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -387,7 +387,7 @@ func TestUploadWrite(t *testing.T) { | ||||||
| 		// Test 400 invalid json
 | 		// Test 400 invalid json
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  | @ -399,7 +399,7 @@ func TestUploadWrite(t *testing.T) { | ||||||
| 		// Test 500
 | 		// Test 500
 | ||||||
| 		{ | 		{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  locationPath, | 				Route:  locationPath, | ||||||
| 				Body:   b, | 				Body:   b, | ||||||
| 			}, | 			}, | ||||||
|  |  | ||||||
|  | @ -98,7 +98,7 @@ func (r *registry) Repositories(ctx context.Context, entries []string, last stri | ||||||
| 		return 0, err | 		return 0, err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequestWithContext(ctx, "GET", u, nil) | 	req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return 0, err | 		return 0, err | ||||||
| 	} | 	} | ||||||
|  | @ -216,7 +216,7 @@ func (t *tags) All(ctx context.Context) ([]string, error) { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	for { | 	for { | ||||||
| 		req, err := http.NewRequestWithContext(ctx, "GET", listURL.String(), nil) | 		req, err := http.NewRequestWithContext(ctx, http.MethodGet, listURL.String(), nil) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return nil, err | 			return nil, err | ||||||
| 		} | 		} | ||||||
|  | @ -268,11 +268,11 @@ func descriptorFromResponse(response *http.Response) (distribution.Descriptor, e | ||||||
| 
 | 
 | ||||||
| 	digestHeader := headers.Get("Docker-Content-Digest") | 	digestHeader := headers.Get("Docker-Content-Digest") | ||||||
| 	if digestHeader == "" { | 	if digestHeader == "" { | ||||||
| 		bytes, err := ioutil.ReadAll(response.Body) | 		data, err := ioutil.ReadAll(response.Body) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return distribution.Descriptor{}, err | 			return distribution.Descriptor{}, err | ||||||
| 		} | 		} | ||||||
| 		_, desc, err := distribution.UnmarshalManifest(ctHeader, bytes) | 		_, desc, err := distribution.UnmarshalManifest(ctHeader, data) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return distribution.Descriptor{}, err | 			return distribution.Descriptor{}, err | ||||||
| 		} | 		} | ||||||
|  | @ -325,7 +325,7 @@ func (t *tags) Get(ctx context.Context, tag string) (distribution.Descriptor, er | ||||||
| 		return resp, err | 		return resp, err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	resp, err := newRequest("HEAD") | 	resp, err := newRequest(http.MethodHead) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return distribution.Descriptor{}, err | 		return distribution.Descriptor{}, err | ||||||
| 	} | 	} | ||||||
|  | @ -340,7 +340,7 @@ func (t *tags) Get(ctx context.Context, tag string) (distribution.Descriptor, er | ||||||
| 		// Issue a GET request:
 | 		// Issue a GET request:
 | ||||||
| 		//   - for data from a server that does not handle HEAD
 | 		//   - for data from a server that does not handle HEAD
 | ||||||
| 		//   - to get error details in case of a failure
 | 		//   - to get error details in case of a failure
 | ||||||
| 		resp, err = newRequest("GET") | 		resp, err = newRequest(http.MethodGet) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return distribution.Descriptor{}, err | 			return distribution.Descriptor{}, err | ||||||
| 		} | 		} | ||||||
|  | @ -371,7 +371,7 @@ func (t *tags) Untag(ctx context.Context, tag string) error { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequestWithContext(ctx, "DELETE", u, nil) | 	req, err := http.NewRequestWithContext(ctx, http.MethodDelete, u, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  | @ -405,7 +405,7 @@ func (ms *manifests) Exists(ctx context.Context, dgst digest.Digest) (bool, erro | ||||||
| 		return false, err | 		return false, err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequestWithContext(ctx, "HEAD", u, nil) | 	req, err := http.NewRequestWithContext(ctx, http.MethodHead, u, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return false, err | 		return false, err | ||||||
| 	} | 	} | ||||||
|  | @ -500,7 +500,7 @@ func (ms *manifests) Get(ctx context.Context, dgst digest.Digest, options ...dis | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequestWithContext(ctx, "GET", u, nil) | 	req, err := http.NewRequestWithContext(ctx, http.MethodGet, u, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  | @ -585,7 +585,7 @@ func (ms *manifests) Put(ctx context.Context, m distribution.Manifest, options . | ||||||
| 		return "", err | 		return "", err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	putRequest, err := http.NewRequestWithContext(ctx, "PUT", manifestURL, bytes.NewReader(p)) | 	putRequest, err := http.NewRequestWithContext(ctx, http.MethodPut, manifestURL, bytes.NewReader(p)) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return "", err | 		return "", err | ||||||
| 	} | 	} | ||||||
|  | @ -620,7 +620,7 @@ func (ms *manifests) Delete(ctx context.Context, dgst digest.Digest) error { | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 	req, err := http.NewRequestWithContext(ctx, "DELETE", u, nil) | 	req, err := http.NewRequestWithContext(ctx, http.MethodDelete, u, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  | @ -790,7 +790,7 @@ func (bs *blobs) Create(ctx context.Context, options ...distribution.BlobCreateO | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequestWithContext(ctx, "POST", u, nil) | 	req, err := http.NewRequestWithContext(ctx, http.MethodPost, u, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  | @ -873,7 +873,7 @@ func (bs *blobStatter) Stat(ctx context.Context, dgst digest.Digest) (distributi | ||||||
| 		return distribution.Descriptor{}, err | 		return distribution.Descriptor{}, err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequestWithContext(ctx, "HEAD", u, nil) | 	req, err := http.NewRequestWithContext(ctx, http.MethodHead, u, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return distribution.Descriptor{}, err | 		return distribution.Descriptor{}, err | ||||||
| 	} | 	} | ||||||
|  | @ -929,7 +929,7 @@ func (bs *blobStatter) Clear(ctx context.Context, dgst digest.Digest) error { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequestWithContext(ctx, "DELETE", blobURL, nil) | 	req, err := http.NewRequestWithContext(ctx, http.MethodDelete, blobURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -50,7 +50,7 @@ func newRandomBlob(size int) (digest.Digest, []byte) { | ||||||
| func addTestFetch(repo string, dgst digest.Digest, content []byte, m *testutil.RequestResponseMap) { | func addTestFetch(repo string, dgst digest.Digest, content []byte, m *testutil.RequestResponseMap) { | ||||||
| 	*m = append(*m, testutil.RequestResponseMapping{ | 	*m = append(*m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "GET", | 			Method: http.MethodGet, | ||||||
| 			Route:  "/v2/" + repo + "/blobs/" + dgst.String(), | 			Route:  "/v2/" + repo + "/blobs/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -66,7 +66,7 @@ func addTestFetch(repo string, dgst digest.Digest, content []byte, m *testutil.R | ||||||
| 
 | 
 | ||||||
| 	*m = append(*m, testutil.RequestResponseMapping{ | 	*m = append(*m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "HEAD", | 			Method: http.MethodHead, | ||||||
| 			Route:  "/v2/" + repo + "/blobs/" + dgst.String(), | 			Route:  "/v2/" + repo + "/blobs/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -91,7 +91,7 @@ func addTestCatalog(route string, content []byte, link string, m *testutil.Reque | ||||||
| 
 | 
 | ||||||
| 	*m = append(*m, testutil.RequestResponseMapping{ | 	*m = append(*m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "GET", | 			Method: http.MethodGet, | ||||||
| 			Route:  route, | 			Route:  route, | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -119,7 +119,7 @@ func TestBlobServeBlob(t *testing.T) { | ||||||
| 	l := r.Blobs(ctx) | 	l := r.Blobs(ctx) | ||||||
| 
 | 
 | ||||||
| 	resp := httptest.NewRecorder() | 	resp := httptest.NewRecorder() | ||||||
| 	req := httptest.NewRequest("GET", "/", nil) | 	req := httptest.NewRequest(http.MethodGet, "/", nil) | ||||||
| 
 | 
 | ||||||
| 	err = l.ServeBlob(ctx, resp, req, dgst) | 	err = l.ServeBlob(ctx, resp, req, dgst) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  | @ -168,7 +168,7 @@ func TestBlobServeBlobHEAD(t *testing.T) { | ||||||
| 	l := r.Blobs(ctx) | 	l := r.Blobs(ctx) | ||||||
| 
 | 
 | ||||||
| 	resp := httptest.NewRecorder() | 	resp := httptest.NewRecorder() | ||||||
| 	req := httptest.NewRequest("HEAD", "/", nil) | 	req := httptest.NewRequest(http.MethodHead, "/", nil) | ||||||
| 
 | 
 | ||||||
| 	err = l.ServeBlob(ctx, resp, req, dgst) | 	err = l.ServeBlob(ctx, resp, req, dgst) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  | @ -207,7 +207,7 @@ func TestBlobResume(t *testing.T) { | ||||||
| 	repo, _ := reference.WithName("test.example.com/repo1") | 	repo, _ := reference.WithName("test.example.com/repo1") | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "PATCH", | 			Method: http.MethodPatch, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + id, | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + id, | ||||||
| 			Body:   b1, | 			Body:   b1, | ||||||
| 		}, | 		}, | ||||||
|  | @ -221,7 +221,7 @@ func TestBlobResume(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "PUT", | 			Method: http.MethodPut, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + id, | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + id, | ||||||
| 			QueryParams: map[string][]string{ | 			QueryParams: map[string][]string{ | ||||||
| 				"digest": {dgst.String()}, | 				"digest": {dgst.String()}, | ||||||
|  | @ -237,7 +237,7 @@ func TestBlobResume(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "HEAD", | 			Method: http.MethodHead, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -295,7 +295,7 @@ func TestBlobDelete(t *testing.T) { | ||||||
| 	repo, _ := reference.WithName("test.example.com/repo1") | 	repo, _ := reference.WithName("test.example.com/repo1") | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "DELETE", | 			Method: http.MethodDelete, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -356,7 +356,7 @@ func TestBlobExistsNoContentLength(t *testing.T) { | ||||||
| 	dgst, content := newRandomBlob(1024) | 	dgst, content := newRandomBlob(1024) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "GET", | 			Method: http.MethodGet, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -371,7 +371,7 @@ func TestBlobExistsNoContentLength(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "HEAD", | 			Method: http.MethodHead, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -447,7 +447,7 @@ func TestBlobUploadChunked(t *testing.T) { | ||||||
| 	uuids := []string{uuid.Generate().String()} | 	uuids := []string{uuid.Generate().String()} | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "POST", | 			Method: http.MethodPost, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -466,7 +466,7 @@ func TestBlobUploadChunked(t *testing.T) { | ||||||
| 		newOffset := offset + len(chunk) | 		newOffset := offset + len(chunk) | ||||||
| 		m = append(m, testutil.RequestResponseMapping{ | 		m = append(m, testutil.RequestResponseMapping{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "PATCH", | 				Method: http.MethodPatch, | ||||||
| 				Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uuids[i], | 				Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uuids[i], | ||||||
| 				Body:   chunk, | 				Body:   chunk, | ||||||
| 			}, | 			}, | ||||||
|  | @ -484,7 +484,7 @@ func TestBlobUploadChunked(t *testing.T) { | ||||||
| 	} | 	} | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "PUT", | 			Method: http.MethodPut, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uuids[len(uuids)-1], | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uuids[len(uuids)-1], | ||||||
| 			QueryParams: map[string][]string{ | 			QueryParams: map[string][]string{ | ||||||
| 				"digest": {dgst.String()}, | 				"digest": {dgst.String()}, | ||||||
|  | @ -501,7 +501,7 @@ func TestBlobUploadChunked(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "HEAD", | 			Method: http.MethodHead, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -562,7 +562,7 @@ func TestBlobUploadMonolithic(t *testing.T) { | ||||||
| 	uploadID := uuid.Generate().String() | 	uploadID := uuid.Generate().String() | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "POST", | 			Method: http.MethodPost, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -577,7 +577,7 @@ func TestBlobUploadMonolithic(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "PATCH", | 			Method: http.MethodPatch, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uploadID, | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uploadID, | ||||||
| 			Body:   b1, | 			Body:   b1, | ||||||
| 		}, | 		}, | ||||||
|  | @ -594,7 +594,7 @@ func TestBlobUploadMonolithic(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "PUT", | 			Method: http.MethodPut, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uploadID, | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uploadID, | ||||||
| 			QueryParams: map[string][]string{ | 			QueryParams: map[string][]string{ | ||||||
| 				"digest": {dgst.String()}, | 				"digest": {dgst.String()}, | ||||||
|  | @ -611,7 +611,7 @@ func TestBlobUploadMonolithic(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "HEAD", | 			Method: http.MethodHead, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -670,7 +670,7 @@ func TestBlobUploadMonolithicDockerUploadUUIDFromURL(t *testing.T) { | ||||||
| 	uploadID := uuid.Generate().String() | 	uploadID := uuid.Generate().String() | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "POST", | 			Method: http.MethodPost, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -684,7 +684,7 @@ func TestBlobUploadMonolithicDockerUploadUUIDFromURL(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "PATCH", | 			Method: http.MethodPatch, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uploadID, | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uploadID, | ||||||
| 			Body:   b1, | 			Body:   b1, | ||||||
| 		}, | 		}, | ||||||
|  | @ -700,7 +700,7 @@ func TestBlobUploadMonolithicDockerUploadUUIDFromURL(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "PUT", | 			Method: http.MethodPut, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uploadID, | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/" + uploadID, | ||||||
| 			QueryParams: map[string][]string{ | 			QueryParams: map[string][]string{ | ||||||
| 				"digest": {dgst.String()}, | 				"digest": {dgst.String()}, | ||||||
|  | @ -717,7 +717,7 @@ func TestBlobUploadMonolithicDockerUploadUUIDFromURL(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "HEAD", | 			Method: http.MethodHead, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -775,7 +775,7 @@ func TestBlobUploadMonolithicNoDockerUploadUUID(t *testing.T) { | ||||||
| 	repo, _ := reference.WithName("test.example.com/uploadrepo") | 	repo, _ := reference.WithName("test.example.com/uploadrepo") | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "POST", | 			Method: http.MethodPost, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -789,7 +789,7 @@ func TestBlobUploadMonolithicNoDockerUploadUUID(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "PATCH", | 			Method: http.MethodPatch, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | ||||||
| 			Body:   b1, | 			Body:   b1, | ||||||
| 		}, | 		}, | ||||||
|  | @ -805,7 +805,7 @@ func TestBlobUploadMonolithicNoDockerUploadUUID(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "PUT", | 			Method: http.MethodPut, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | 			Route:  "/v2/" + repo.Name() + "/blobs/uploads/", | ||||||
| 			QueryParams: map[string][]string{ | 			QueryParams: map[string][]string{ | ||||||
| 				"digest": {dgst.String()}, | 				"digest": {dgst.String()}, | ||||||
|  | @ -822,7 +822,7 @@ func TestBlobUploadMonolithicNoDockerUploadUUID(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "HEAD", | 			Method: http.MethodHead, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -865,7 +865,7 @@ func TestBlobMount(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method:      "POST", | 			Method:      http.MethodPost, | ||||||
| 			Route:       "/v2/" + repo.Name() + "/blobs/uploads/", | 			Route:       "/v2/" + repo.Name() + "/blobs/uploads/", | ||||||
| 			QueryParams: map[string][]string{"from": {sourceRepo.Name()}, "mount": {dgst.String()}}, | 			QueryParams: map[string][]string{"from": {sourceRepo.Name()}, "mount": {dgst.String()}}, | ||||||
| 		}, | 		}, | ||||||
|  | @ -880,7 +880,7 @@ func TestBlobMount(t *testing.T) { | ||||||
| 	}) | 	}) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "HEAD", | 			Method: http.MethodHead, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | 			Route:  "/v2/" + repo.Name() + "/blobs/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -958,7 +958,7 @@ func newRandomSchemaV1Manifest(name reference.Named, tag string, blobCount int) | ||||||
| func addTestManifestWithEtag(repo reference.Named, reference string, content []byte, m *testutil.RequestResponseMap, dgst string) { | func addTestManifestWithEtag(repo reference.Named, reference string, content []byte, m *testutil.RequestResponseMap, dgst string) { | ||||||
| 	actualDigest := digest.FromBytes(content) | 	actualDigest := digest.FromBytes(content) | ||||||
| 	getReqWithEtag := testutil.Request{ | 	getReqWithEtag := testutil.Request{ | ||||||
| 		Method: "GET", | 		Method: http.MethodGet, | ||||||
| 		Route:  "/v2/" + repo.Name() + "/manifests/" + reference, | 		Route:  "/v2/" + repo.Name() + "/manifests/" + reference, | ||||||
| 		Headers: http.Header(map[string][]string{ | 		Headers: http.Header(map[string][]string{ | ||||||
| 			"If-None-Match": {fmt.Sprintf(`"%s"`, dgst)}, | 			"If-None-Match": {fmt.Sprintf(`"%s"`, dgst)}, | ||||||
|  | @ -1002,7 +1002,7 @@ func contentDigestString(mediatype string, content []byte) string { | ||||||
| func addTestManifest(repo reference.Named, reference string, mediatype string, content []byte, m *testutil.RequestResponseMap) { | func addTestManifest(repo reference.Named, reference string, mediatype string, content []byte, m *testutil.RequestResponseMap) { | ||||||
| 	*m = append(*m, testutil.RequestResponseMapping{ | 	*m = append(*m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "GET", | 			Method: http.MethodGet, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/manifests/" + reference, | 			Route:  "/v2/" + repo.Name() + "/manifests/" + reference, | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -1018,7 +1018,7 @@ func addTestManifest(repo reference.Named, reference string, mediatype string, c | ||||||
| 	}) | 	}) | ||||||
| 	*m = append(*m, testutil.RequestResponseMapping{ | 	*m = append(*m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "HEAD", | 			Method: http.MethodHead, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/manifests/" + reference, | 			Route:  "/v2/" + repo.Name() + "/manifests/" + reference, | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -1036,7 +1036,7 @@ func addTestManifest(repo reference.Named, reference string, mediatype string, c | ||||||
| func addTestManifestWithoutDigestHeader(repo reference.Named, reference string, mediatype string, content []byte, m *testutil.RequestResponseMap) { | func addTestManifestWithoutDigestHeader(repo reference.Named, reference string, mediatype string, content []byte, m *testutil.RequestResponseMap) { | ||||||
| 	*m = append(*m, testutil.RequestResponseMapping{ | 	*m = append(*m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "GET", | 			Method: http.MethodGet, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/manifests/" + reference, | 			Route:  "/v2/" + repo.Name() + "/manifests/" + reference, | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -1051,7 +1051,7 @@ func addTestManifestWithoutDigestHeader(repo reference.Named, reference string, | ||||||
| 	}) | 	}) | ||||||
| 	*m = append(*m, testutil.RequestResponseMapping{ | 	*m = append(*m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "HEAD", | 			Method: http.MethodHead, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/manifests/" + reference, | 			Route:  "/v2/" + repo.Name() + "/manifests/" + reference, | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -1265,7 +1265,7 @@ func TestManifestDelete(t *testing.T) { | ||||||
| 	var m testutil.RequestResponseMap | 	var m testutil.RequestResponseMap | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "DELETE", | 			Method: http.MethodDelete, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/manifests/" + dgst1.String(), | 			Route:  "/v2/" + repo.Name() + "/manifests/" + dgst1.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -1310,7 +1310,7 @@ func TestManifestPut(t *testing.T) { | ||||||
| 	var m testutil.RequestResponseMap | 	var m testutil.RequestResponseMap | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "PUT", | 			Method: http.MethodPut, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/manifests/other", | 			Route:  "/v2/" + repo.Name() + "/manifests/other", | ||||||
| 			Body:   payload, | 			Body:   payload, | ||||||
| 		}, | 		}, | ||||||
|  | @ -1326,7 +1326,7 @@ func TestManifestPut(t *testing.T) { | ||||||
| 	putDgst := digest.FromBytes(m1.Canonical) | 	putDgst := digest.FromBytes(m1.Canonical) | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "PUT", | 			Method: http.MethodPut, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/manifests/" + putDgst.String(), | 			Route:  "/v2/" + repo.Name() + "/manifests/" + putDgst.String(), | ||||||
| 			Body:   payload, | 			Body:   payload, | ||||||
| 		}, | 		}, | ||||||
|  | @ -1379,7 +1379,7 @@ func TestManifestTags(t *testing.T) { | ||||||
| 	for i := 0; i < 3; i++ { | 	for i := 0; i < 3; i++ { | ||||||
| 		m = append(m, testutil.RequestResponseMapping{ | 		m = append(m, testutil.RequestResponseMapping{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method: "GET", | 				Method: http.MethodGet, | ||||||
| 				Route:  "/v2/" + repo.Name() + "/tags/list", | 				Route:  "/v2/" + repo.Name() + "/tags/list", | ||||||
| 			}, | 			}, | ||||||
| 			Response: testutil.Response{ | 			Response: testutil.Response{ | ||||||
|  | @ -1433,7 +1433,7 @@ func TestTagDelete(t *testing.T) { | ||||||
| 	var m testutil.RequestResponseMap | 	var m testutil.RequestResponseMap | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "DELETE", | 			Method: http.MethodDelete, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/manifests/" + tag, | 			Route:  "/v2/" + repo.Name() + "/manifests/" + tag, | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -1474,7 +1474,7 @@ func TestObtainsErrorForMissingTag(t *testing.T) { | ||||||
| 	} | 	} | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "GET", | 			Method: http.MethodGet, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/manifests/1.0.0", | 			Route:  "/v2/" + repo.Name() + "/manifests/1.0.0", | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  | @ -1578,7 +1578,7 @@ func TestManifestTagsPaginated(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 		m = append(m, testutil.RequestResponseMapping{ | 		m = append(m, testutil.RequestResponseMapping{ | ||||||
| 			Request: testutil.Request{ | 			Request: testutil.Request{ | ||||||
| 				Method:      "GET", | 				Method:      http.MethodGet, | ||||||
| 				Route:       "/v2/" + repo.Name() + "/tags/list", | 				Route:       "/v2/" + repo.Name() + "/tags/list", | ||||||
| 				QueryParams: queryParams, | 				QueryParams: queryParams, | ||||||
| 			}, | 			}, | ||||||
|  | @ -1628,7 +1628,7 @@ func TestManifestUnauthorized(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	m = append(m, testutil.RequestResponseMapping{ | 	m = append(m, testutil.RequestResponseMapping{ | ||||||
| 		Request: testutil.Request{ | 		Request: testutil.Request{ | ||||||
| 			Method: "GET", | 			Method: http.MethodGet, | ||||||
| 			Route:  "/v2/" + repo.Name() + "/manifests/" + dgst.String(), | 			Route:  "/v2/" + repo.Name() + "/manifests/" + dgst.String(), | ||||||
| 		}, | 		}, | ||||||
| 		Response: testutil.Response{ | 		Response: testutil.Response{ | ||||||
|  |  | ||||||
|  | @ -171,7 +171,7 @@ func (hrs *httpReadSeeker) reader() (io.Reader, error) { | ||||||
| 		return hrs.rc, nil | 		return hrs.rc, nil | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequestWithContext(hrs.ctx, "GET", hrs.url, nil) | 	req, err := http.NewRequestWithContext(hrs.ctx, http.MethodGet, hrs.url, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -613,7 +613,7 @@ func testBlobAPI(t *testing.T, env *testEnv, args blobArgs) *testEnv { | ||||||
| 		"Docker-Upload-UUID": []string{uploadUUID}, | 		"Docker-Upload-UUID": []string{uploadUUID}, | ||||||
| 	}) | 	}) | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequest("DELETE", uploadURLBase, nil) | 	req, err := http.NewRequest(http.MethodDelete, uploadURLBase, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("unexpected error creating delete request: %v", err) | 		t.Fatalf("unexpected error creating delete request: %v", err) | ||||||
| 	} | 	} | ||||||
|  | @ -786,7 +786,7 @@ func testBlobAPI(t *testing.T, env *testEnv, args blobArgs) *testEnv { | ||||||
| 
 | 
 | ||||||
| 	// Matching etag, gives 304
 | 	// Matching etag, gives 304
 | ||||||
| 	etag := resp.Header.Get("Etag") | 	etag := resp.Header.Get("Etag") | ||||||
| 	req, err = http.NewRequest("GET", layerURL, nil) | 	req, err = http.NewRequest(http.MethodGet, layerURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -800,7 +800,7 @@ func testBlobAPI(t *testing.T, env *testEnv, args blobArgs) *testEnv { | ||||||
| 	checkResponse(t, "fetching layer with etag", resp, http.StatusNotModified) | 	checkResponse(t, "fetching layer with etag", resp, http.StatusNotModified) | ||||||
| 
 | 
 | ||||||
| 	// Non-matching etag, gives 200
 | 	// Non-matching etag, gives 200
 | ||||||
| 	req, err = http.NewRequest("GET", layerURL, nil) | 	req, err = http.NewRequest(http.MethodGet, layerURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -972,7 +972,7 @@ func TestStartPushReadOnly(t *testing.T) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func httpDelete(url string) (*http.Response, error) { | func httpDelete(url string) (*http.Response, error) { | ||||||
| 	req, err := http.NewRequest("DELETE", url, nil) | 	req, err := http.NewRequest(http.MethodDelete, url, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  | @ -1490,7 +1490,7 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name | ||||||
| 
 | 
 | ||||||
| 	// Get by name with etag, gives 304
 | 	// Get by name with etag, gives 304
 | ||||||
| 	etag := resp.Header.Get("Etag") | 	etag := resp.Header.Get("Etag") | ||||||
| 	req, err := http.NewRequest("GET", manifestURL, nil) | 	req, err := http.NewRequest(http.MethodGet, manifestURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -1503,7 +1503,7 @@ func testManifestAPISchema1(t *testing.T, env *testEnv, imageName reference.Name | ||||||
| 	checkResponse(t, "fetching manifest by name with etag", resp, http.StatusNotModified) | 	checkResponse(t, "fetching manifest by name with etag", resp, http.StatusNotModified) | ||||||
| 
 | 
 | ||||||
| 	// Get by digest with etag, gives 304
 | 	// Get by digest with etag, gives 304
 | ||||||
| 	req, err = http.NewRequest("GET", manifestDigestURL, nil) | 	req, err = http.NewRequest(http.MethodGet, manifestDigestURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -1732,7 +1732,7 @@ func testManifestAPISchema2(t *testing.T, env *testEnv, imageName reference.Name | ||||||
| 
 | 
 | ||||||
| 	// ------------------
 | 	// ------------------
 | ||||||
| 	// Fetch by tag name
 | 	// Fetch by tag name
 | ||||||
| 	req, err := http.NewRequest("GET", manifestURL, nil) | 	req, err := http.NewRequest(http.MethodGet, manifestURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -1767,7 +1767,7 @@ func testManifestAPISchema2(t *testing.T, env *testEnv, imageName reference.Name | ||||||
| 
 | 
 | ||||||
| 	// ---------------
 | 	// ---------------
 | ||||||
| 	// Fetch by digest
 | 	// Fetch by digest
 | ||||||
| 	req, err = http.NewRequest("GET", manifestDigestURL, nil) | 	req, err = http.NewRequest(http.MethodGet, manifestDigestURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -1799,7 +1799,7 @@ func testManifestAPISchema2(t *testing.T, env *testEnv, imageName reference.Name | ||||||
| 
 | 
 | ||||||
| 	// Get by name with etag, gives 304
 | 	// Get by name with etag, gives 304
 | ||||||
| 	etag := resp.Header.Get("Etag") | 	etag := resp.Header.Get("Etag") | ||||||
| 	req, err = http.NewRequest("GET", manifestURL, nil) | 	req, err = http.NewRequest(http.MethodGet, manifestURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -1812,7 +1812,7 @@ func testManifestAPISchema2(t *testing.T, env *testEnv, imageName reference.Name | ||||||
| 	checkResponse(t, "fetching manifest by name with etag", resp, http.StatusNotModified) | 	checkResponse(t, "fetching manifest by name with etag", resp, http.StatusNotModified) | ||||||
| 
 | 
 | ||||||
| 	// Get by digest with etag, gives 304
 | 	// Get by digest with etag, gives 304
 | ||||||
| 	req, err = http.NewRequest("GET", manifestDigestURL, nil) | 	req, err = http.NewRequest(http.MethodGet, manifestDigestURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -1992,7 +1992,7 @@ func testManifestAPIManifestList(t *testing.T, env *testEnv, args manifestArgs) | ||||||
| 
 | 
 | ||||||
| 	// ------------------
 | 	// ------------------
 | ||||||
| 	// Fetch by tag name
 | 	// Fetch by tag name
 | ||||||
| 	req, err := http.NewRequest("GET", manifestURL, nil) | 	req, err := http.NewRequest(http.MethodGet, manifestURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -2029,7 +2029,7 @@ func testManifestAPIManifestList(t *testing.T, env *testEnv, args manifestArgs) | ||||||
| 
 | 
 | ||||||
| 	// ---------------
 | 	// ---------------
 | ||||||
| 	// Fetch by digest
 | 	// Fetch by digest
 | ||||||
| 	req, err = http.NewRequest("GET", manifestDigestURL, nil) | 	req, err = http.NewRequest(http.MethodGet, manifestDigestURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -2061,7 +2061,7 @@ func testManifestAPIManifestList(t *testing.T, env *testEnv, args manifestArgs) | ||||||
| 
 | 
 | ||||||
| 	// Get by name with etag, gives 304
 | 	// Get by name with etag, gives 304
 | ||||||
| 	etag := resp.Header.Get("Etag") | 	etag := resp.Header.Get("Etag") | ||||||
| 	req, err = http.NewRequest("GET", manifestURL, nil) | 	req, err = http.NewRequest(http.MethodGet, manifestURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -2074,7 +2074,7 @@ func testManifestAPIManifestList(t *testing.T, env *testEnv, args manifestArgs) | ||||||
| 	checkResponse(t, "fetching manifest by name with etag", resp, http.StatusNotModified) | 	checkResponse(t, "fetching manifest by name with etag", resp, http.StatusNotModified) | ||||||
| 
 | 
 | ||||||
| 	// Get by digest with etag, gives 304
 | 	// Get by digest with etag, gives 304
 | ||||||
| 	req, err = http.NewRequest("GET", manifestDigestURL, nil) | 	req, err = http.NewRequest(http.MethodGet, manifestDigestURL, nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("Error constructing request: %s", err) | 		t.Fatalf("Error constructing request: %s", err) | ||||||
| 	} | 	} | ||||||
|  | @ -2383,7 +2383,7 @@ func putManifest(t *testing.T, msg, url, contentType string, v interface{}) *htt | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequest("PUT", url, bytes.NewReader(body)) | 	req, err := http.NewRequest(http.MethodPut, url, bytes.NewReader(body)) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("error creating request for %s: %v", msg, err) | 		t.Fatalf("error creating request for %s: %v", msg, err) | ||||||
| 	} | 	} | ||||||
|  | @ -2457,7 +2457,7 @@ func doPushLayer(t *testing.T, ub *v2.URLBuilder, name reference.Named, dgst dig | ||||||
| 	uploadURL := u.String() | 	uploadURL := u.String() | ||||||
| 
 | 
 | ||||||
| 	// Just do a monolithic upload
 | 	// Just do a monolithic upload
 | ||||||
| 	req, err := http.NewRequest("PUT", uploadURL, body) | 	req, err := http.NewRequest(http.MethodPut, uploadURL, body) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("unexpected error creating new request: %v", err) | 		t.Fatalf("unexpected error creating new request: %v", err) | ||||||
| 	} | 	} | ||||||
|  | @ -2560,7 +2560,7 @@ func doPushChunk(t *testing.T, uploadURLBase string, body io.Reader, options chu | ||||||
| 
 | 
 | ||||||
| 	uploadURL := u.String() | 	uploadURL := u.String() | ||||||
| 
 | 
 | ||||||
| 	req, err := http.NewRequest("PATCH", uploadURL, body) | 	req, err := http.NewRequest(http.MethodPatch, uploadURL, body) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("unexpected error creating new request: %v", err) | 		t.Fatalf("unexpected error creating new request: %v", err) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -838,7 +838,7 @@ func (app *App) authorized(w http.ResponseWriter, r *http.Request, context *Cont | ||||||
| 		if fromRepo := r.FormValue("from"); fromRepo != "" { | 		if fromRepo := r.FormValue("from"); fromRepo != "" { | ||||||
| 			// mounting a blob from one repository to another requires pull (GET)
 | 			// mounting a blob from one repository to another requires pull (GET)
 | ||||||
| 			// access to the source repository.
 | 			// access to the source repository.
 | ||||||
| 			accessRecords = appendAccessRecords(accessRecords, "GET", fromRepo) | 			accessRecords = appendAccessRecords(accessRecords, http.MethodGet, fromRepo) | ||||||
| 		} | 		} | ||||||
| 	} else { | 	} else { | ||||||
| 		// Only allow the name not to be set on the base route.
 | 		// Only allow the name not to be set on the base route.
 | ||||||
|  | @ -927,13 +927,13 @@ func appendAccessRecords(records []auth.Access, method string, repo string) []au | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	switch method { | 	switch method { | ||||||
| 	case "GET", "HEAD": | 	case http.MethodGet, http.MethodHead: | ||||||
| 		records = append(records, | 		records = append(records, | ||||||
| 			auth.Access{ | 			auth.Access{ | ||||||
| 				Resource: resource, | 				Resource: resource, | ||||||
| 				Action:   "pull", | 				Action:   "pull", | ||||||
| 			}) | 			}) | ||||||
| 	case "POST", "PUT", "PATCH": | 	case http.MethodPost, http.MethodPut, http.MethodPatch: | ||||||
| 		records = append(records, | 		records = append(records, | ||||||
| 			auth.Access{ | 			auth.Access{ | ||||||
| 				Resource: resource, | 				Resource: resource, | ||||||
|  | @ -943,7 +943,7 @@ func appendAccessRecords(records []auth.Access, method string, repo string) []au | ||||||
| 				Resource: resource, | 				Resource: resource, | ||||||
| 				Action:   "push", | 				Action:   "push", | ||||||
| 			}) | 			}) | ||||||
| 	case "DELETE": | 	case http.MethodDelete: | ||||||
| 		records = append(records, | 		records = append(records, | ||||||
| 			auth.Access{ | 			auth.Access{ | ||||||
| 				Resource: resource, | 				Resource: resource, | ||||||
|  |  | ||||||
|  | @ -235,42 +235,42 @@ func TestAppendAccessRecords(t *testing.T) { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	records := []auth.Access{} | 	records := []auth.Access{} | ||||||
| 	result := appendAccessRecords(records, "GET", repo) | 	result := appendAccessRecords(records, http.MethodGet, repo) | ||||||
| 	expectedResult := []auth.Access{expectedPullRecord} | 	expectedResult := []auth.Access{expectedPullRecord} | ||||||
| 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | ||||||
| 		t.Fatalf("Actual access record differs from expected") | 		t.Fatalf("Actual access record differs from expected") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	records = []auth.Access{} | 	records = []auth.Access{} | ||||||
| 	result = appendAccessRecords(records, "HEAD", repo) | 	result = appendAccessRecords(records, http.MethodHead, repo) | ||||||
| 	expectedResult = []auth.Access{expectedPullRecord} | 	expectedResult = []auth.Access{expectedPullRecord} | ||||||
| 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | ||||||
| 		t.Fatalf("Actual access record differs from expected") | 		t.Fatalf("Actual access record differs from expected") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	records = []auth.Access{} | 	records = []auth.Access{} | ||||||
| 	result = appendAccessRecords(records, "POST", repo) | 	result = appendAccessRecords(records, http.MethodPost, repo) | ||||||
| 	expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord} | 	expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord} | ||||||
| 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | ||||||
| 		t.Fatalf("Actual access record differs from expected") | 		t.Fatalf("Actual access record differs from expected") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	records = []auth.Access{} | 	records = []auth.Access{} | ||||||
| 	result = appendAccessRecords(records, "PUT", repo) | 	result = appendAccessRecords(records, http.MethodPut, repo) | ||||||
| 	expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord} | 	expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord} | ||||||
| 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | ||||||
| 		t.Fatalf("Actual access record differs from expected") | 		t.Fatalf("Actual access record differs from expected") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	records = []auth.Access{} | 	records = []auth.Access{} | ||||||
| 	result = appendAccessRecords(records, "PATCH", repo) | 	result = appendAccessRecords(records, http.MethodPatch, repo) | ||||||
| 	expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord} | 	expectedResult = []auth.Access{expectedPullRecord, expectedPushRecord} | ||||||
| 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | ||||||
| 		t.Fatalf("Actual access record differs from expected") | 		t.Fatalf("Actual access record differs from expected") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	records = []auth.Access{} | 	records = []auth.Access{} | ||||||
| 	result = appendAccessRecords(records, "DELETE", repo) | 	result = appendAccessRecords(records, http.MethodDelete, repo) | ||||||
| 	expectedResult = []auth.Access{expectedDeleteRecord} | 	expectedResult = []auth.Access{expectedDeleteRecord} | ||||||
| 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | 	if ok := reflect.DeepEqual(result, expectedResult); !ok { | ||||||
| 		t.Fatalf("Actual access record differs from expected") | 		t.Fatalf("Actual access record differs from expected") | ||||||
|  |  | ||||||
|  | @ -33,12 +33,12 @@ func blobDispatcher(ctx *Context, r *http.Request) http.Handler { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	mhandler := handlers.MethodHandler{ | 	mhandler := handlers.MethodHandler{ | ||||||
| 		"GET":  http.HandlerFunc(blobHandler.GetBlob), | 		http.MethodGet:  http.HandlerFunc(blobHandler.GetBlob), | ||||||
| 		"HEAD": http.HandlerFunc(blobHandler.GetBlob), | 		http.MethodHead: http.HandlerFunc(blobHandler.GetBlob), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if !ctx.readOnly { | 	if !ctx.readOnly { | ||||||
| 		mhandler["DELETE"] = http.HandlerFunc(blobHandler.DeleteBlob) | 		mhandler[http.MethodDelete] = http.HandlerFunc(blobHandler.DeleteBlob) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return mhandler | 	return mhandler | ||||||
|  |  | ||||||
|  | @ -25,15 +25,15 @@ func blobUploadDispatcher(ctx *Context, r *http.Request) http.Handler { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	handler := handlers.MethodHandler{ | 	handler := handlers.MethodHandler{ | ||||||
| 		"GET":  http.HandlerFunc(buh.GetUploadStatus), | 		http.MethodGet:  http.HandlerFunc(buh.GetUploadStatus), | ||||||
| 		"HEAD": http.HandlerFunc(buh.GetUploadStatus), | 		http.MethodHead: http.HandlerFunc(buh.GetUploadStatus), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if !ctx.readOnly { | 	if !ctx.readOnly { | ||||||
| 		handler["POST"] = http.HandlerFunc(buh.StartBlobUpload) | 		handler[http.MethodPost] = http.HandlerFunc(buh.StartBlobUpload) | ||||||
| 		handler["PATCH"] = http.HandlerFunc(buh.PatchBlobData) | 		handler[http.MethodPatch] = http.HandlerFunc(buh.PatchBlobData) | ||||||
| 		handler["PUT"] = http.HandlerFunc(buh.PutBlobUploadComplete) | 		handler[http.MethodPut] = http.HandlerFunc(buh.PutBlobUploadComplete) | ||||||
| 		handler["DELETE"] = http.HandlerFunc(buh.CancelBlobUpload) | 		handler[http.MethodDelete] = http.HandlerFunc(buh.CancelBlobUpload) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if buh.UUID != "" { | 	if buh.UUID != "" { | ||||||
|  |  | ||||||
|  | @ -21,7 +21,7 @@ func catalogDispatcher(ctx *Context, r *http.Request) http.Handler { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return handlers.MethodHandler{ | 	return handlers.MethodHandler{ | ||||||
| 		"GET": http.HandlerFunc(catalogHandler.GetCatalog), | 		http.MethodGet: http.HandlerFunc(catalogHandler.GetCatalog), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -137,7 +137,7 @@ func TestHTTPHealthCheck(t *testing.T) { | ||||||
| 	stopFailing := make(chan struct{}) | 	stopFailing := make(chan struct{}) | ||||||
| 
 | 
 | ||||||
| 	checkedServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | 	checkedServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||||||
| 		if r.Method != "HEAD" { | 		if r.Method != http.MethodHead { | ||||||
| 			t.Fatalf("expected HEAD request, got %s", r.Method) | 			t.Fatalf("expected HEAD request, got %s", r.Method) | ||||||
| 		} | 		} | ||||||
| 		select { | 		select { | ||||||
|  |  | ||||||
|  | @ -49,23 +49,23 @@ func manifestDispatcher(ctx *Context, r *http.Request) http.Handler { | ||||||
| 	manifestHandler := &manifestHandler{ | 	manifestHandler := &manifestHandler{ | ||||||
| 		Context: ctx, | 		Context: ctx, | ||||||
| 	} | 	} | ||||||
| 	reference := getReference(ctx) | 	ref := getReference(ctx) | ||||||
| 	dgst, err := digest.Parse(reference) | 	dgst, err := digest.Parse(ref) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		// We just have a tag
 | 		// We just have a tag
 | ||||||
| 		manifestHandler.Tag = reference | 		manifestHandler.Tag = ref | ||||||
| 	} else { | 	} else { | ||||||
| 		manifestHandler.Digest = dgst | 		manifestHandler.Digest = dgst | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	mhandler := handlers.MethodHandler{ | 	mhandler := handlers.MethodHandler{ | ||||||
| 		"GET":  http.HandlerFunc(manifestHandler.GetManifest), | 		http.MethodGet:  http.HandlerFunc(manifestHandler.GetManifest), | ||||||
| 		"HEAD": http.HandlerFunc(manifestHandler.GetManifest), | 		http.MethodHead: http.HandlerFunc(manifestHandler.GetManifest), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if !ctx.readOnly { | 	if !ctx.readOnly { | ||||||
| 		mhandler["PUT"] = http.HandlerFunc(manifestHandler.PutManifest) | 		mhandler[http.MethodPut] = http.HandlerFunc(manifestHandler.PutManifest) | ||||||
| 		mhandler["DELETE"] = http.HandlerFunc(manifestHandler.DeleteManifest) | 		mhandler[http.MethodDelete] = http.HandlerFunc(manifestHandler.DeleteManifest) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return mhandler | 	return mhandler | ||||||
|  |  | ||||||
|  | @ -19,7 +19,7 @@ func tagsDispatcher(ctx *Context, r *http.Request) http.Handler { | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return handlers.MethodHandler{ | 	return handlers.MethodHandler{ | ||||||
| 		"GET": http.HandlerFunc(tagsHandler.GetTags), | 		http.MethodGet: http.HandlerFunc(tagsHandler.GetTags), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -337,7 +337,7 @@ func testProxyStoreServe(t *testing.T, te *testEnv, numClients int) { | ||||||
| 			defer wg.Done() | 			defer wg.Done() | ||||||
| 			for _, remoteBlob := range te.inRemote { | 			for _, remoteBlob := range te.inRemote { | ||||||
| 				w := httptest.NewRecorder() | 				w := httptest.NewRecorder() | ||||||
| 				r, err := http.NewRequest("GET", "", nil) | 				r, err := http.NewRequest(http.MethodGet, "", nil) | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
| 					t.Error(err) | 					t.Error(err) | ||||||
| 					return | 					return | ||||||
|  | @ -383,7 +383,7 @@ func testProxyStoreServe(t *testing.T, te *testEnv, numClients int) { | ||||||
| 	// Serveblob - blobs come from local
 | 	// Serveblob - blobs come from local
 | ||||||
| 	for _, dr := range te.inRemote { | 	for _, dr := range te.inRemote { | ||||||
| 		w := httptest.NewRecorder() | 		w := httptest.NewRecorder() | ||||||
| 		r, err := http.NewRequest("GET", "", nil) | 		r, err := http.NewRequest(http.MethodGet, "", nil) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			t.Fatal(err) | 			t.Fatal(err) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -321,7 +321,7 @@ func getObject(client *http.Client, bucket string, name string, offset int64) (* | ||||||
| 		Host:   "storage.googleapis.com", | 		Host:   "storage.googleapis.com", | ||||||
| 		Path:   fmt.Sprintf("/%s/%s", bucket, name), | 		Path:   fmt.Sprintf("/%s/%s", bucket, name), | ||||||
| 	} | 	} | ||||||
| 	req, err := http.NewRequest("GET", u.String(), nil) | 	req, err := http.NewRequest(http.MethodGet, u.String(), nil) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return nil, err | 		return nil, err | ||||||
| 	} | 	} | ||||||
|  | @ -808,11 +808,11 @@ func (d *driver) URLFor(context context.Context, path string, options map[string | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	name := d.pathToKey(path) | 	name := d.pathToKey(path) | ||||||
| 	methodString := "GET" | 	methodString := http.MethodGet | ||||||
| 	method, ok := options["method"] | 	method, ok := options["method"] | ||||||
| 	if ok { | 	if ok { | ||||||
| 		methodString, ok = method.(string) | 		methodString, ok = method.(string) | ||||||
| 		if !ok || (methodString != "GET" && methodString != "HEAD") { | 		if !ok || (methodString != http.MethodGet && methodString != http.MethodHead) { | ||||||
| 			return "", storagedriver.ErrUnsupportedMethod{} | 			return "", storagedriver.ErrUnsupportedMethod{} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -849,7 +849,7 @@ func startSession(client *http.Client, bucket string, name string) (uri string, | ||||||
| 		RawQuery: fmt.Sprintf("uploadType=resumable&name=%v", name), | 		RawQuery: fmt.Sprintf("uploadType=resumable&name=%v", name), | ||||||
| 	} | 	} | ||||||
| 	err = retry(func() error { | 	err = retry(func() error { | ||||||
| 		req, err := http.NewRequest("POST", u.String(), nil) | 		req, err := http.NewRequest(http.MethodPost, u.String(), nil) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|  | @ -873,7 +873,7 @@ func startSession(client *http.Client, bucket string, name string) (uri string, | ||||||
| func putChunk(client *http.Client, sessionURI string, chunk []byte, from int64, totalSize int64) (int64, error) { | func putChunk(client *http.Client, sessionURI string, chunk []byte, from int64, totalSize int64) (int64, error) { | ||||||
| 	bytesPut := int64(0) | 	bytesPut := int64(0) | ||||||
| 	err := retry(func() error { | 	err := retry(func() error { | ||||||
| 		req, err := http.NewRequest("PUT", sessionURI, bytes.NewReader(chunk)) | 		req, err := http.NewRequest(http.MethodPut, sessionURI, bytes.NewReader(chunk)) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			return err | 			return err | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | @ -465,11 +465,11 @@ func (d *driver) Delete(ctx context.Context, path string) error { | ||||||
| // URLFor returns a URL which may be used to retrieve the content stored at the given path.
 | // URLFor returns a URL which may be used to retrieve the content stored at the given path.
 | ||||||
| // May return an UnsupportedMethodErr in certain StorageDriver implementations.
 | // May return an UnsupportedMethodErr in certain StorageDriver implementations.
 | ||||||
| func (d *driver) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) { | func (d *driver) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) { | ||||||
| 	methodString := "GET" | 	methodString := http.MethodGet | ||||||
| 	method, ok := options["method"] | 	method, ok := options["method"] | ||||||
| 	if ok { | 	if ok { | ||||||
| 		methodString, ok = method.(string) | 		methodString, ok = method.(string) | ||||||
| 		if !ok || (methodString != "GET") { | 		if !ok || (methodString != http.MethodGet) { | ||||||
| 			return "", storagedriver.ErrUnsupportedMethod{} | 			return "", storagedriver.ErrUnsupportedMethod{} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -1005,11 +1005,11 @@ ListLoop: | ||||||
| // URLFor returns a URL which may be used to retrieve the content stored at the given path.
 | // URLFor returns a URL which may be used to retrieve the content stored at the given path.
 | ||||||
| // May return an UnsupportedMethodErr in certain StorageDriver implementations.
 | // May return an UnsupportedMethodErr in certain StorageDriver implementations.
 | ||||||
| func (d *driver) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) { | func (d *driver) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) { | ||||||
| 	methodString := "GET" | 	methodString := http.MethodGet | ||||||
| 	method, ok := options["method"] | 	method, ok := options["method"] | ||||||
| 	if ok { | 	if ok { | ||||||
| 		methodString, ok = method.(string) | 		methodString, ok = method.(string) | ||||||
| 		if !ok || (methodString != "GET" && methodString != "HEAD") { | 		if !ok || (methodString != http.MethodGet && methodString != http.MethodHead) { | ||||||
| 			return "", storagedriver.ErrUnsupportedMethod{} | 			return "", storagedriver.ErrUnsupportedMethod{} | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  | @ -1026,12 +1026,12 @@ func (d *driver) URLFor(ctx context.Context, path string, options map[string]int | ||||||
| 	var req *request.Request | 	var req *request.Request | ||||||
| 
 | 
 | ||||||
| 	switch methodString { | 	switch methodString { | ||||||
| 	case "GET": | 	case http.MethodGet: | ||||||
| 		req, _ = d.S3.GetObjectRequest(&s3.GetObjectInput{ | 		req, _ = d.S3.GetObjectRequest(&s3.GetObjectInput{ | ||||||
| 			Bucket: aws.String(d.Bucket), | 			Bucket: aws.String(d.Bucket), | ||||||
| 			Key:    aws.String(d.s3Path(path)), | 			Key:    aws.String(d.s3Path(path)), | ||||||
| 		}) | 		}) | ||||||
| 	case "HEAD": | 	case http.MethodHead: | ||||||
| 		req, _ = d.S3.HeadObjectRequest(&s3.HeadObjectInput{ | 		req, _ = d.S3.HeadObjectRequest(&s3.HeadObjectInput{ | ||||||
| 			Bucket: aws.String(d.Bucket), | 			Bucket: aws.String(d.Bucket), | ||||||
| 			Key:    aws.String(d.s3Path(path)), | 			Key:    aws.String(d.s3Path(path)), | ||||||
|  |  | ||||||
|  | @ -608,7 +608,7 @@ func (d *driver) URLFor(ctx context.Context, path string, options map[string]int | ||||||
| 		return "", storagedriver.ErrUnsupportedMethod{} | 		return "", storagedriver.ErrUnsupportedMethod{} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	methodString := "GET" | 	methodString := http.MethodGet | ||||||
| 	method, ok := options["method"] | 	method, ok := options["method"] | ||||||
| 	if ok { | 	if ok { | ||||||
| 		if methodString, ok = method.(string); !ok { | 		if methodString, ok = method.(string); !ok { | ||||||
|  | @ -616,10 +616,10 @@ func (d *driver) URLFor(ctx context.Context, path string, options map[string]int | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if methodString == "HEAD" { | 	if methodString == http.MethodHead { | ||||||
| 		// A "HEAD" request on a temporary URL is allowed if the
 | 		// A "HEAD" request on a temporary URL is allowed if the
 | ||||||
| 		// signature was generated with "GET", "POST" or "PUT"
 | 		// signature was generated with "GET", "POST" or "PUT"
 | ||||||
| 		methodString = "GET" | 		methodString = http.MethodGet | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	supported := false | 	supported := false | ||||||
|  |  | ||||||
|  | @ -645,7 +645,7 @@ func (suite *DriverSuite) TestURLFor(c *check.C) { | ||||||
| 	c.Assert(err, check.IsNil) | 	c.Assert(err, check.IsNil) | ||||||
| 	c.Assert(read, check.DeepEquals, contents) | 	c.Assert(read, check.DeepEquals, contents) | ||||||
| 
 | 
 | ||||||
| 	url, err = suite.StorageDriver.URLFor(suite.ctx, filename, map[string]interface{}{"method": "HEAD"}) | 	url, err = suite.StorageDriver.URLFor(suite.ctx, filename, map[string]interface{}{"method": http.MethodHead}) | ||||||
| 	if _, ok := err.(storagedriver.ErrUnsupportedMethod); ok { | 	if _, ok := err.(storagedriver.ErrUnsupportedMethod); ok { | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue