You can both manually and automatically test the application. See below for more information.
docker pull ghcr.io/louissullivan4/stewauth:1.2.0
Create a .env.test file in the current directory and include the following variables:
- JWT_SECRET: A randomly generated JWT secret.
- PORT: The port number on which the service will run (default is 3005).
- MONGO_URI: TO YOUR TESTING DATABASE. THIS IS IMPORTANT AS IT WILL CLEAR YOUR DATABASE ON RUNNING.
- CLEAR_DB: Set to true to delete the database on startup. CAUTION!!!
- DISABLE_RATE_LIMIT: Set to true to avoid rate limiting errors. CAUTION!!!
- NODE_ENV: set to test to run npm test
JWT_SECRET=your_random_secret
PORT=3005
MONGO_URI=mongodb://localhost:27017/TESTDBNAME
CLEAR_DB=true
DISABLE_RATE_LIMIT=true
NODE_ENV=test
Run the Docker image with the following command, passing the .env file:
docker run --env-file .env.test -p 3005:3005 ghcr.io/louissullivan4/stewauth:1.2.0
- Linux/Mac:
curl -X POST http://localhost:3005/auth/signup -H "Content-Type: application/json" -d '{"username": "[email protected]", "password": "Password123!"}'
- Windows:
curl -X POST http://localhost:3005/auth/signup -H "Content-Type: application/json" -d "{\"username\": \"[email protected]\", \"password\": \"Password123!\"}"
2. Creating a New User with Invalid credentials (i.e. password must be at least 8 chars, at least 1 capital letter, at least 1 symbol and at least 1 number)
- Linux/Mac:
curl -X POST http://localhost:3005/auth/signup -H "Content-Type: application/json" -d '{"username": "[email protected]", "password": "abc"}'
- Windows:
curl -X POST http://localhost:3005/auth/signup -H "Content-Type: application/json" -d "{\"username\": \"[email protected]\", \"password\": \"abc\"}"
- Linux/Mac:
curl -X POST http://localhost:3005/auth/signup -H "Content-Type: application/json" -d '{"username": "[email protected]", "password": "Password123!"}'
- Windows:
curl -X POST http://localhost:3005/auth/signup -H "Content-Type: application/json" -d "{\"username\": \"[email protected]\", \"password\": \"Password123!\"}"
- Linux/Mac:
curl -X POST http://localhost:3005/auth/login -H "Content-Type: application/json" -d '{"username": "[email protected]", "password": "Password123!"}'
- Windows:
curl -X POST http://localhost:3005/auth/login -H "Content-Type: application/json" -d "{\"username\": \"[email protected]\", \"password\": \"Password123!\"}"
- Linux/Mac:
curl -X POST http://localhost:3005/auth/login -H "Content-Type: application/json" -d '{"username": "[email protected]", "password": "Password123!"}'
- Windows:
curl -X POST http://localhost:3005/auth/login -H "Content-Type: application/json" -d "{\"username\": \"[email protected]\", \"password\": \"Password123!\"}"
- Linux/Mac:
curl -X POST http://localhost:3005/auth/login -H "Content-Type: application/json" -d '{"username": "[email protected]", "password": "Wrongpassword123!"}'
- Windows:
curl -X POST http://localhost:3005/auth/login -H "Content-Type: application/json" -d "{\"username\": \"[email protected]\", \"password\": \"Wrongpassword123!\"}"