Goal is to register an user and send them an email with the auth code to validate the registration.
docs/
contains the architecture schema.email_server_mock/
contains the mock of the email server.src/
contains the code for the user-apitest/
contains all the unit tests.
- Structure of the repo
- C4 schema of the solution.
- Docker deployment
- docker-compose deployment with DB
- Setup the db
- User registration logic
- Create user
- Send email to user containing the code
- docker-compose deployment with DB and mocked email server
- Email sender
- Validate activation code
- Pretify code
- Add more doc in README
- Unvalidate the
activate
call if the call comes more than 1min after theregister
call
docker-compose up -d
Go to http://localhost:8000/docs
to see the docs of the API
The flow works like this:
- User registers by calling
/register
API withemail
andpassword
in the body of the request. - We store the details in our db.
- We send an email to the user using the
email_server_mock
. In this example, since the email is not sent, check for the log of email server.
The code in this example is 4466
-
Call
/activate
using previous email and passwordBASIC AUTH
. As body, give theactivation_code
retrieved in the previous step. Hurry up! You will have only 1 min to use this code. -
2 possibilities:
a. If it is used in less than 1 min --> Success! Your user has been activated.
b. If it is used after 1 min --> Failure! The code has expired.
Same as above but building the source code every time
docker-compose up --build
# Install general dependencies
pip install -r requirements.txt
# To install pytest + test dependencies
pip install -r requirements.test.txt
# Run the tests
TEST_MODE=true python3 -m pytest
Run tests with debug logging
TEST_MODE=true python3 -m pytest --log-cli-level=DEBUG -rP
Run the tests to see the coverage
TEST_MODE=true python3 -m pytest --cov