Files
threshold/internal/auth/oidc/client_secret_test.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.4 KiB
Go
Raw Normal View History

2023-02-02 17:15:17 -08:00
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1
2021-04-08 20:54:32 -04:00
package oidc
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestClientSecret_String(t *testing.T) {
t.Parallel()
t.Run("redacted", func(t *testing.T) {
assert := assert.New(t)
const want = redactedClientSecret
tk := ClientSecret("super secret token")
2021-06-16 11:44:08 -07:00
assert.Equalf(want, tk.String(), "ClientSecret.String() = %v, want %v", tk.String(), want)
// Verify stringer is called
s := fmt.Sprintf("%#v", tk)
assert.Equalf(want, s, "ClientSecret.String() = %v, want %v", s, want)
})
}
func TestClientSecret_GoString(t *testing.T) {
t.Parallel()
t.Run("redacted", func(t *testing.T) {
assert := assert.New(t)
const want = redactedClientSecret
tk := ClientSecret("super secret token")
assert.Equalf(want, tk.GoString(), "ClientSecret.GoString() = %v, want %v", tk.GoString(), want)
// Verify gostringer is called
s := fmt.Sprintf("%#v", tk)
assert.Equalf(want, s, "ClientSecret.GoString() = %v, want %v", s, want)
2021-04-08 20:54:32 -04:00
})
}
func TestClientSecret_MarshalJSON(t *testing.T) {
t.Parallel()
t.Run("redacted", func(t *testing.T) {
assert, require := assert.New(t), require.New(t)
want := fmt.Sprintf(`"%s"`, redactedClientSecret)
tk := ClientSecret("super secret token")
got, err := tk.MarshalJSON()
require.NoError(err)
2021-06-16 11:44:08 -07:00
assert.Equalf([]byte(want), got, "ClientSecret.MarshalJSON() = %s, want %s", got, want)
2021-04-08 20:54:32 -04:00
})
}