Scenarii to test the API
Here the URLs and scenarii I used in order to test several API endpoints. This relates to the tests I did on the review of the merge request !142 (merged).
A valid token is needed to perform these operation. The token can be found in the profile page or in the webapp detail in the tab called 'Use the API'.
The curl
argument -k
authorizes the connection without checking the SSL certificate.
# Check if job that doesn't belong to your user send back a 403 (forbidden) http error.
# The error should be return for a job that doesn't belong to the user or doesn't exist in the database
curl -k -H 'Authorization: Token token=<token>' 'https://localhost/api/v1/jobs/<job_id>'
# {"error": "403 Forbidden"}
# Check that you can create a job on a job
# It should return a 'status: waiting' if successful
# This should be tested with the different arguments such as 'queue', 'param', 'files', 'file_url', 'dataset'
curl -k -H 'Authorization: Token token=<token>' 'https://localhost/api/v1/jobs/<job_id>' -F 'job[webapp_id]=<app_id>'
# {"<job_id>": {"status": "waiting", "files": {}}}
# {"<job_id>": {"status": "waiting", "files": {"<filename>": "https://localhost/datastore/<job_id>/<filename>"}}}
# Test if a file can be downloaded
# For a job where one or several files has been updated, test if you can download it
# This can be tested with the 'allgo.log' file which is always generated and stored in the datastore
curl -k -H 'Authorization: Token token=<token>' 'https://localhost/datastore/<job_id>/<file_name>'
# Return the file or a 404 error if the file doesn't exist
# Error types
# {"error": "Unknown queue"}
# curl: (26) couldn't open file "<bad_filename_or_path>"
# {"error": "Application not found"}