feat: support verified bulk load-test setup

This commit is contained in:
richjohnrambo
2026-09-27 01:34:39 +08:00
parent 021169555a
commit b3b5dd55a6
8 changed files with 272 additions and 47 deletions
+15 -4
View File
@@ -119,12 +119,12 @@ func connectWSClient(ctx context.Context, cfg *Config, account AccountRecord, ap
return client, nil
}
func connectForPrepare(ctx context.Context, cfg *Config, account AccountRecord, apiKey, password string) (*WSClient, bool, error) {
func connectForPrepare(ctx context.Context, cfg *Config, account AccountRecord, api *apiClient, password, verificationCode string) (*WSClient, bool, error) {
timeout, err := configDuration(cfg.CommandTimeout)
if err != nil {
return nil, false, err
}
endpoint, err := websocketEndpoint(account.Endpoint, apiKey)
endpoint, err := websocketEndpoint(account.Endpoint, api.apiKey)
if err != nil {
return nil, false, err
}
@@ -156,11 +156,22 @@ func connectForPrepare(ctx context.Context, cfg *Config, account AccountRecord,
client.Close()
return nil, false, loginErr
}
ctrl, err = client.command(ctx, "acc", map[string]any{"acc": map[string]any{
credential, credentialErr := api.createRegistrationCredential(ctx, account, verificationCode)
if credentialErr != nil {
client.Close()
return nil, false, credentialErr
}
acc := map[string]any{
"id": client.nextID("acc"), "user": "new", "scheme": "basic", "username": account.Username,
"registration_type": 0, "tenant_code": cfg.Tenant, "secret": secret, "login": true,
"desc": map[string]any{"public": map[string]any{"fn": strings.ToUpper(account.Username)}},
}})
}
if credential != nil {
acc["phone"] = account.Phone
acc["cred"] = []map[string]any{{"meth": "tel", "val": account.Phone,
"resp": credential.VerificationToken, "params": map[string]any{"challenge_id": credential.ChallengeID}}}
}
ctrl, err = client.command(ctx, "acc", map[string]any{"acc": acc})
if err != nil {
client.Close()
return nil, false, err