Skip to content

Commit

Permalink
add randomness to signin
Browse files Browse the repository at this point in the history
  • Loading branch information
elliesterner committed Jul 10, 2023
1 parent 251f15c commit 38fc1f7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions benchmarktests/target_auth_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"flag"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"net/url"
"path/filepath"
Expand Down Expand Up @@ -195,8 +196,11 @@ func (g *GCPAuth) Setup(client *api.Client, randomMountName bool, mountName stri
return nil, fmt.Errorf("error writing gcp role: %v", err)
}

// TODO: handle more than one service account
jwt, err := getSignedJwt(g.config.Config.GCPTestRoleConfig.Name, config.GCPAuthConfig.Credentials, config.GCPTestRoleConfig.MaxJWTExp, config.GCPTestRoleConfig.BoundServiceAccounts[0])
// Select one of the configured service accounts if more than 1
rand.Seed(time.Now().Unix())
n := rand.Int() % len(config.GCPTestRoleConfig.BoundServiceAccounts)

jwt, err := getSignedJwt(g.config.Config.GCPTestRoleConfig.Name, config.GCPAuthConfig.Credentials, config.GCPTestRoleConfig.MaxJWTExp, config.GCPTestRoleConfig.BoundServiceAccounts[n])
if err != nil {
return nil, fmt.Errorf("error fetching JWT: %v", err)
}
Expand Down

0 comments on commit 38fc1f7

Please sign in to comment.