Una API REST para acceder a la administración de usuarios y grupos en en Samba4
apt install pipenv git curl jq
git clone [email protected]:VTacius/justine-api.git
cd justine-api
python setup.py develop
- Creamos dos usuarios y un grupo que usaremos en las pruebas automatizadas
samba-tool group add http_access --nis-domain=DOMINIO.COM --gid-number=1001 --description "Grupos para acceso web"
samba-tool user create alortiz P.4ssw0rd --nis-domain=DOMINIO.COM --unix-home=/home/alortiz --uid-number=1002 --login-shell=/bin/false --gid-number=1001
samba-tool user create opineda P.4ssw0rd --nis-domain=DOMINIO.COM --unix-home=/home/opineda --uid-number=1003 --login-shell=/bin/false --gid-number=1001
- Obtenemos el token con el que vamos a realizar todas las demás operaciones
curl -s -L -XPOST -H 'Content-Type: application/json' 127.0.0.1:6543/auth/tokenizador --user alortiz -d '{"direccion": "alortiz", "rol": "administrador"}' | jq '.token'
- Listamos los usuarios disponibles en el directorio
curl -s -L XGET -H 'Content-Type: application/json' -H "www-authorization: $TOKEN" 127.0.0.1:6543/usuarios | jq
- Creamos un usuario
curl -s -L -XPOST -H 'Content-Type: application/json' -H "www-authorization: $TOKEN" 127.0.0.1:6543/usuarios -d @datos.d/usuario_creacion.json | jq
- Obtenemos los datos del usuario que acabamos de crear
curl -s -L -XGET -H 'Content-Type: application/json' -H "www-authorization: $TOKEN" 127.0.0.1:6543/usuarios/kpenate | jq
- Cambiamos el apellido a su forma correcta
curl -s -L -XPUT -H 'Content-Type: application/json' -H "www-authorization: $TOKEN" 127.0.0.1:6543/usuarios/kpenate -d @datos.d/usuario_modificacion.json
- Borramos el usuario recién creado
curl -s -L -XDELETE -H 'Content-Type: application/json' -H "www-authorization: $TOKEN" 127.0.0.1:6543/usuarios/kpenate | jq
- Listamos los grupos disponibles en el directorio
curl -s -L XGET -H 'Content-Type: application/json' -H "www-authorization: $TOKEN" 127.0.0.1:6543/grupos | jq
- Creamos un grupo
curl -s -L -XPOST -H 'Content-Type: application/json' -H "www-authorization: $TOKEN" 127.0.0.1:6543/grupos -d @datos.d/grupo_creacion.json | jq
- Obtenemos los datos del grupo recién creado
curl -s -L -XGET -H 'Content-Type: application/json' -H "www-authorization: $TOKEN" 127.0.0.1:6543/grupos/unidad | jq
-
Cambiamos la lista de correo asociada a la unidad TODO: Falta implementar esto
-
Borramos el grupo recién creado
curl -s -L -XDELETE -H 'Content-Type: application/json' -H "www-authorization: $TOKEN" 127.0.0.1:6543/grupos/unidad