Skip to content

Commit

Permalink
[GITEA] Fix test TestWebhookProxy with http proxy env
Browse files Browse the repository at this point in the history
- Unset the http proxies environments for the `TestWebhookProxy`.
- Resolves go-gitea#2132

(cherry picked from commit 244b9786fc431c362c6f5ac971ac4d04b97f78a2)
(cherry picked from commit 8602dfa6a21e1ac9fa0fc6f5952da219a57b2613)
(cherry picked from commit 862144920945575c26e026281aab6e9bf3e00c5c)
(cherry picked from commit aefa77f917b58dc9e3fc013790aaa286f0beda5b)
  • Loading branch information
Gusted authored and earl-warren committed Feb 5, 2024
1 parent 2bdab5e commit 2baec13
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions services/webhook/deliver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"
"net/http/httptest"
"net/url"
"os"
"testing"
"time"

Expand All @@ -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)
Expand Down

0 comments on commit 2baec13

Please sign in to comment.