photoprism/internal/config/config_proxy_test.go
Michael Mayer 6dd55170fe Config: Add option to set a proxy for outgoing connections #3132
Signed-off-by: Michael Mayer <michael@photoprism.app>
2023-01-19 20:46:27 +01:00

36 lines
691 B
Go

package config
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestConfig_HttpsProxy(t *testing.T) {
c := NewConfig(CliTestContext())
assert.Equal(t, "", c.HttpsProxy())
_ = os.Setenv("HTTPS_PROXY", "https://foo.bar:8081")
assert.Equal(t, "https://foo.bar:8081", c.HttpsProxy())
_ = os.Setenv("HTTPS_PROXY", "")
assert.Equal(t, "", c.HttpsProxy())
}
func TestConfig_HttpsProxyInsecure(t *testing.T) {
c := NewConfig(CliTestContext())
assert.False(t, c.HttpsProxyInsecure())
_ = os.Setenv("HTTPS_PROXY", "https://foo.bar:8081")
assert.False(t, c.HttpsProxyInsecure())
_ = os.Setenv("HTTPS_PROXY", "")
assert.False(t, c.HttpsProxyInsecure())
}