Skip to content

API Test Harness Scaffold

This assignment guides you through building a reusable command-line tool for testing REST APIs. The goal is to create a harness that can issue requests to any endpoint, capture responses, and save logs for later analysis.

Objectives

  1. Reusable – Accept base URLs, endpoints, and authentication details via configuration.
  2. Flexible – Support common HTTP methods (GET, POST, PUT, DELETE) and arbitrary headers.
  3. Observable – Output request/response data in both the console and log files for debugging.
  4. Extensible – Structure the project so additional features (e.g., concurrency, authentication plugins) can be added later.

Setup

  1. Create a new Python project using venv or conda.
  2. Install required packages:
    pip install requests pyyaml
    
  3. Scaffold the following files:
  4. harness.py – main entry point for executing API calls.
  5. config.yaml – stores base URL, default headers, and auth tokens.
  6. README.md – usage instructions.

Basic Flow

flowchart TD
    Start(["Run harness.py"]) --> LoadConfig{{"Read config.yaml"}}
    LoadConfig --> BuildRequest{{"Construct HTTP request"}}
    BuildRequest --> Send["Send request via requests library"]
    Send --> Log["Log response status and body"]
    Log --> End(["Save log & exit"])

Example Configuration

base_url: "https://api.example.com"
endpoints:
  - path: "/users"
    method: "GET"
  - path: "/posts"
    method: "POST"
    body: {}
headers:
  Authorization: "Bearer <token>"

Deliverables

  1. Working harness.py capable of reading config.yaml and making requests.
  2. Example log file showing successful calls to two sample endpoints.
  3. Updated README.md describing setup, configuration options, and how to extend the tool.

Submission

Push your code to the provided repository and open a pull request. Include screenshots or log snippets demonstrating your harness successfully calling at least two endpoints. Mention any known limitations or future improvement ideas in the PR description.