feat(credentials): Refactor credential purposes (#2260)
* feat(credentials): Refactor credential purposes * Application credentials have been refactored to Brokered credentials * Egress credentials have been refactored to Injected Application credentials Co-authored-by: Jeff Mitchell <jeffrey.mitchell@gmail.com>
This commit is contained in:
1 parent
271cc8f781
commit
a17e973712
49 files changed
+1516
-1051
No files matched your search
@@ -18,18 +18,19 @@ func GetOpts(opt ...Option) Options {
|
||||
|
||||
// Options = how options are represented
|
||||
type Options struct {
|
||||
WithEgressCredentials []*serverpb.Credential
|
||||
WithInjectedApplicationCredentials []*serverpb.Credential
|
||||
}
|
||||
|
||||
func getDefaultOptions() Options {
|
||||
return Options{
|
||||
WithEgressCredentials: nil,
|
||||
WithInjectedApplicationCredentials: nil,
|
||||
}
|
||||
}
|
||||
|
||||
// WithEgressCredentials provides an optional egress credentials to use when establishing a proxy
|
||||
func WithEgressCredentials(creds []*serverpb.Credential) Option {
|
||||
// WithInjectedApplicationCredentials provides an optional injected application
|
||||
// credentials to use when establishing a proxy
|
||||
func WithInjectedApplicationCredentials(creds []*serverpb.Credential) Option {
|
||||
return func(o *Options) {
|
||||
o.WithEgressCredentials = creds
|
||||
o.WithInjectedApplicationCredentials = creds
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
func Test_GetOpts(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("WithEgressCredentials", func(t *testing.T) {
|
||||
t.Run("WithInjectedApplicationCredentials", func(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
c := &serverpb.Credential{
|
||||
Credential: &serverpb.Credential_UsernamePassword{
|
||||
@@ -20,10 +20,10 @@ func Test_GetOpts(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}
|
||||
opts := GetOpts(WithEgressCredentials([]*serverpb.Credential{c}))
|
||||
opts := GetOpts(WithInjectedApplicationCredentials([]*serverpb.Credential{c}))
|
||||
testOpts := getDefaultOptions()
|
||||
assert.NotEqual(opts, testOpts)
|
||||
testOpts.WithEgressCredentials = []*serverpb.Credential{c}
|
||||
testOpts.WithInjectedApplicationCredentials = []*serverpb.Credential{c}
|
||||
assert.Equal(opts, testOpts)
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user