# Public API end to end tests
###### tags: `Reminiz` `API` `Tests`
# Public API endpoints
Our public API, for its 1st published version, is prefixed with the path `/v1/`.
It includes 5 endpoints, grouped into 4 categories:
- Authentication (1 endpoint)
- Health (1 endpoint)
- Metrics (1 endpoint)
- Videos (2 endpoints)
We'll dig these categories and endpoints in the next few lines.
## Authentication
### Endpoint `POST /v1/token` - Public
To use our API, some of the endpoints needs the user to be authenticated, with a token.
The endpoint is public, and allows users to fetch a token valid for 24 hours.
The only accepted payload is an url-encoded form data, with `username` and `password`.
For 4XX response, we also check EXACTLY the json response.
For 20X response, we check json response, when we can expect some field values. We check for ALL needed fields.
#### Tests
- Test wrong payloads:
- [x] username not present -> 422 error
- [x] password not present -> 422 error
- [x] none of them present -> 422 error
- [x] wrong combination username/password -> 401 error
- [x] too much field with wrong username/password -> 401 error
- [x] json payload instead of form-data -> 422 error
- Test with good credentials (we also test some fields in response when necessary)
- [x] test active customer -> 200 OK
- [x] test disabled customer -> 403 error
- [x] test active manager -> 200 OK
- [x] test disabled manager -> 403 error
- [x] too much field with good username/password -> 200 OK
## Health
### Endpoint: `GET /v1/health` - public
This endpoint is present to check whether a backend is alive or not.
#### Tests
- [ ] Test when backend is up and running -> 200 OK with {"status": "OK"}
- [ ] Test when backend is not running -> ?
## Metrics
### Endpoint: `GET /v1/metrics` - private
To check the load average for a specific client, we use this endpoint.
#### Tests
**TODO**: asks for the right thing to test for this endpoint ...
## Videos
### Endpoint `POST /v1/videos` - private
#### Tests
- [x] test without token in headers -> 401 error
- [x] test with wrong payload (missing fields) -> 422 error
- [x] test with with formdata instead of json -> 400 error
- [ ] test with a good payload -> 201 OK