mirror of
https://github.com/hanzoai/forge.git
synced 2026-10-30 15:00:39 +00:00
Source files keep their SPDX-License-Identifier and Hanzo copyright line; the Gitea, Gogs and LFS Test Server copyrights they used to repeat now live once in NOTICE, alongside LICENSE. The header lint accepts any copyright line above the SPDX line, so it no longer demands an upstream one. Co-authored-by: Hanzo Dev <[email protected]>
30 lines
868 B
Go
30 lines
868 B
Go
// Copyright 2026 Hanzo AI, Inc. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package openid
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"sync/atomic"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestOpenIDDiscoveryBlocksInternalHost(t *testing.T) {
|
|
var reached atomic.Bool
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
reached.Store(true)
|
|
w.WriteHeader(http.StatusOK)
|
|
}))
|
|
defer srv.Close()
|
|
|
|
// RedirectURL performs server-side discovery of the identifier URL; a loopback URL
|
|
// must be refused at dial time instead of reaching the internal server
|
|
_, err := RedirectURL(srv.URL, "http://example.com/callback", "http://example.com/")
|
|
require.Error(t, err)
|
|
assert.False(t, reached.Load(), "OpenID discovery must not reach an internal/loopback host")
|
|
}
|