This service provides information about users' salaries and the date of the next raise based on private access for each user.
NOTE: The instruction below is shown for MacOS.
- Clone the repository to your local machine.
- Navigate to the project directory:
cd <repo_root>. - Install Poetry from the Official page - Poetry.
- Install the project dependencies using Poetry:
poetry install. - Activate poetry environment by
poetry shell.
The service relies on the environment variable called JWT_SECRET_KEY which is neccessary for encoding/decoding token required for JWT based authentication.
- Set
JWT_SECRET_KEYenvironment variable by writing in the terminalopenssl rand -hex 64. Put the result in your profile (e.g.open ~/.zshrc).export JWT_SECRET_KEY=<your value>.
cd <repo_root>.- Do
poetry run pytest ..
- Build the docker image with
docker build --tag employee_service ..
- Run the image by
docker run -dit -p 8000:8000 -e JWT_SECRET_KEY=$JWT_SECRET_KEY --name employee_service employee_service. It will launch the container in the testing mode. This mode has 2 preconfigured users than can be used in the steps below. - Check the container is active by
docker ps. - Open
Postman. If you don't have Postman installed, docurl -LJO "https://dl.pstmn.io/download/latest/osx". - Form
POSTrequest tohttp://0.0.0.0:8000/loginaddress. Use a preconfigured user: { "username": "user1", "password": "password1" } The response will contain an access token in theaccess_tokenfield. - Form
GETrequest tohttp://0.0.0.0:8000/users/salaryaddress by first addingaccess_tokenvalue from the response above to theAuthorizationtab in Postman. Receive response with the particular user'ssalaryandsalary_increase_date. - Stop the docker container by
docker stop <container_id>. - Remove the docker container from your local machine by
docker rm <container_id>.