Files
threshold/internal/bsr/options_test.go
T
429247f407 [COMPLIANCE] Update Copyright Headers (#6282)
* [COMPLIANCE] Update Copyright and License Headers

* chore: make gen to generate files with copyright headers

* chore: update missed copyright headers

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Justin Nguyen <justin.nguyen@hashicorp.com>
2026-01-28 11:05:07 -06:00

58 lines
1.4 KiB
Go

// Copyright IBM Corp. 2020, 2025
// SPDX-License-Identifier: BUSL-1.1
package bsr
import (
"context"
"testing"
"github.com/hashicorp/boundary/internal/bsr/kms"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func Test_GetOpts(t *testing.T) {
t.Parallel()
t.Run("default", func(t *testing.T) {
assert := assert.New(t)
opts := getOpts()
testOpts := options{
withSupportsMultiplex: false,
withKeys: nil,
withSha256Sum: nil,
}
assert.Equal(opts, testOpts)
})
t.Run("WithSupportsMultiplex", func(t *testing.T) {
assert := assert.New(t)
opts := getOpts(WithSupportsMultiplex(true))
testOpts := getDefaultOptions()
testOpts.withSupportsMultiplex = true
assert.Equal(opts, testOpts)
})
t.Run("WithKeys", func(t *testing.T) {
ctx := context.Background()
assert := assert.New(t)
require := require.New(t)
keys, err := kms.CreateKeys(ctx, kms.TestWrapper(t), "foo")
require.NoError(err)
opts := getOpts(WithKeys(keys))
testOpts := getDefaultOptions()
testOpts.withKeys = keys
assert.Equal(opts, testOpts)
})
t.Run("WithSha256Sum", func(t *testing.T) {
// echo "test" | sha256sum
sum := []byte(`f2ca1bb6c7e907d06dafe4687e579fce76b37e4e93b7605022da52e6ccc26fd2`)
assert := assert.New(t)
opts := getOpts(WithSha256Sum(sum))
testOpts := getDefaultOptions()
testOpts.withSha256Sum = sum
assert.Equal(opts, testOpts)
})
}