Checks need the same protection as identity provider requests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
23 lines
612 B
Go
23 lines
612 B
Go
package sso
|
|
|
|
import (
|
|
"errors"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
)
|
|
|
|
func TestSafeHTTPClientBlocksLoopback(t *testing.T) {
|
|
srv := httptest.NewServer(http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}))
|
|
defer srv.Close()
|
|
|
|
if _, err := SafeHTTPClient(false).Get(srv.URL); !errors.Is(err, ErrForbiddenAddress) {
|
|
t.Errorf("Get(%s) with private networks denied: error = %v, want %v", srv.URL, err, ErrForbiddenAddress)
|
|
}
|
|
resp, err := SafeHTTPClient(true).Get(srv.URL)
|
|
if err != nil {
|
|
t.Fatalf("Get(%s) with private networks allowed failed: %v", srv.URL, err)
|
|
}
|
|
_ = resp.Body.Close()
|
|
}
|