|
@@ -134,13 +134,13 @@ func TestElapsedTime(t *testing.T) {
|
|
|
func TestProxyFilterWithHttpDefault(t *testing.T) {
|
|
func TestProxyFilterWithHttpDefault(t *testing.T) {
|
|
|
os.Clearenv()
|
|
os.Clearenv()
|
|
|
os.Setenv("PROXY_IMAGES", "http-only")
|
|
os.Setenv("PROXY_IMAGES", "http-only")
|
|
|
- c := config.NewConfig()
|
|
|
|
|
|
|
+ config.ParseConfig()
|
|
|
|
|
|
|
|
r := mux.NewRouter()
|
|
r := mux.NewRouter()
|
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
|
|
|
|
|
|
input := `<p><img src="http://website/folder/image.png" alt="Test"/></p>`
|
|
input := `<p><img src="http://website/folder/image.png" alt="Test"/></p>`
|
|
|
- output := imageProxyFilter(r, c, input)
|
|
|
|
|
|
|
+ output := imageProxyFilter(r, input)
|
|
|
expected := `<p><img src="/proxy/aHR0cDovL3dlYnNpdGUvZm9sZGVyL2ltYWdlLnBuZw==" alt="Test"/></p>`
|
|
expected := `<p><img src="/proxy/aHR0cDovL3dlYnNpdGUvZm9sZGVyL2ltYWdlLnBuZw==" alt="Test"/></p>`
|
|
|
|
|
|
|
|
if expected != output {
|
|
if expected != output {
|
|
@@ -151,13 +151,13 @@ func TestProxyFilterWithHttpDefault(t *testing.T) {
|
|
|
func TestProxyFilterWithHttpsDefault(t *testing.T) {
|
|
func TestProxyFilterWithHttpsDefault(t *testing.T) {
|
|
|
os.Clearenv()
|
|
os.Clearenv()
|
|
|
os.Setenv("PROXY_IMAGES", "http-only")
|
|
os.Setenv("PROXY_IMAGES", "http-only")
|
|
|
- c := config.NewConfig()
|
|
|
|
|
|
|
+ config.ParseConfig()
|
|
|
|
|
|
|
|
r := mux.NewRouter()
|
|
r := mux.NewRouter()
|
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
|
|
|
|
|
|
input := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
input := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
|
- output := imageProxyFilter(r, c, input)
|
|
|
|
|
|
|
+ output := imageProxyFilter(r, input)
|
|
|
expected := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
expected := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
|
|
|
|
|
|
if expected != output {
|
|
if expected != output {
|
|
@@ -168,13 +168,13 @@ func TestProxyFilterWithHttpsDefault(t *testing.T) {
|
|
|
func TestProxyFilterWithHttpNever(t *testing.T) {
|
|
func TestProxyFilterWithHttpNever(t *testing.T) {
|
|
|
os.Clearenv()
|
|
os.Clearenv()
|
|
|
os.Setenv("PROXY_IMAGES", "none")
|
|
os.Setenv("PROXY_IMAGES", "none")
|
|
|
- c := config.NewConfig()
|
|
|
|
|
|
|
+ config.ParseConfig()
|
|
|
|
|
|
|
|
r := mux.NewRouter()
|
|
r := mux.NewRouter()
|
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
|
|
|
|
|
|
input := `<p><img src="http://website/folder/image.png" alt="Test"/></p>`
|
|
input := `<p><img src="http://website/folder/image.png" alt="Test"/></p>`
|
|
|
- output := imageProxyFilter(r, c, input)
|
|
|
|
|
|
|
+ output := imageProxyFilter(r, input)
|
|
|
expected := input
|
|
expected := input
|
|
|
|
|
|
|
|
if expected != output {
|
|
if expected != output {
|
|
@@ -185,13 +185,13 @@ func TestProxyFilterWithHttpNever(t *testing.T) {
|
|
|
func TestProxyFilterWithHttpsNever(t *testing.T) {
|
|
func TestProxyFilterWithHttpsNever(t *testing.T) {
|
|
|
os.Clearenv()
|
|
os.Clearenv()
|
|
|
os.Setenv("PROXY_IMAGES", "none")
|
|
os.Setenv("PROXY_IMAGES", "none")
|
|
|
- c := config.NewConfig()
|
|
|
|
|
|
|
+ config.ParseConfig()
|
|
|
|
|
|
|
|
r := mux.NewRouter()
|
|
r := mux.NewRouter()
|
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
|
|
|
|
|
|
input := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
input := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
|
- output := imageProxyFilter(r, c, input)
|
|
|
|
|
|
|
+ output := imageProxyFilter(r, input)
|
|
|
expected := input
|
|
expected := input
|
|
|
|
|
|
|
|
if expected != output {
|
|
if expected != output {
|
|
@@ -202,13 +202,13 @@ func TestProxyFilterWithHttpsNever(t *testing.T) {
|
|
|
func TestProxyFilterWithHttpAlways(t *testing.T) {
|
|
func TestProxyFilterWithHttpAlways(t *testing.T) {
|
|
|
os.Clearenv()
|
|
os.Clearenv()
|
|
|
os.Setenv("PROXY_IMAGES", "all")
|
|
os.Setenv("PROXY_IMAGES", "all")
|
|
|
- c := config.NewConfig()
|
|
|
|
|
|
|
+ config.ParseConfig()
|
|
|
|
|
|
|
|
r := mux.NewRouter()
|
|
r := mux.NewRouter()
|
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
|
|
|
|
|
|
input := `<p><img src="http://website/folder/image.png" alt="Test"/></p>`
|
|
input := `<p><img src="http://website/folder/image.png" alt="Test"/></p>`
|
|
|
- output := imageProxyFilter(r, c, input)
|
|
|
|
|
|
|
+ output := imageProxyFilter(r, input)
|
|
|
expected := `<p><img src="/proxy/aHR0cDovL3dlYnNpdGUvZm9sZGVyL2ltYWdlLnBuZw==" alt="Test"/></p>`
|
|
expected := `<p><img src="/proxy/aHR0cDovL3dlYnNpdGUvZm9sZGVyL2ltYWdlLnBuZw==" alt="Test"/></p>`
|
|
|
|
|
|
|
|
if expected != output {
|
|
if expected != output {
|
|
@@ -219,13 +219,13 @@ func TestProxyFilterWithHttpAlways(t *testing.T) {
|
|
|
func TestProxyFilterWithHttpsAlways(t *testing.T) {
|
|
func TestProxyFilterWithHttpsAlways(t *testing.T) {
|
|
|
os.Clearenv()
|
|
os.Clearenv()
|
|
|
os.Setenv("PROXY_IMAGES", "all")
|
|
os.Setenv("PROXY_IMAGES", "all")
|
|
|
- c := config.NewConfig()
|
|
|
|
|
|
|
+ config.ParseConfig()
|
|
|
|
|
|
|
|
r := mux.NewRouter()
|
|
r := mux.NewRouter()
|
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
|
|
|
|
|
|
input := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
input := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
|
- output := imageProxyFilter(r, c, input)
|
|
|
|
|
|
|
+ output := imageProxyFilter(r, input)
|
|
|
expected := `<p><img src="/proxy/aHR0cHM6Ly93ZWJzaXRlL2ZvbGRlci9pbWFnZS5wbmc=" alt="Test"/></p>`
|
|
expected := `<p><img src="/proxy/aHR0cHM6Ly93ZWJzaXRlL2ZvbGRlci9pbWFnZS5wbmc=" alt="Test"/></p>`
|
|
|
|
|
|
|
|
if expected != output {
|
|
if expected != output {
|
|
@@ -236,13 +236,13 @@ func TestProxyFilterWithHttpsAlways(t *testing.T) {
|
|
|
func TestProxyFilterWithHttpInvalid(t *testing.T) {
|
|
func TestProxyFilterWithHttpInvalid(t *testing.T) {
|
|
|
os.Clearenv()
|
|
os.Clearenv()
|
|
|
os.Setenv("PROXY_IMAGES", "invalid")
|
|
os.Setenv("PROXY_IMAGES", "invalid")
|
|
|
- c := config.NewConfig()
|
|
|
|
|
|
|
+ config.ParseConfig()
|
|
|
|
|
|
|
|
r := mux.NewRouter()
|
|
r := mux.NewRouter()
|
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
|
|
|
|
|
|
input := `<p><img src="http://website/folder/image.png" alt="Test"/></p>`
|
|
input := `<p><img src="http://website/folder/image.png" alt="Test"/></p>`
|
|
|
- output := imageProxyFilter(r, c, input)
|
|
|
|
|
|
|
+ output := imageProxyFilter(r, input)
|
|
|
expected := `<p><img src="/proxy/aHR0cDovL3dlYnNpdGUvZm9sZGVyL2ltYWdlLnBuZw==" alt="Test"/></p>`
|
|
expected := `<p><img src="/proxy/aHR0cDovL3dlYnNpdGUvZm9sZGVyL2ltYWdlLnBuZw==" alt="Test"/></p>`
|
|
|
|
|
|
|
|
if expected != output {
|
|
if expected != output {
|
|
@@ -253,13 +253,13 @@ func TestProxyFilterWithHttpInvalid(t *testing.T) {
|
|
|
func TestProxyFilterWithHttpsInvalid(t *testing.T) {
|
|
func TestProxyFilterWithHttpsInvalid(t *testing.T) {
|
|
|
os.Clearenv()
|
|
os.Clearenv()
|
|
|
os.Setenv("PROXY_IMAGES", "invalid")
|
|
os.Setenv("PROXY_IMAGES", "invalid")
|
|
|
- c := config.NewConfig()
|
|
|
|
|
|
|
+ config.ParseConfig()
|
|
|
|
|
|
|
|
r := mux.NewRouter()
|
|
r := mux.NewRouter()
|
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
r.HandleFunc("/proxy/{encodedURL}", func(w http.ResponseWriter, r *http.Request) {}).Name("proxy")
|
|
|
|
|
|
|
|
input := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
input := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
|
- output := imageProxyFilter(r, c, input)
|
|
|
|
|
|
|
+ output := imageProxyFilter(r, input)
|
|
|
expected := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
expected := `<p><img src="https://website/folder/image.png" alt="Test"/></p>`
|
|
|
|
|
|
|
|
if expected != output {
|
|
if expected != output {
|