94 lines
3.1 KiB
Bash
Executable File
94 lines
3.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -Eeuo pipefail
|
|
|
|
dhv2_base_url="${DHV2_BASE_URL:-https://dhv2.korexlabs.com}"
|
|
dhv2_base_url="${dhv2_base_url%/}"
|
|
|
|
fail() {
|
|
echo "ERROR: $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
echo "========== B1 · MIGRACIONES =========="
|
|
dhv2_migration_status="$(docker compose --profile tools run --rm migrate npm run migration:show 2>&1)"
|
|
grep -q 'Pending migrations: no' <<<"$dhv2_migration_status" \
|
|
|| fail "Quedaron migraciones pendientes"
|
|
echo "Migraciones pendientes: no"
|
|
|
|
echo
|
|
echo "========== B1 · HEALTH =========="
|
|
dhv2_internal="$(curl -fsS --connect-timeout 10 --max-time 30 http://127.0.0.1:3101/api/v3/health)"
|
|
dhv2_external="$(curl -fsS --connect-timeout 10 --max-time 30 "$dhv2_base_url/api/v3/health")"
|
|
grep -q '"version":"0.8.0"' <<<"$dhv2_internal" || fail "Health interno no informa v0.8.0"
|
|
grep -q '"phase":"B1"' <<<"$dhv2_internal" || fail "Health interno no informa B1"
|
|
grep -q '"version":"0.8.0"' <<<"$dhv2_external" || fail "Health externo no informa v0.8.0"
|
|
grep -q '"database":"ok"' <<<"$dhv2_external" || fail "La base no está saludable"
|
|
echo "$dhv2_external"
|
|
|
|
echo
|
|
echo "========== B1 · RUTAS PROTEGIDAS =========="
|
|
for dhv2_path in assets asset-types; do
|
|
dhv2_code="$(curl -sS --connect-timeout 10 --max-time 30 \
|
|
-o /tmp/dhv2-b1-response.json -w '%{http_code}' \
|
|
"$dhv2_base_url/api/v3/$dhv2_path")"
|
|
test "$dhv2_code" = "401" || fail "/api/v3/$dhv2_path devolvió HTTP $dhv2_code; se esperaba 401"
|
|
echo "/api/v3/$dhv2_path sin sesión: 401 OK"
|
|
done
|
|
rm -f /tmp/dhv2-b1-response.json
|
|
|
|
echo
|
|
echo "========== B1 · ESQUEMA Y PERMISOS =========="
|
|
dhv2_db_check="$(docker compose exec -T db sh -lc \
|
|
'psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -v ON_ERROR_STOP=1 -At' <<'SQL'
|
|
SELECT 'tables', COUNT(*)
|
|
FROM information_schema.tables
|
|
WHERE table_schema = 'public'
|
|
AND table_name IN (
|
|
'asset_types',
|
|
'asset_type_parent_rules',
|
|
'asset_attribute_definitions',
|
|
'assets',
|
|
'asset_attribute_values'
|
|
);
|
|
|
|
SELECT 'permissions', COUNT(*)
|
|
FROM permissions
|
|
WHERE code IN (
|
|
'asset_types.read',
|
|
'asset_types.manage',
|
|
'assets.read',
|
|
'assets.create',
|
|
'assets.update',
|
|
'assets.change_status'
|
|
);
|
|
|
|
SELECT 'admin_permissions', COUNT(*)
|
|
FROM role_permissions role_permission
|
|
INNER JOIN roles role ON role.id = role_permission.role_id
|
|
INNER JOIN permissions permission ON permission.id = role_permission.permission_id
|
|
WHERE role.code = 'admin'
|
|
AND permission.code IN (
|
|
'asset_types.read',
|
|
'asset_types.manage',
|
|
'assets.read',
|
|
'assets.create',
|
|
'assets.update',
|
|
'assets.change_status'
|
|
);
|
|
SQL
|
|
)"
|
|
grep -q 'tables|5' <<<"$dhv2_db_check" || fail "No se encontraron las cinco tablas de B1"
|
|
grep -q 'permissions|6' <<<"$dhv2_db_check" || fail "No se encontraron los seis permisos de B1"
|
|
grep -q 'admin_permissions|6' <<<"$dhv2_db_check" || fail "El rol admin no recibió todos los permisos de B1"
|
|
echo "$dhv2_db_check"
|
|
|
|
echo
|
|
echo "========== B1 · FRONTEND =========="
|
|
docker compose exec -T web sh -lc \
|
|
'grep -R "0.8.0" /usr/share/nginx/html/assets >/dev/null && grep -R "Base del Maestro de Activos" /usr/share/nginx/html/assets >/dev/null'
|
|
echo "Frontend y footer v0.8.0: OK"
|
|
|
|
echo
|
|
echo "ACEPTACIÓN DE FASE B1: OK"
|