mirror of
https://github.com/argoproj/argo-cd
synced 2026-04-21 17:07:16 +00:00
chore(deps): update module github.com/golangci/golangci-lint/v2 to v2.11.1 (#26713)
Signed-off-by: renovate[bot] <renovate[bot]@users.noreply.github.com> Signed-off-by: reggie-k <regina.voloshin@codefresh.io> Co-authored-by: argoproj-renovate[bot] <161757507+argoproj-renovate[bot]@users.noreply.github.com> Co-authored-by: reggie-k <regina.voloshin@codefresh.io>
This commit is contained in:
parent
ede9229353
commit
1f6d54ce04
9 changed files with 53 additions and 53 deletions
2
.github/workflows/ci-build.yaml
vendored
2
.github/workflows/ci-build.yaml
vendored
|
|
@ -111,7 +111,7 @@ jobs:
|
|||
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
|
||||
with:
|
||||
# renovate: datasource=go packageName=github.com/golangci/golangci-lint/v2 versioning=regex:^v(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)?$
|
||||
version: v2.10.1
|
||||
version: v2.11.1
|
||||
args: --verbose
|
||||
|
||||
test-go:
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ func TestWebhookHandler(t *testing.T) {
|
|||
h, err := NewWebhookHandler(webhookParallelism, set, fc, mockGenerators())
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set(test.headerKey, test.headerValue)
|
||||
eventJSON, err := os.ReadFile(filepath.Join("testdata", test.payloadFile))
|
||||
require.NoError(t, err)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
set -eux -o pipefail
|
||||
|
||||
# renovate: datasource=go packageName=github.com/golangci/golangci-lint/v2
|
||||
GOLANGCI_LINT_VERSION=2.10.1
|
||||
GOLANGCI_LINT_VERSION=2.11.1
|
||||
|
||||
GO111MODULE=on go install "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v${GOLANGCI_LINT_VERSION}"
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ func TestTerminalHandler_ServeHTTP_empty_params(t *testing.T) {
|
|||
paramsArray = append(paramsArray, key+"="+value)
|
||||
}
|
||||
paramsString := strings.Join(paramsArray, "&")
|
||||
request := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/api/v1/terminal?"+paramsString, http.NoBody)
|
||||
request := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/api/v1/terminal?"+paramsString, http.NoBody)
|
||||
recorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(recorder, request)
|
||||
response := recorder.Result()
|
||||
|
|
@ -220,7 +220,7 @@ func TestTerminalHandler_ServeHTTP_empty_params(t *testing.T) {
|
|||
|
||||
func TestTerminalHandler_ServeHTTP_disallowed_namespace(t *testing.T) {
|
||||
handler := terminalHandler{namespace: "argocd", enabledNamespaces: []string{"allowed"}}
|
||||
request := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/api/v1/terminal?pod=valid&container=valid&appName=valid&projectName=valid&namespace=test&appNamespace=disallowed", http.NoBody)
|
||||
request := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/api/v1/terminal?pod=valid&container=valid&appName=valid&projectName=valid&namespace=test&appNamespace=disallowed", http.NoBody)
|
||||
recorder := httptest.NewRecorder()
|
||||
handler.ServeHTTP(recorder, request)
|
||||
response := recorder.Result()
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ func TestNewRedirectServerEmptyRootPath(t *testing.T) {
|
|||
assert.Equal(t, "localhost:8080", server.Addr, "When rootPath is empty, server address should be 'localhost:8080'")
|
||||
|
||||
// Test the redirect handler
|
||||
req := httptest.NewRequest(http.MethodGet, "/applications", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/applications", http.NoBody)
|
||||
req.Host = "example.com:8080"
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
|
|
@ -84,7 +84,7 @@ func TestNewRedirectServerNonEmptyRootPath(t *testing.T) {
|
|||
assert.Equal(t, "localhost:8080/argocd", server.Addr, "When rootPath is '/argocd', server address should be 'localhost:8080/argocd'")
|
||||
|
||||
// Test the redirect handler
|
||||
req := httptest.NewRequest(http.MethodGet, "/applications", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/applications", http.NoBody)
|
||||
req.Host = "example.com:8080"
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ func TestNewRedirectServerRootPathDuplication(t *testing.T) {
|
|||
server := newRedirectServer(8080, "/argocd")
|
||||
|
||||
// Test the redirect handler with a request path that already includes rootPath
|
||||
req := httptest.NewRequest(http.MethodGet, "/argocd/applications", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/argocd/applications", http.NoBody)
|
||||
req.Host = "example.com:8080"
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
|
|
|
|||
|
|
@ -1487,7 +1487,7 @@ func TestCacheControlHeaders(t *testing.T) {
|
|||
handler := argocd.newStaticAssetsHandler()
|
||||
|
||||
rr := httptest.NewRecorder()
|
||||
req := httptest.NewRequest("", "/"+testCase.filename, http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), "", "/"+testCase.filename, http.NoBody)
|
||||
|
||||
fp := filepath.Join(argocd.TmpAssetsDir, testCase.filename)
|
||||
|
||||
|
|
@ -1643,7 +1643,7 @@ func Test_enforceContentTypes(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
handler := enforceContentTypes(getBaseHandler(t, true), []string{"application/json"}).(http.HandlerFunc)
|
||||
req := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/", http.NoBody)
|
||||
w := httptest.NewRecorder()
|
||||
handler(w, req)
|
||||
resp := w.Result()
|
||||
|
|
@ -1654,20 +1654,20 @@ func Test_enforceContentTypes(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
handler := enforceContentTypes(getBaseHandler(t, true), []string{"application/json"}).(http.HandlerFunc)
|
||||
req := httptest.NewRequest(http.MethodPost, "/", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/", http.NoBody)
|
||||
w := httptest.NewRecorder()
|
||||
handler(w, req)
|
||||
resp := w.Result()
|
||||
assert.Equal(t, http.StatusUnsupportedMediaType, resp.StatusCode, "didn't provide a content type, should have gotten an error")
|
||||
|
||||
req = httptest.NewRequest(http.MethodPost, "/", http.NoBody)
|
||||
req = httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/", http.NoBody)
|
||||
req.Header = map[string][]string{"Content-Type": {"application/json"}}
|
||||
w = httptest.NewRecorder()
|
||||
handler(w, req)
|
||||
resp = w.Result()
|
||||
assert.Equal(t, http.StatusOK, resp.StatusCode, "should have passed, since an allowed content type was provided")
|
||||
|
||||
req = httptest.NewRequest(http.MethodPost, "/", http.NoBody)
|
||||
req = httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/", http.NoBody)
|
||||
req.Header = map[string][]string{"Content-Type": {"not-allowed"}}
|
||||
w = httptest.NewRecorder()
|
||||
handler(w, req)
|
||||
|
|
@ -1696,7 +1696,7 @@ func Test_StaticAssetsDir_no_symlink_traversal(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
// Make a request to get the file from the /assets endpoint
|
||||
req := httptest.NewRequest(http.MethodGet, "/link.txt", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/link.txt", http.NoBody)
|
||||
w := httptest.NewRecorder()
|
||||
argocd.newStaticAssetsHandler()(w, req)
|
||||
resp := w.Result()
|
||||
|
|
@ -1706,7 +1706,7 @@ func Test_StaticAssetsDir_no_symlink_traversal(t *testing.T) {
|
|||
normalFilePath := filepath.Join(argocd.StaticAssetsDir, "normal.txt")
|
||||
err = os.WriteFile(normalFilePath, []byte("normal"), 0o644)
|
||||
require.NoError(t, err)
|
||||
req = httptest.NewRequest(http.MethodGet, "/normal.txt", http.NoBody)
|
||||
req = httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/normal.txt", http.NoBody)
|
||||
w = httptest.NewRecorder()
|
||||
argocd.newStaticAssetsHandler()(w, req)
|
||||
resp = w.Result()
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ func (p *fakeProvider) Verify(_ context.Context, _ string, _ *settings.ArgoCDSet
|
|||
func TestHandleCallback(t *testing.T) {
|
||||
app := ClientApp{provider: &fakeProvider{}, settings: &settings.ArgoCDSettings{}}
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "http://example.com/foo", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "http://example.com/foo", http.NoBody)
|
||||
req.Form = url.Values{
|
||||
"error": []string{"login-failed"},
|
||||
"error_description": []string{"<script>alert('hello')</script>"},
|
||||
|
|
@ -156,7 +156,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
app, err := NewClientApp(cdSettings, dexTestServer.URL, nil, "https://argocd.example.com", cache.NewInMemoryCache(24*time.Hour))
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
app, err := NewClientApp(cdSettings, dexTestServer.URL, nil, "https://argocd.example.com", cache.NewInMemoryCache(24*time.Hour))
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
app, err := NewClientApp(cdSettings, dexTestServer.URL, &dex.DexTLSConfig{StrictValidation: false}, "https://argocd.example.com", cache.NewInMemoryCache(24*time.Hour))
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
w := httptest.NewRecorder()
|
||||
app.HandleLogin(w, req)
|
||||
|
||||
|
|
@ -265,7 +265,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
app, err := NewClientApp(cdSettings, dexTestServer.URL, &dex.DexTLSConfig{StrictValidation: false}, "https://argocd.example.com", cache.NewInMemoryCache(24*time.Hour))
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
w := httptest.NewRecorder()
|
||||
app.HandleLogin(w, req)
|
||||
|
||||
|
|
@ -302,7 +302,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
app, err := NewClientApp(cdSettings, dexTestServer.URL, &dex.DexTLSConfig{StrictValidation: false}, "https://argocd.example.com", cache.NewInMemoryCache(24*time.Hour))
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
w := httptest.NewRecorder()
|
||||
app.HandleLogin(w, req)
|
||||
|
||||
|
|
@ -341,7 +341,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
require.NoError(t, err)
|
||||
|
||||
t.Run("should accept login redirecting on the main domain", func(t *testing.T) {
|
||||
req := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
|
||||
req.URL.RawQuery = url.Values{
|
||||
"return_url": []string{"https://argocd.example.com/applications"},
|
||||
|
|
@ -360,7 +360,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
})
|
||||
|
||||
t.Run("should accept login redirecting on the alternative domains", func(t *testing.T) {
|
||||
req := httptest.NewRequest(http.MethodGet, "https://localhost:8080/auth/login", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://localhost:8080/auth/login", http.NoBody)
|
||||
|
||||
req.URL.RawQuery = url.Values{
|
||||
"return_url": []string{"https://localhost:8080/applications"},
|
||||
|
|
@ -379,7 +379,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
})
|
||||
|
||||
t.Run("should accept login redirecting on the alternative domains", func(t *testing.T) {
|
||||
req := httptest.NewRequest(http.MethodGet, "https://other.argocd.example.com/auth/login", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://other.argocd.example.com/auth/login", http.NoBody)
|
||||
|
||||
req.URL.RawQuery = url.Values{
|
||||
"return_url": []string{"https://other.argocd.example.com/applications"},
|
||||
|
|
@ -398,7 +398,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
})
|
||||
|
||||
t.Run("should deny login redirecting on the alternative domains", func(t *testing.T) {
|
||||
req := httptest.NewRequest(http.MethodGet, "https://not-argocd.example.com/auth/login", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://not-argocd.example.com/auth/login", http.NoBody)
|
||||
|
||||
req.URL.RawQuery = url.Values{
|
||||
"return_url": []string{"https://not-argocd.example.com/applications"},
|
||||
|
|
@ -438,7 +438,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/auth/login", http.NoBody)
|
||||
|
||||
app.HandleLogin(w, req)
|
||||
|
||||
|
|
@ -447,7 +447,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
|
||||
state := redirectURL.Query().Get("state")
|
||||
|
||||
req = httptest.NewRequest(http.MethodGet, fmt.Sprintf("https://argocd.example.com/auth/callback?state=%s&code=abc", state), http.NoBody)
|
||||
req = httptest.NewRequestWithContext(t.Context(), http.MethodGet, fmt.Sprintf("https://argocd.example.com/auth/callback?state=%s&code=abc", state), http.NoBody)
|
||||
for _, cookie := range w.Result().Cookies() {
|
||||
req.AddCookie(cookie)
|
||||
}
|
||||
|
|
@ -486,7 +486,7 @@ enablePKCEAuthentication: true`, oidcTestServer.URL),
|
|||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "https://example.com/argocd/auth/login", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://example.com/argocd/auth/login", http.NoBody)
|
||||
|
||||
app.HandleLogin(w, req)
|
||||
|
||||
|
|
@ -500,7 +500,7 @@ enablePKCEAuthentication: true`, oidcTestServer.URL),
|
|||
|
||||
state := redirectURL.Query().Get("state")
|
||||
|
||||
req = httptest.NewRequest(http.MethodGet, fmt.Sprintf("https://example.com/argocd/auth/callback?state=%s&code=abc", state), http.NoBody)
|
||||
req = httptest.NewRequestWithContext(t.Context(), http.MethodGet, fmt.Sprintf("https://example.com/argocd/auth/callback?state=%s&code=abc", state), http.NoBody)
|
||||
for _, cookie := range w.Result().Cookies() {
|
||||
req.AddCookie(cookie)
|
||||
}
|
||||
|
|
@ -533,7 +533,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
app, err := NewClientApp(cdSettings, dexTestServer.URL, nil, "https://argocd.example.com", cache.NewInMemoryCache(24*time.Hour))
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/auth/callback", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/auth/callback", http.NoBody)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
|
|
@ -572,7 +572,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
app, err := NewClientApp(cdSettings, dexTestServer.URL, nil, "https://argocd.example.com", cache.NewInMemoryCache(24*time.Hour))
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/auth/callback", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/auth/callback", http.NoBody)
|
||||
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
|
|
@ -700,7 +700,7 @@ requestedScopes: ["oidc"]`, oidcTestServer.URL),
|
|||
app, err := NewClientApp(cdSettings, dexTestServer.URL, nil, "https://argocd.example.com", cache.NewInMemoryCache(24*time.Hour))
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "https://argocd.example.com/auth/callback", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "https://argocd.example.com/auth/callback", http.NoBody)
|
||||
req.Form = url.Values{
|
||||
"code": {"abc"},
|
||||
"state": {"123"},
|
||||
|
|
@ -827,7 +827,7 @@ func TestGenerateAppState(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
t.Run("VerifyAppState_Successful", func(t *testing.T) {
|
||||
req := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/", http.NoBody)
|
||||
for _, cookie := range generateResponse.Result().Cookies() {
|
||||
req.AddCookie(cookie)
|
||||
}
|
||||
|
|
@ -839,7 +839,7 @@ func TestGenerateAppState(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("VerifyAppState_Failed", func(t *testing.T) {
|
||||
req := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/", http.NoBody)
|
||||
for _, cookie := range generateResponse.Result().Cookies() {
|
||||
req.AddCookie(cookie)
|
||||
}
|
||||
|
|
@ -872,7 +872,7 @@ func TestGenerateAppState_XSS(t *testing.T) {
|
|||
state, err := app.generateAppState(expectedReturnURL, "", generateResponse)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/", http.NoBody)
|
||||
for _, cookie := range generateResponse.Result().Cookies() {
|
||||
req.AddCookie(cookie)
|
||||
}
|
||||
|
|
@ -888,7 +888,7 @@ func TestGenerateAppState_XSS(t *testing.T) {
|
|||
state, err := app.generateAppState(expectedReturnURL, "", generateResponse)
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/", http.NoBody)
|
||||
for _, cookie := range generateResponse.Result().Cookies() {
|
||||
req.AddCookie(cookie)
|
||||
}
|
||||
|
|
@ -906,7 +906,7 @@ func TestGenerateAppState_NoReturnURL(t *testing.T) {
|
|||
key, err := cdSettings.GetServerEncryptionKey()
|
||||
require.NoError(t, err)
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/", http.NoBody)
|
||||
encrypted, err := crypto.Encrypt([]byte("123"), key)
|
||||
require.NoError(t, err)
|
||||
app, err := NewClientApp(cdSettings, "", nil, "/argo-cd", cache.NewInMemoryCache(24*time.Hour))
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ func TestGetCallBack(t *testing.T) {
|
|||
t.Run("custom proxy absent", func(t *testing.T) {
|
||||
proxyEnv := "http://proxy:8888"
|
||||
t.Setenv("http_proxy", "http://proxy:8888")
|
||||
url, err := GetCallback("", "")(httptest.NewRequest(http.MethodGet, proxyEnv, http.NoBody))
|
||||
url, err := GetCallback("", "")(httptest.NewRequestWithContext(t.Context(), http.MethodGet, proxyEnv, http.NoBody))
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, proxyEnv, url.String())
|
||||
})
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ func newMockHandler(reactor *reactorDef, applicationNamespaces []string, maxPayl
|
|||
func TestGitHubCommitEvent(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-GitHub-Event", "push")
|
||||
eventJSON, err := os.ReadFile("testdata/github-commit-event.json")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -168,7 +168,7 @@ func TestGitHubCommitEvent(t *testing.T) {
|
|||
func TestAzureDevOpsCommitEvent(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-Vss-Activityid", "abc")
|
||||
eventJSON, err := os.ReadFile("testdata/azuredevops-git-push-event.json")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -250,7 +250,7 @@ func TestGitHubCommitEvent_AppsInOtherNamespaces(t *testing.T) {
|
|||
},
|
||||
},
|
||||
)
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-GitHub-Event", "push")
|
||||
eventJSON, err := os.ReadFile("testdata/github-commit-event.json")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -284,7 +284,7 @@ func TestGitHubCommitEvent_AppsInOtherNamespaces(t *testing.T) {
|
|||
func TestGitHubTagEvent(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-GitHub-Event", "push")
|
||||
eventJSON, err := os.ReadFile("testdata/github-tag-event.json")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -302,7 +302,7 @@ func TestGitHubTagEvent(t *testing.T) {
|
|||
func TestGitHubPingEvent(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-GitHub-Event", "ping")
|
||||
eventJSON, err := os.ReadFile("testdata/github-ping-event.json")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -320,7 +320,7 @@ func TestGitHubPingEvent(t *testing.T) {
|
|||
func TestBitbucketServerRepositoryReferenceChangedEvent(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-Event-Key", "repo:refs_changed")
|
||||
eventJSON, err := os.ReadFile("testdata/bitbucket-server-event.json")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -341,7 +341,7 @@ func TestBitbucketServerRepositoryDiagnosticPingEvent(t *testing.T) {
|
|||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
eventJSON := "{\"test\": true}"
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", bytes.NewBufferString(eventJSON))
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", bytes.NewBufferString(eventJSON))
|
||||
req.Header.Set("X-Event-Key", "diagnostics:ping")
|
||||
w := httptest.NewRecorder()
|
||||
h.Handler(w, req)
|
||||
|
|
@ -356,7 +356,7 @@ func TestBitbucketServerRepositoryDiagnosticPingEvent(t *testing.T) {
|
|||
func TestGogsPushEvent(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-Gogs-Event", "push")
|
||||
eventJSON, err := os.ReadFile("testdata/gogs-event.json")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -374,7 +374,7 @@ func TestGogsPushEvent(t *testing.T) {
|
|||
func TestGitLabPushEvent(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-Gitlab-Event", "Push Hook")
|
||||
eventJSON, err := os.ReadFile("testdata/gitlab-event.json")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -392,7 +392,7 @@ func TestGitLabPushEvent(t *testing.T) {
|
|||
func TestGitLabSystemEvent(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-Gitlab-Event", "System Hook")
|
||||
eventJSON, err := os.ReadFile("testdata/gitlab-event.json")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -410,7 +410,7 @@ func TestGitLabSystemEvent(t *testing.T) {
|
|||
func TestInvalidMethod(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
req := httptest.NewRequest(http.MethodGet, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodGet, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-GitHub-Event", "push")
|
||||
w := httptest.NewRecorder()
|
||||
h.Handler(w, req)
|
||||
|
|
@ -426,7 +426,7 @@ func TestInvalidMethod(t *testing.T) {
|
|||
func TestInvalidEvent(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-GitHub-Event", "push")
|
||||
w := httptest.NewRecorder()
|
||||
h.Handler(w, req)
|
||||
|
|
@ -442,7 +442,7 @@ func TestInvalidEvent(t *testing.T) {
|
|||
func TestUnknownEvent(t *testing.T) {
|
||||
hook := test.NewGlobal()
|
||||
h := NewMockHandler(nil, []string{})
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-Unknown-Event", "push")
|
||||
w := httptest.NewRecorder()
|
||||
h.Handler(w, req)
|
||||
|
|
@ -741,7 +741,7 @@ func TestGitHubCommitEventMaxPayloadSize(t *testing.T) {
|
|||
hook := test.NewGlobal()
|
||||
maxPayloadSize := int64(100)
|
||||
h := NewMockHandlerWithPayloadLimit(nil, []string{}, maxPayloadSize)
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-GitHub-Event", "push")
|
||||
eventJSON, err := os.ReadFile("testdata/github-commit-event.json")
|
||||
require.NoError(t, err)
|
||||
|
|
@ -1152,7 +1152,7 @@ func TestHandleEvent(t *testing.T) {
|
|||
|
||||
// Create payload with the changed file
|
||||
payload := createTestPayload(ttc.changedFile)
|
||||
req := httptest.NewRequest(http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req := httptest.NewRequestWithContext(t.Context(), http.MethodPost, "/api/webhook", http.NoBody)
|
||||
req.Header.Set("X-GitHub-Event", "push")
|
||||
req.Body = io.NopCloser(bytes.NewReader(payload))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue