Class: SpreeCmCommissioner::LoadTest::CreateAccounts
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::LoadTest::CreateAccounts
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree_cm_commissioner/load_test/create_accounts.rb
Overview
Creates N load-test accounts (tenant-scoped when client_id given, platform accounts otherwise). Each gets a unique random email — "#email_prefix_#hex@#domain" — so runs are NOT idempotent: every call adds N fresh accounts to the pool (unlike the old +1/+2/+N scheme, random emails can't be matched to skip or reuse existing rows). Clean up with LoadTest::DestroyAccounts, which removes them by the load_test_account flag, not by email.
Accounts are flagged load_test_account and can never authenticate with a real password —
from any client, mobile app included (see SpreeCmCommissioner::UserPasswordAuthenticator).
This service only creates the account pool; it does NOT mint login tokens. Login tokens are
stateless, signed JWTs minted on demand from the admin UI (see LoginToken) — an account needs
nothing stored on it beyond the flag.
Instance Method Summary collapse
Instance Method Details
#call(client_id: nil, count: 20, email_prefix: 'loadtest', email_domain: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/spree_cm_commissioner/load_test/create_accounts.rb', line 17 def call(client_id: nil, count: 20, email_prefix: 'loadtest', email_domain: nil) tenant = resolve_tenant(client_id) domain = email_domain.presence || (tenant ? "#{tenant.slug}.test" : 'bookmeplus.test') accounts = Array.new(count) { create_account!(email: unique_email(email_prefix, domain), tenant: tenant) } success(created: accounts.size, accounts: accounts.map { |user| account_row(user) }, email_domain: domain) rescue StandardError => e failure(nil, e.) end |