Skip to main content

API Testing Guide

This document explains how to manually test the backend routes using Postman and curl.


Prerequisites

  • The server is running locally at http://localhost:8080
  • You have a valid Firebase ID token (after sign-in or sign-up)
  • You have created a .env file with correct values

Testing with Postman

1. POST /addUser

  • Method: POST
  • URL: http://localhost:8080/addUser
  • Headers:
    • Authorization: Bearer <firebase_token>
  • Body (JSON):
{
"name": "John Doe",
"email": "john@example.com"
}

2. GET /me

  • Method: GET
  • URL: http://localhost:8080/me
  • Headers:
    • Authorization: Bearer <firebase_token>

3. PATCH /me

  • Method: PATCH
  • URL: http://localhost:8080/me
  • Headers:
    • Authorization: Bearer <firebase_token>
  • Body (JSON):
{
"headline": "Updated headline"
}

4. DELETE /me

  • Method: DELETE
  • URL: http://localhost:8080/me
  • Headers:
    • Authorization: Bearer <firebase_token>

5. GET /validateToken

  • Method: GET
  • URL: http://localhost:8080/validateToken
  • Headers:
    • Authorization: Bearer <firebase_token>

6. POST /public/validateApiToken

  • Method: POST
  • URL: http://localhost:8080/public/validateApiToken
  • Headers:
    • x-api-key: <your_api_token>

Testing with curl (optional)

Example:

curl -X GET http://localhost:8080/me \
-H "Authorization: Bearer <firebase_token>"

Automated Tests (future)

Dart unit tests can be added using the package:test.

To run tests:

dart test

This requires a /test folder and test files.


Last updated: 2025-04-01

Backend

API Testing Guide

This document explains how to manually test the backend routes using Postman and curl.


Prerequisites

  • The server is running locally at http://localhost:8080
  • You have a valid Firebase ID token (after sign-in or sign-up)
  • You have created a .env file with correct values

Testing with Postman

1. POST /addUser

  • Method: POST
  • URL: http://localhost:8080/addUser
  • Headers:
    • Authorization: Bearer <firebase_token>
  • Body (JSON):
{
"name": "John Doe",
"email": "john@example.com"
}

2. GET /me

  • Method: GET
  • URL: http://localhost:8080/me
  • Headers:
    • Authorization: Bearer <firebase_token>

3. PATCH /me

  • Method: PATCH
  • URL: http://localhost:8080/me
  • Headers:
    • Authorization: Bearer <firebase_token>
  • Body (JSON):
{
"headline": "Updated headline"
}

4. DELETE /me

  • Method: DELETE
  • URL: http://localhost:8080/me
  • Headers:
    • Authorization: Bearer <firebase_token>

5. GET /validateToken

  • Method: GET
  • URL: http://localhost:8080/validateToken
  • Headers:
    • Authorization: Bearer <firebase_token>

6. POST /public/validateApiToken

  • Method: POST
  • URL: http://localhost:8080/public/validateApiToken
  • Headers:
    • x-api-key: <your_api_token>

Testing with curl (optional)

Example:

curl -X GET http://localhost:8080/me \
-H "Authorization: Bearer <firebase_token>"

Automated Tests (future)

Dart unit tests can be added using the package:test.

To run tests:

dart test

This requires a /test folder and test files.


Last updated: 2025-04-01