Skip to content
Open
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
16 changes: 16 additions & 0 deletions benchmarktests/target_auth_approle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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),
Expand Down
4 changes: 4 additions & 0 deletions docs/tests/auth-approle.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading