Skip to content

LoFor1t/WinWinTest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WinWinTest Stack

This workspace runs two Spring Boot services (ProjectA and ProjectB) plus a Postgres database. ProjectA exposes the public API for registering/logging-in users and processing text; ProjectB performs the text transformation and is protected by an internal token.

Prerequisites

  • Docker Desktop (or Docker Engine + Docker Compose plugin)
  • Java 21 and Maven if you want to build locally outside of Docker
  • macOS only: make sure Docker Desktop can access init.sql file. Run:
    defaults write com.docker.docker FilesharingDirectories -array-add "path/to/init.sql" \
      && killall Docker || true \
      && open -a Docker
    This adds path to init.sql to Docker Desktop’s file-sharing list so Postgres can mount the init script. (Reopen Docker Desktop if it restarts.)

Run Example

1) Build & Start

docker compose up -d --build

The Maven steps compile each service so the Docker builds can reuse the pre-built JARs from target/. The compose command starts ProjectA on http://localhost:8080, ProjectB on http://localhost:8081, and Postgres on localhost:5432.

2) Register & Login

curl -X POST http://localhost:8080/api/auth/register \
  -H "Content-Type: application/json" \
  -d '{"email":"a@a.com","password":"longpassword1234"}'

curl -X POST http://localhost:8080/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"a@a.com","password":"longpassword1234"}'

The login response returns { "token": "<jwt>" }. Save that JWT for the next step.

3) Process Text

TOKEN=<paste-jwt-here>

curl -X POST http://localhost:8080/api/process \
  -H "Authorization: Bearer ${TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"text":"hello"}'

Expected response:

{"processedText":"OLLEH"}

You should also see a new row in the tb_process_logs table:

docker exec -it postgres psql -U projecta -d projecta \
  -c "SELECT id, input_text, output_text, result_code FROM tb_process_logs ORDER BY created_at DESC LIMIT 1;"

Stopping the Stack

docker compose down

Add -v if you want to remove the Postgres volume.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published