-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
161 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,161 @@ | ||
# ll-employee-manager | ||
Luizalabs Employee Manager Challenge Application | ||
# LuizaLabs Employee Manager Challenge Application | ||
[![Build Status](https://travis-ci.org/dutradda/ll-employee-manager.svg?branch=master)](https://travis-ci.org/dutradda/ll-employee-manager) [![Coverage Status](https://coveralls.io/repos/github/dutradda/ll-employee-manager/badge.svg?branch=master)](https://coveralls.io/github/dutradda/ll-employee-manager?branch=master) | ||
|
||
## This is a simple application to manage employees. | ||
|
||
The application uses a Makefile to support the development and run docker commands. | ||
|
||
- Running the tests: | ||
|
||
```shell | ||
$ make integration | ||
``` | ||
|
||
- Serving the application for development: | ||
|
||
```shell | ||
$ make dev-server | ||
``` | ||
|
||
- Only running the `make` command will run the integration and after the dev-server rules. | ||
|
||
```shell | ||
$ make | ||
``` | ||
|
||
- Running the deployment version of the server (with gunicorn): | ||
|
||
```shell | ||
$ make run-deploy | ||
``` | ||
|
||
- Running the develop environment with a new database: | ||
|
||
```shell | ||
$ mv db.sqlite3 db.sqlite3.bkp && \ | ||
make dev-migrate && \ | ||
make dev-superuser && \ | ||
make dev-server | ||
``` | ||
|
||
### Features | ||
|
||
- Private endpoints for `write` access (the users are the same of the django admin) | ||
- Public endpoints for `read-only` access | ||
- Email validation | ||
|
||
|
||
### API Examples | ||
|
||
- Adding a new employee (with the default database): | ||
```shell | ||
$ curl -i -H 'Content-Type: application/json' -X POST -u admin:password123 '127.0.0.1:8000/employee' -d ' | ||
{ | ||
"name": "Diogo", | ||
"email": "diogo@luizalabs.com", | ||
"department": "Architecture" | ||
}' | ||
HTTP/1.1 201 Created | ||
Server: WSGIServer/0.2 CPython/3.7.0b3 | ||
Content-Type: application/json | ||
Vary: Accept, Cookie | ||
Allow: GET, POST, HEAD, OPTIONS | ||
X-Frame-Options: SAMEORIGIN | ||
Content-Length: 87 | ||
|
||
{ | ||
"name": "Diogo", | ||
"email": "diogo@luizalabs.com", | ||
"department": "Architecture" | ||
} | ||
``` | ||
|
||
- Getting the employees: | ||
```shell | ||
$ curl -i '127.0.0.1:8000/employee' | ||
HTTP/1.1 200 OK | ||
Server: WSGIServer/0.2 CPython/3.7.0b3 | ||
Content-Type: application/json | ||
Vary: Accept, Cookie | ||
Allow: GET, POST, HEAD, OPTIONS | ||
X-Frame-Options: SAMEORIGIN | ||
Content-Length: 422 | ||
|
||
[ | ||
{ | ||
"name": "Arnaldo Pereira", | ||
"email": "arnaldo@luizalabs.com", | ||
"department": "Architecture" | ||
}, | ||
{ | ||
"name": "Renato Pedigoni", | ||
"email": "renato@luizalabs.com", | ||
"department": "E-commerce" | ||
}, | ||
{ | ||
"name": "Thiago Catoto", | ||
"email": "catoto@luizalabs.com", | ||
"department": "Mobile" | ||
}, | ||
{ | ||
"name": "Diogo", | ||
"email": "diogo@luizalabs.com", | ||
"department": "Architecture" | ||
} | ||
] | ||
``` | ||
|
||
- Trying to add an employee without credentials: | ||
```shell | ||
$ curl -i -H 'Content-Type: application/json' -X POST '127.0.0.1:8000/employee' -d ' | ||
{ | ||
"name": "Diogo", | ||
"email": "diogo@luizalabs.com", | ||
"department": "Architecture" | ||
}' | ||
HTTP/1.1 403 Forbidden | ||
Server: WSGIServer/0.2 CPython/3.7.0b3 | ||
Content-Type: application/json | ||
Vary: Accept, Cookie | ||
Allow: GET, POST, HEAD, OPTIONS | ||
X-Frame-Options: SAMEORIGIN | ||
Content-Length: 63 | ||
|
||
{ | ||
"detail": "Authentication credentials were not provided." | ||
} | ||
``` | ||
|
||
- Trying to add an employee without a valid email address: | ||
```shell | ||
$ curl -i -H 'Content-Type: application/json' -X POST -u admin:password123 '127.0.0.1:8000/employee' -d ' | ||
{ | ||
"name": "Diogo", | ||
"email": "diogo@luizalabs", | ||
"department": "Architecture" | ||
}' | ||
HTTP/1.1 400 Bad Request | ||
Server: WSGIServer/0.2 CPython/3.7.0b3 | ||
Content-Type: application/json | ||
Vary: Accept, Cookie | ||
Allow: GET, POST, HEAD, OPTIONS | ||
X-Frame-Options: SAMEORIGIN | ||
Content-Length: 48 | ||
|
||
{ | ||
"email": [ | ||
"Invalid email address" | ||
] | ||
} | ||
``` | ||
|
||
- Removing an employee :( | ||
```shell | ||
$ curl -i -X DELETE -u admin:password123 '127.0.0.1:8000/employee/7' | ||
HTTP/1.1 204 No Content | ||
Server: WSGIServer/0.2 CPython/3.7.0b3 | ||
Vary: Accept, Cookie | ||
Allow: GET, PUT, PATCH, DELETE, HEAD, OPTIONS | ||
X-Frame-Options: SAMEORIGIN | ||
Content-Length: 0 | ||
``` |