API test automation suite for the Login → Get Product chain, built against the public dummyjson.com REST API. Written as a live take-home exercise for a CRED interview, using AI-assisted development.
- Auth (
/auth/login) — valid login, invalid credentials, missing fields, malformed JSON bodies, case-insensitive usernames, password never leaked in responses, extra/unknown fields ignored. - Products (
/products/:id) — fetching a product by id, chained auth-token usage, 404 on unknown id, boundary value analysis (BVA) around the valid id range, invalid id shapes (negative, decimal, non-numeric, overflow, injection-style), and authorization header edge cases.
| File | Purpose |
|---|---|
client.py |
Thin ApiClient wrapper around requests for login and product lookups. |
conftest.py |
Shared pytest fixtures (api_client, authenticated_client, credentials, product_total). |
test_auth.py |
Baseline auth happy-path / bad-password tests. |
test_auth_negative.py |
Negative and edge-case auth tests. |
test_products.py |
Baseline product lookup tests. |
test_products_negative_bva.py |
Boundary value analysis and negative tests for product ids. |
run_tests.py |
Standalone, dependency-free JSON-driven test runner (stdlib only) that executes scenarios from test-scenarios.json. |
test-scenarios.json |
Declarative upstream/downstream (login → product) test scenarios consumed by run_tests.py. |
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.example .envEnvironment variables (see .env.example):
| Variable | Default | Description |
|---|---|---|
BASE_URL |
https://dummyjson.com |
API base URL |
TEST_USERNAME |
emilys |
Test account username |
TEST_PASSWORD |
emilyspass |
Test account password |
pytest -vpython run_tests.pyReads test-scenarios.json, logs in once for a shared token, then runs each
scenario's upstream (login) and downstream (product) calls, asserting status
codes, response shape, and field types.