@@ -106,21 +106,31 @@ func Test_InsertIntoRoleSlice_with(t *testing.T) {
106106 ttests := map [string ]struct {
107107 role string
108108 roleChain []string
109+ isSso bool
109110 expect []string
110111 }{
111- "chain empty and role specified" : {
112- "role" , []string {}, []string {},
112+ "chain empty and role specified with insertRoleIntoChain as false " : {
113+ "role" , []string {}, false , []string {},
113114 },
114- "chain set and role empty" : {
115- "" , []string {"rolec1" }, []string {"rolec1" },
115+ "chain set and role empty with insertRoleIntoChain as false " : {
116+ "" , []string {"rolec1" }, false , []string {"rolec1" },
116117 },
117- "both set and role is always first in list" : {
118- "role" , []string {"rolec1" }, []string {"rolec1" },
118+ "both set and role is always first in list with insertRoleIntoChain as false" : {
119+ "role" , []string {"rolec1" }, false , []string {"rolec1" },
120+ },
121+ "chain empty and role specified with insertRoleIntoChain as true" : {
122+ "role" , []string {}, true , []string {"role" },
123+ },
124+ "chain set and role empty with insertRoleIntoChain as true" : {
125+ "" , []string {"rolec1" }, true , []string {"rolec1" },
126+ },
127+ "both set and role is always first in list with insertRoleIntoChain as true" : {
128+ "role" , []string {"rolec1" }, true , []string {"role" , "rolec1" },
119129 },
120130 }
121131 for name , tt := range ttests {
122132 t .Run (name , func (t * testing.T ) {
123- if got := credentialexchange .InsertRoleIntoChain (tt .role , tt .roleChain ); len (got ) != len (tt .expect ) {
133+ if got := credentialexchange .MergeRoleChain (tt .role , tt .roleChain , tt . isSso ); len (got ) != len (tt .expect ) {
124134 t .Errorf ("expected: %v, got: %v" , tt .expect , got )
125135 }
126136 })
0 commit comments