Skip to content

Commit dfc8ff3

Browse files
committed
fix: maintain original behaviour
1 parent 93a58ff commit dfc8ff3

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ LDFLAGS := -ldflags="-s -w -X \"github.com/$(OWNER)/$(NAME)/cmd.Version=$(VERSIO
99
.PHONY: test test_ci tidy install buildprep build buildmac buildwin
1010

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

1516
test_ci:

cmd/saml.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func getSaml(cmd *cobra.Command, args []string) error {
8989
},
9090
}
9191

92-
saveRole := ""
92+
saveRole := role
9393
if isSso {
9494
sr := strings.Split(ssoRole, ":")
9595
if len(sr) != 2 {

internal/credentialexchange/helper.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ func SessionName(username, selfName string) string {
4343
func InsertRoleIntoChain(role string, roleChain []string) []string {
4444
// IF role is provided it can be assumed from the WEB_ID credentials
4545
// this is to maintain the old implementation
46-
if role != "" {
47-
// could use this experimental slice Insert
48-
// https://pkg.go.dev/golang.org/x/exp/slices#Insert
49-
roleChain = append(roleChain[:0], append([]string{role}, roleChain[0:]...)...)
46+
rc := []string{}
47+
for _, r := range roleChain {
48+
if r != role {
49+
rc = append(rc, r)
50+
}
5051
}
51-
return roleChain
52+
53+
return rc
5254
}
5355

5456
func SetCredentials(creds *AWSCredentials, config CredentialConfig) error {

internal/credentialexchange/helper_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ func Test_InsertIntoRoleSlice_with(t *testing.T) {
109109
expect []string
110110
}{
111111
"chain empty and role specified": {
112-
"role", []string{}, []string{"role"},
112+
"role", []string{}, []string{},
113113
},
114114
"chain set and role empty": {
115115
"", []string{"rolec1"}, []string{"rolec1"},
116116
},
117117
"both set and role is always first in list": {
118-
"role", []string{"rolec1"}, []string{"role", "rolec1"},
118+
"role", []string{"rolec1"}, []string{"rolec1"},
119119
},
120120
}
121121
for name, tt := range ttests {

0 commit comments

Comments
 (0)