daef7ea190
Helper functions (matrix-mas capability group): - mas_client_register_bash_infra: register/sync OAuth clients via mas-cli - mas_syn2mas_migration_bash_infra: dry-run + apply user migration to MAS - synapse_msc3861_enable_go_infra: edit homeserver.yaml MSC3861 block (with diff) - wellknown_oidc_patch_go_infra: patch well-known JSON with msc2965.authentication - synapse_login_flows_check_go_infra: health-check post-migration login flows Flows + issues for custom Matrix clients (PC + Android): - 0010 matrix-client-pc: Wails + React+Mantine (issues 0147-0153) - 0011 matrix-client-android: Kotlin + Compose (issues 0154-0161) - 0162 enable MAS as auth provider (Synapse delegate) — EXECUTED on VPS - 0163 custom admin panel propio (sustituye synapse-admin) Production state (organic-machine.com): - Synapse migrated SQLite -> Postgres - MSC3861 active, password_config disabled - 21 users + 41 access_tokens migrated via syn2mas - 4 MAS clients registered (element, matrix_pc, matrix_android, admin_panel) - synapse-admin container removed + Coolify route deleted - well-known patched with org.matrix.msc2965.authentication Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
68 lines
2.2 KiB
Bash
68 lines
2.2 KiB
Bash
#!/usr/bin/env bash
|
|
# Tests para mas_client_register
|
|
# No requiere SSH real — prueba paths locales (arg validation, --help, JSON output)
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
PASS=0
|
|
FAIL=0
|
|
|
|
assert_contains() {
|
|
local test_name="$1" needle="$2" haystack="$3"
|
|
if echo "$haystack" | grep -qF "$needle"; then
|
|
echo "PASS: $test_name"
|
|
((PASS++))
|
|
else
|
|
echo "FAIL: $test_name — expected to contain '$needle', got: $haystack"
|
|
((FAIL++))
|
|
fi
|
|
}
|
|
|
|
assert_json_parseable() {
|
|
local test_name="$1" json="$2"
|
|
if command -v jq &>/dev/null; then
|
|
if echo "$json" | jq . >/dev/null 2>&1; then
|
|
echo "PASS: $test_name"
|
|
((PASS++))
|
|
else
|
|
echo "FAIL: $test_name — output no es JSON valido: $json"
|
|
((FAIL++))
|
|
fi
|
|
else
|
|
if [[ "$json" == \{* ]]; then
|
|
echo "PASS: $test_name (jq no disponible, verificacion basica OK)"
|
|
((PASS++))
|
|
else
|
|
echo "FAIL: $test_name — output no parece JSON: $json"
|
|
((FAIL++))
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# Test: help flag emite JSON parseable
|
|
# Cada invocacion en subshell aislada para no contaminar el runner con set -e del script fuente
|
|
bash "$SCRIPT_DIR/mas_client_register.sh" --help >/tmp/mas_test_help_$$ 2>/dev/null || true
|
|
output_help=$(cat /tmp/mas_test_help_$$ 2>/dev/null || true)
|
|
rm -f /tmp/mas_test_help_$$
|
|
assert_json_parseable "help flag emite JSON parseable" "$output_help"
|
|
|
|
# Test: args faltantes retornan JSON de error sin ssh
|
|
bash "$SCRIPT_DIR/mas_client_register.sh" >/tmp/mas_test_noargs_$$ 2>/dev/null || true
|
|
output_noargs=$(cat /tmp/mas_test_noargs_$$ 2>/dev/null || true)
|
|
rm -f /tmp/mas_test_noargs_$$
|
|
assert_json_parseable "args faltantes retornan JSON de error sin ssh" "$output_noargs"
|
|
assert_contains "args faltantes contienen status error" '"status":"error"' "$output_noargs"
|
|
|
|
# Test: jq disponible en host local
|
|
if command -v jq &>/dev/null; then
|
|
echo "PASS: jq disponible en host local"
|
|
((PASS++))
|
|
else
|
|
echo "FAIL: jq disponible en host local — instalar: apt install jq"
|
|
((FAIL++))
|
|
fi
|
|
|
|
echo "---"
|
|
echo "Results: $PASS passed, $FAIL failed"
|
|
[[ $FAIL -eq 0 ]] || exit 1
|