Skip to main content
Below is a Locustfile that demonstrates how to:
  1. Authenticate with Azure AD and obtain an access token.
  2. Store and reuse cookies (e.g., AspNetCore.Antiforgery, AspNetCore.Cookies).
  3. Call endpoints with correct headers while handling stateful session data.

Example test script for LoadForge

This script:
  • Logs in to Azure AD using client credentials.
  • Stores and manages cookies and tokens.
  • Executes requests in a simulated user flow.

Key Features

  1. OAuth2 Token Handling
    • Retrieves an access token from Azure AD.
    • Uses client credentials flow (modify if using user authentication).
  2. Session Management
    • Stores ASP.NET Core antiforgery tokens and cookies dynamically.
    • Ensures requests include required headers.
  3. User Flow Simulation
    • Starts with a login request to set up cookies.
    • Calls /dashboard (or another resource) with authentication headers.
    • Simulates an event signup to test form submissions.

Modifications for Your Portal

  • Update Azure AD settings (replace YOUR_TENANT_ID, YOUR_CLIENT_ID, etc.).
  • Change request endpoints (/login, /dashboard, /event/signup) to match your portal.
  • Modify authentication grant type if using authorization code flow.