1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-25 08:59:31 -05:00

[GITEA] Fix test TestWebhookProxy with http proxy env

- Unset the http proxies environments for the `TestWebhookProxy`.
- Resolves #2132

(cherry picked from commit 244b9786fc)
(cherry picked from commit 8602dfa6a2)
(cherry picked from commit 8621449209)
This commit is contained in:
Gusted 2024-01-13 22:01:05 +01:00 committed by Earl Warren
parent e9ff354f7c
commit aefa77f917
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00

View file

@ -8,6 +8,7 @@ import (
"net/http"
"net/http/httptest"
"net/url"
"os"
"testing"
"time"
@ -25,9 +26,15 @@ import (
func TestWebhookProxy(t *testing.T) {
oldWebhook := setting.Webhook
oldHTTPProxy := os.Getenv("http_proxy")
oldHTTPSProxy := os.Getenv("https_proxy")
t.Cleanup(func() {
setting.Webhook = oldWebhook
os.Setenv("http_proxy", oldHTTPProxy)
os.Setenv("https_proxy", oldHTTPSProxy)
})
os.Unsetenv("http_proxy")
os.Unsetenv("https_proxy")
setting.Webhook.ProxyURL = "http://localhost:8080"
setting.Webhook.ProxyURLFixed, _ = url.Parse(setting.Webhook.ProxyURL)