mirror of
https://github.com/hashicorp/vault.git
synced 2026-02-10 02:11:11 +01:00
* license: update headers to IBM Corp. * `make proto` * update offset because source file changed Signed-off-by: Ryan Cragun <me@ryan.ec> Co-authored-by: Ryan Cragun <me@ryan.ec>
30 lines
839 B
Go
30 lines
839 B
Go
// Copyright IBM Corp. 2016, 2025
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
package pluginutil
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// TestIdentityToken_Stringer ensures that plugin identity tokens that
|
|
// are printed in formatted strings or errors are redacted and getters
|
|
// return expected values.
|
|
func TestIdentityToken_Stringer(t *testing.T) {
|
|
contents := "header.payload.signature"
|
|
tk := IdentityToken(contents)
|
|
|
|
// token getters
|
|
assert.Equal(t, contents, tk.Token())
|
|
assert.Equal(t, redactedTokenString, tk.String())
|
|
|
|
// formatted strings and errors
|
|
assert.NotContains(t, fmt.Sprintf("%v", tk), tk.Token())
|
|
assert.NotContains(t, fmt.Sprintf("%s", tk), tk.Token())
|
|
assert.NotContains(t, fmt.Errorf("%v", tk).Error(), tk.Token())
|
|
assert.NotContains(t, fmt.Errorf("%s", tk).Error(), tk.Token())
|
|
}
|