Skip to content
RecipesDoc

Scripts That Create and Clean Up Test Accounts Through Your API

Certyn writes small scripts in your repo that create realistic test accounts with different plans and roles, and remove them again, so people and runs can reuse them.

For teams who make test accounts by hand before testing, and want a script for it.

Your setup

  • A web app with plans (free, pro, team) and roles (owner, member).
  • An admin token that can create and delete accounts on staging.
  • A GitHub repo for the scripts.

Say this to Certyn

We need a script that creates test accounts on staging for each plan and role through our API, and one that deletes them. Put them in acme/web under scripts/test-accounts and open a PR.

What Certyn does

  1. Opens secret forms (env_var) for the admin token (ADMIN_API_TOKEN), one password for all test accounts (TEST_ACCOUNT_PASSWORD), and GH_TOKEN if needed (Contents and Pull requests Read and write).
  2. Saves the repo as GITHUB_REPO so later runs find the scripts (you approve).
  3. Clones the repo on its Machine and finds the account and plan endpoints in the code or API spec.
  4. Writes two scripts in your repo's language (Node or Python) on a certyn/<name> branch:
    • create makes one account per plan and role, with realistic names and fixed emails such as qa+pro-owner@acme.test.
    • cleanup deletes only accounts that match that pattern. --dry-run shows what it would delete.
  5. The scripts read TARGET_BASE_URL, the token and the password from environment variables, never from code.
  6. Runs create once on the environment you named, signs in as one new account to check it, and runs cleanup.
  7. Opens a pull request with the scripts, a short README and the test output.
  8. Adds a wiki testing rule, for example Before tests that need a plan or role, run scripts/test-accounts/create.mjs from GITHUB_REPO; run cleanup at the end. Every run reads it.

What you get

  • Two scripts your team owns and can run in its own CI.
  • Runs that create the accounts they need, then remove them.

Limits

  • Use a test environment. Certyn asks before it writes to production.
  • Cleanup can delete only what your API allows. Without a delete endpoint, Certyn says so and the accounts stay.
  • If new accounts must confirm an email, the API needs a way to skip it, for example an admin call that marks the email confirmed.
  • Two runs at the same time share the fixed emails. Ask for a run id in the email if that matters.
  • Certyn never merges.