This Python script tests a login API using POST requests. It sends requests with both valid and invalid credentials and checks the API's response.
-
Python 3.x
-
requestslibrary: You can install it using pip:pip install requests
-
Clone the repository (if you haven't already):
git clone [https://github.com/Kmwas/lemonade-login.git](https://github.com/Kmwas/lemonade-login.git) # Replace with your repo URL cd lemonade-login
-
Replace the test API endpoint:
Open
test_login_api.pyand replace"https://test_api_endpoint"with the actual URL of the API you want to test. Do not use a production API endpoint for testing.api_url = "https://your_test_api_endpoint" # Replace with your test endpoint
-
Run the script:
python test_login_api.py
The script uses the requests library to send POST requests to the login API. The test_login_api function takes a username and password as arguments, sends the request, and checks the response for a "token" upon successful authentication. It also handles potential errors during the request.