This is a simple proxy service, which proxies any POST request coming in to downstream server.
Following are the technical requirements:
- The proxy expects a json request body
- The json body should always contain a key called "user" else it should throw an error and return 400
- The proxy expects a json response body from downstream server
- The response json body from downstream server should always contain a key called "user" else it should throw an error and return 400.
- The "user" key from the response body will be removed and rest of the body will be returned from proxy server
- Python version: 3.12
- uv installed: https://docs.astral.sh/uv/getting-started/installation/
uv syncto create and install dependencies- Service configuration can be found in
config.py
uv run main.py
You should see following:
INFO: Started server process [50724]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://localhost:8000 (Press CTRL+C to quit)
POST http://localhost:8000/api/login
Request Body:
{
"user": 40,
"password": "12345"
}
Response Body:
{
"token": "abc123xyz",
"expires_in": 3600
}
-
Please write automation tests for the above requirements. You can use any langugage or framework you are comfortable in.
-
Please also propose how can this service be tested manually.
- What is a proxy: https://en.wikipedia.org/wiki/Proxy_server
- You might need to create a downstream service for your testing ( see
config.py,PROXY_TARGET_HOSTandPROXY_TARGET_PORTto configure proxy to connect to downstream service)