mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-16 03:27:01 +02:00
* systemview: adds method for plugins to generate identity tokens * change test name and godoc * adds changelog * make proto to include comment
30 lines
838 B
Go
30 lines
838 B
Go
// Copyright (c) HashiCorp, Inc.
|
|
// 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())
|
|
}
|