diff --git a/benchmarktests/target_auth_approle.go b/benchmarktests/target_auth_approle.go index 30e8a110..a4bfb384 100644 --- a/benchmarktests/target_auth_approle.go +++ b/benchmarktests/target_auth_approle.go @@ -36,6 +36,7 @@ type ApproleAuth struct { type ApproleAuthConfig struct { RoleConfig *RoleConfig `hcl:"role,block"` SecretIDConfig *SecretIDConfig `hcl:"secret_id,block"` + SecretIDCount int `hcl:"secret_id_count,optional"` } type RoleConfig struct { @@ -82,6 +83,12 @@ func (a *ApproleAuth) ParseConfig(body hcl.Body) error { return fmt.Errorf("error decoding to struct: %v", diags) } a.config = testConfig.Config + c := a.config + + if c.SecretIDCount < 0 { + return fmt.Errorf("secret_id_count must be >= 0") + } + return nil } @@ -131,6 +138,15 @@ func (a *ApproleAuth) Setup(client *api.Client, mountName string, topLevelConfig roleID := roleIDSecret.Data["role_id"].(string) secretID := secretId.Data["secret_id"].(string) + setupLogger.Debug("generating remaining secret-ids") + for remainingSecretIDs := a.config.SecretIDCount - 1; remainingSecretIDs > 0; remainingSecretIDs-- { + secretIDData, err := structToMap(a.config.SecretIDConfig) + _, err = client.Logical().Write(rolePath+"/secret-id", secretIDData) + if err != nil { + return nil, fmt.Errorf("error generating approle secret-id: %v", err) + } + } + return &ApproleAuth{ header: generateHeader(client), pathPrefix: "/v1/" + filepath.Join("auth", authPath), diff --git a/docs/tests/auth-approle.md b/docs/tests/auth-approle.md index 67642e40..6af4797d 100644 --- a/docs/tests/auth-approle.md +++ b/docs/tests/auth-approle.md @@ -4,6 +4,10 @@ This benchmark tests the performance of logins using the AppRole auth method. ## Benchmark Configuration Parameters +- `secret_id_count` `(integer: 0)` - Number of secret IDs to create during the + setup phase. These secret IDs are not used for the login, just populate + under the mount generated per test. + ### Role Configuration (`role`) - `role_name` `(string: "benchmark-role")` - Name of the AppRole. Must be less than 4096 bytes, accepted characters