From 5b4e58f0b8d52dec241ac8c6b574f91aea6412f3 Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Tue, 2 Feb 2021 09:29:09 -0600 Subject: [PATCH] Add some trivial unit tests to internal/oidc/csrftoken. This change is primarily to test that our test coverage reporting is working as expected. Signed-off-by: Matt Moyer --- internal/oidc/csrftoken/csrftoken_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 internal/oidc/csrftoken/csrftoken_test.go diff --git a/internal/oidc/csrftoken/csrftoken_test.go b/internal/oidc/csrftoken/csrftoken_test.go new file mode 100644 index 00000000..61030731 --- /dev/null +++ b/internal/oidc/csrftoken/csrftoken_test.go @@ -0,0 +1,22 @@ +// Copyright 2021 the Pinniped contributors. All Rights Reserved. +// 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) +}