Skip to content

Commit

Permalink
fix: maintain original behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
dnitsch committed Jan 30, 2024
1 parent 93a58ff commit dfc8ff3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ LDFLAGS := -ldflags="-s -w -X \"github.com/$(OWNER)/$(NAME)/cmd.Version=$(VERSIO
.PHONY: test test_ci tidy install buildprep build buildmac buildwin

test: test_prereq
go test ./... -v -mod=readonly -coverprofile=.coverage/out | go-junit-report > .coverage/report-junit.xml && \
go test ./... -v -mod=readonly -coverprofile=.coverage/out && \
cat .coverage/out | go-junit-report > .coverage/report-junit.xml && \
gocov convert .coverage/out | gocov-xml > .coverage/report-cobertura.xml

test_ci:
Expand Down
2 changes: 1 addition & 1 deletion cmd/saml.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func getSaml(cmd *cobra.Command, args []string) error {
},
}

saveRole := ""
saveRole := role
if isSso {
sr := strings.Split(ssoRole, ":")
if len(sr) != 2 {
Expand Down
12 changes: 7 additions & 5 deletions internal/credentialexchange/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ func SessionName(username, selfName string) string {
func InsertRoleIntoChain(role string, roleChain []string) []string {
// IF role is provided it can be assumed from the WEB_ID credentials
// this is to maintain the old implementation
if role != "" {
// could use this experimental slice Insert
// https://pkg.go.dev/golang.org/x/exp/slices#Insert
roleChain = append(roleChain[:0], append([]string{role}, roleChain[0:]...)...)
rc := []string{}
for _, r := range roleChain {
if r != role {
rc = append(rc, r)
}
}
return roleChain

return rc
}

func SetCredentials(creds *AWSCredentials, config CredentialConfig) error {
Expand Down
4 changes: 2 additions & 2 deletions internal/credentialexchange/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ func Test_InsertIntoRoleSlice_with(t *testing.T) {
expect []string
}{
"chain empty and role specified": {
"role", []string{}, []string{"role"},
"role", []string{}, []string{},
},
"chain set and role empty": {
"", []string{"rolec1"}, []string{"rolec1"},
},
"both set and role is always first in list": {
"role", []string{"rolec1"}, []string{"role", "rolec1"},
"role", []string{"rolec1"}, []string{"rolec1"},
},
}
for name, tt := range ttests {
Expand Down

0 comments on commit dfc8ff3

Please sign in to comment.