diff options
author | feistel <6742251-feistel@users.noreply.gitlab.com> | 2022-06-15 16:06:13 +0300 |
---|---|---|
committer | feistel <6742251-feistel@users.noreply.gitlab.com> | 2022-06-15 16:08:53 +0300 |
commit | 42251ee190c3774d46a9e5f6de03b0ee4d7c5e9b (patch) | |
tree | c4af0f18a71ae309571f99465966d2e047acbea2 /internal/handlers | |
parent | 8e66a072959f511459eaaafd33579de204b313f6 (diff) |
Remove host out of Artifact.TryMakeRequest
Diffstat (limited to 'internal/handlers')
-rw-r--r-- | internal/handlers/handlers.go | 5 | ||||
-rw-r--r-- | internal/handlers/handlers_test.go | 6 | ||||
-rw-r--r-- | internal/handlers/mock/handler_mock.go | 8 |
3 files changed, 8 insertions, 11 deletions
diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index c91491f0..80c771d5 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -5,7 +5,6 @@ import ( "gitlab.com/gitlab-org/gitlab-pages/internal" "gitlab.com/gitlab-org/gitlab-pages/internal/logging" - "gitlab.com/gitlab-org/gitlab-pages/internal/request" ) // Handlers take care of handling specific requests @@ -63,10 +62,8 @@ func (a *Handlers) HandleArtifactRequest(w http.ResponseWriter, r *http.Request) return true } - host := request.GetHostWithoutPort(r) - // nolint: bodyclose // false positive // a.checkIfLoginRequiredOrInvalidToken returns a response.Body, closing this body is responsibility // of the TryMakeRequest implementation - return a.Artifact.TryMakeRequest(host, w, r, token, a.checkIfLoginRequiredOrInvalidToken(w, r, token)) + return a.Artifact.TryMakeRequest(w, r, token, a.checkIfLoginRequiredOrInvalidToken(w, r, token)) } diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go index aedc077c..99ba8ca9 100644 --- a/internal/handlers/handlers_test.go +++ b/internal/handlers/handlers_test.go @@ -18,7 +18,7 @@ func TestNotHandleArtifactRequestReturnsFalse(t *testing.T) { mockArtifact := mock.NewMockArtifact(mockCtrl) mockArtifact.EXPECT(). - TryMakeRequest(gomock.Any(), gomock.Any(), gomock.Any(), "", gomock.Any()). + TryMakeRequest(gomock.Any(), gomock.Any(), "", gomock.Any()). Return(false). Times(1) @@ -43,7 +43,7 @@ func TestHandleArtifactRequestedReturnsTrue(t *testing.T) { mockArtifact := mock.NewMockArtifact(mockCtrl) mockArtifact.EXPECT(). - TryMakeRequest(gomock.Any(), gomock.Any(), gomock.Any(), "", gomock.Any()). + TryMakeRequest(gomock.Any(), gomock.Any(), "", gomock.Any()). Return(true). Times(1) @@ -175,7 +175,7 @@ func TestHandleArtifactRequestButGetTokenFails(t *testing.T) { mockArtifact := mock.NewMockArtifact(mockCtrl) mockArtifact.EXPECT(). - TryMakeRequest(gomock.Any(), gomock.Any(), gomock.Any(), "", gomock.Any()). + TryMakeRequest(gomock.Any(), gomock.Any(), "", gomock.Any()). Times(0) mockAuth := mock.NewMockAuth(mockCtrl) diff --git a/internal/handlers/mock/handler_mock.go b/internal/handlers/mock/handler_mock.go index 11548221..089b567c 100644 --- a/internal/handlers/mock/handler_mock.go +++ b/internal/handlers/mock/handler_mock.go @@ -35,17 +35,17 @@ func (m *MockArtifact) EXPECT() *MockArtifactMockRecorder { } // TryMakeRequest mocks base method. -func (m *MockArtifact) TryMakeRequest(host string, w http.ResponseWriter, r *http.Request, token string, responseHandler func(*http.Response) bool) bool { +func (m *MockArtifact) TryMakeRequest(w http.ResponseWriter, r *http.Request, token string, responseHandler func(*http.Response) bool) bool { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "TryMakeRequest", host, w, r, token, responseHandler) + ret := m.ctrl.Call(m, "TryMakeRequest", w, r, token, responseHandler) ret0, _ := ret[0].(bool) return ret0 } // TryMakeRequest indicates an expected call of TryMakeRequest. -func (mr *MockArtifactMockRecorder) TryMakeRequest(host, w, r, token, responseHandler interface{}) *gomock.Call { +func (mr *MockArtifactMockRecorder) TryMakeRequest(w, r, token, responseHandler interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryMakeRequest", reflect.TypeOf((*MockArtifact)(nil).TryMakeRequest), host, w, r, token, responseHandler) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TryMakeRequest", reflect.TypeOf((*MockArtifact)(nil).TryMakeRequest), w, r, token, responseHandler) } // MockAuth is a mock of Auth interface. |