2023-06-22 22:12:33 +00:00
|
|
|
// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved.
|
2021-02-02 15:29:09 +00:00
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
package csrftoken
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestCSRFToken(t *testing.T) {
|
|
|
|
tok, err := Generate()
|
|
|
|
require.NoError(t, err)
|
|
|
|
require.Len(t, tok, 64)
|
|
|
|
|
|
|
|
var empty bytes.Buffer
|
|
|
|
tok, err = generate(&empty)
|
|
|
|
require.EqualError(t, err, "could not generate CSRFToken: EOF")
|
|
|
|
require.Empty(t, tok)
|
|
|
|
}
|