1 parent
0b6530b8b6
commit
a1718effba
9 files changed
+44
-7
No files matched your search
@@ -4,6 +4,8 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"io"
|
||||
"net"
|
||||
|
||||
serverpb "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||
@@ -32,6 +34,7 @@ type Options struct {
|
||||
WithTestKerberosServerHostname string
|
||||
WithLogger hclog.Logger
|
||||
WithSshHostKeyCallback ssh.HostKeyCallback
|
||||
WithRandomReader io.Reader
|
||||
}
|
||||
|
||||
func getDefaultOptions() Options {
|
||||
@@ -39,6 +42,7 @@ func getDefaultOptions() Options {
|
||||
WithInjectedApplicationCredentials: nil,
|
||||
WithPostConnectionHook: nil,
|
||||
WithLogger: hclog.NewNullLogger(),
|
||||
WithRandomReader: rand.Reader,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,3 +101,10 @@ func WithSshHostKeyCallback(with ssh.HostKeyCallback) Option {
|
||||
o.WithSshHostKeyCallback = with
|
||||
}
|
||||
}
|
||||
|
||||
// WithRandomReader provides an option to specify a random reader.
|
||||
func WithRandomReader(reader io.Reader) Option {
|
||||
return func(o *Options) {
|
||||
o.WithRandomReader = reader
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,11 @@ package proxy
|
||||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"io"
|
||||
"net"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
serverpb "github.com/hashicorp/boundary/internal/gen/controller/servers/services"
|
||||
@@ -76,4 +78,11 @@ func Test_GetOpts(t *testing.T) {
|
||||
opts = GetOpts(WithSshHostKeyCallback(ssh.FixedHostKey(signer.PublicKey())))
|
||||
assert.NotNil(opts.WithSshHostKeyCallback)
|
||||
})
|
||||
t.Run("WithRandomReader", func(t *testing.T) {
|
||||
reader := io.Reader(&strings.Reader{})
|
||||
opts := GetOpts(WithRandomReader(reader))
|
||||
testOpts := getDefaultOptions()
|
||||
testOpts.WithRandomReader = reader
|
||||
assert.Equal(t, opts, testOpts)
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user