Skip to content

Commit

Permalink
S2a options set default LocalIdentity for ClientOptions (matthewsteve…
Browse files Browse the repository at this point in the history
…nson88#61)

* added default identity to clientOptions LocalIdentity

* changed default to nil, added unit test for nil identity
  • Loading branch information
davisgu authored Jul 29, 2020
1 parent 34b2ec4 commit 9226b66
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions security/s2a/s2a_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ func DefaultServerOptions(handshakerAddress string) *ServerOptions {
}

func toProtoIdentity(identity Identity) (*s2apb.Identity, error) {
if identity == nil {
return nil, nil
}
switch id := identity.(type) {
case *spiffeID:
return &s2apb.Identity{IdentityOneof: &s2apb.Identity_SpiffeId{SpiffeId: id.Name()}}, nil
Expand Down
4 changes: 4 additions & 0 deletions security/s2a/s2a_options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func TestToProtoIdentity(t *testing.T) {
IdentityOneof: &s2apb.Identity_Hostname{Hostname: "test_hostname"},
},
},
{
identity: nil,
outIdentity: nil,
},
} {
t.Run(tc.outIdentity.String(), func(t *testing.T) {
protoSpiffeID, err := toProtoIdentity(tc.identity)
Expand Down

0 comments on commit 9226b66

Please sign in to comment.