Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion coderd/idpsync/idpsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ func ParseStringSliceClaim(claim interface{}) ([]string, error) {
// The simple case is the type is exactly what we expected
asStringArray, ok := claim.([]string)
if ok {
return asStringArray, nil
cpy := make([]string, len(asStringArray))
copy(cpy, asStringArray)
return cpy, nil
}

asArray, ok := claim.([]interface{})
Expand Down
11 changes: 11 additions & 0 deletions coderd/idpsync/idpsync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ func TestParseStringSliceClaim(t *testing.T) {
}
}

func TestParseStringSliceClaimReference(t *testing.T) {
t.Parallel()

var val any = []string{"a", "b", "c"}
parsed, err := idpsync.ParseStringSliceClaim(val)
require.NoError(t, err)

parsed[0] = ""
require.Equal(t, "a", val.([]string)[0], "should not modify original value")
}

func TestIsHTTPError(t *testing.T) {
t.Parallel()

Expand Down
Loading