This keeps only essential information in list output for auth methods when the user is u_anon. Boundary's default is to allow listing of auth methods for anonymous users to allow discovery of authentication points, but there's no need to return more information about internal configuration than necessary.
50 lines
1.1 KiB
Go
50 lines
1.1 KiB
Go
package handlers
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/hashicorp/go-hclog"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// Test_GetOpts provides unit tests for GetOpts and all the options
|
|
func Test_GetOpts(t *testing.T) {
|
|
t.Parallel()
|
|
t.Run("WithDiscardUnknownFields", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
opts := GetOpts()
|
|
testOpts := getDefaultOptions()
|
|
assert.Equal(opts, testOpts)
|
|
|
|
opts = GetOpts(WithDiscardUnknownFields(true))
|
|
testOpts = getDefaultOptions()
|
|
testOpts.withDiscardUnknownFields = true
|
|
assert.Equal(opts, testOpts)
|
|
|
|
opts = GetOpts(WithDiscardUnknownFields(false))
|
|
testOpts = getDefaultOptions()
|
|
testOpts.withDiscardUnknownFields = false
|
|
assert.Equal(opts, testOpts)
|
|
})
|
|
t.Run("WithLogger", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
opts := GetOpts()
|
|
assert.Nil(opts.WithLogger)
|
|
|
|
opts = GetOpts(WithLogger(hclog.New(nil)))
|
|
assert.NotNil(opts.WithLogger)
|
|
})
|
|
|
|
t.Run("WithAnonymousListing", func(t *testing.T) {
|
|
assert := assert.New(t)
|
|
|
|
opts := GetOpts()
|
|
assert.False(opts.WithAnonymousListing)
|
|
|
|
opts = GetOpts(WithAnonymousListing(true))
|
|
assert.True(opts.WithAnonymousListing)
|
|
})
|
|
}
|