mirror of
https://github.com/juanfont/headscale.git
synced 2026-07-17 16:36:02 +00:00
20 lines
614 B
Go
20 lines
614 B
Go
package hscontrol
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// TestGetCookieNameShortValue ensures a value shorter than the prefix length
|
|
// (e.g. a malformed nonce from a misbehaving IdP) does not panic with
|
|
// slice-out-of-range; it uses the available bytes instead.
|
|
func TestGetCookieNameShortValue(t *testing.T) {
|
|
require.NotPanics(t, func() {
|
|
assert.Equal(t, "nonce_ab", getCookieName("nonce", "ab"))
|
|
})
|
|
|
|
assert.Equal(t, "nonce_abcdef", getCookieName("nonce", "abcdef"))
|
|
assert.Equal(t, "nonce_abcdef", getCookieName("nonce", "abcdefghij"))
|
|
}
|