mirror of
https://github.com/cloudflare/cloudflared.git
synced 2026-10-12 02:12:14 +00:00
Redact recipient rules, improve protected tunnel startup output, and reject --allowed-mail for named tunnels. Use state-specific cookies so concurrent login flows remain independent, with callbacks selecting and clearing only the matching state cookie.
41 lines
1.2 KiB
Go
41 lines
1.2 KiB
Go
package quicktunnelauth
|
|
|
|
import (
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestFilterQuickTunnelsAuthHeaders(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
headers := http.Header{
|
|
"Cache-Control": {"public, max-age=3600"},
|
|
"Referrer-Policy": {"unsafe-url"},
|
|
"Set-Cookie": {
|
|
quickTunnelAuthSessionCookieName + "=session-value; Path=/; Secure; HttpOnly; SameSite=Lax",
|
|
quickTunnelAuthStateCookiePrefix + "state=state-value; Path=/; Secure; HttpOnly; SameSite=Lax",
|
|
quickTunnelAuthSessionCookieName + "; Path=/; Secure; Max-Age=0",
|
|
quickTunnelAuthStateCookiePrefix + "state; Path=/; Secure; Max-Age=0",
|
|
"origin-session=origin-value; Path=/; Secure; HttpOnly; SameSite=Lax",
|
|
},
|
|
}
|
|
|
|
FilterQuickTunnelsAuthHeaders(headers)
|
|
|
|
assert.Equal(t, quickTunnelAuthCacheControlValue, headers.Get("Cache-Control"))
|
|
assert.Equal(t, quickTunnelAuthReferrerPolicyValue, headers.Get("Referrer-Policy"))
|
|
assert.Equal(t, []string{
|
|
"origin-session=origin-value; Path=/; Secure; HttpOnly; SameSite=Lax",
|
|
}, headers.Values("Set-Cookie"))
|
|
}
|
|
|
|
func TestFilterQuickTunnelsAuthHeadersHandlesNil(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
assert.NotPanics(t, func() {
|
|
FilterQuickTunnelsAuthHeaders(nil)
|
|
})
|
|
}
|