ЛК ЕСИА Финанс: портфель ДЕПО из DEPO — сверка каждые 10 с в проходе опроса, отправка только при изменении; настройки и «Синхронизировать сейчас»

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014FsEKyJrYF69Cj9ZXzFLRi
This commit is contained in:
zuevav
2026-09-29 16:54:43 +03:00
parent 98e17a8cb7
commit e47e6cfbdc
10 changed files with 500 additions and 0 deletions
+39
View File
@@ -0,0 +1,39 @@
//go:build live
package lkgateway
import (
"context"
"encoding/json"
"fmt"
"os"
"strings"
"testing"
"time"
)
// Только чтение: снимок данных клиента в ЛК ЕСИА Финанс. LK_PATHS=/contracts/1557,/contracts/1557/depo_accounts,/users/891 LK_OUT=файл
func TestLKBackupLive(t *testing.T) {
rc, err := NewRuntimeConfig("/var/lib/bj/.bj/setup.json")
if err != nil {
t.Fatal(err)
}
ep, ok := lkActiveEndpoint(rc)
if !ok {
t.Fatal("ЛК не настроен")
}
out := map[string]any{"at": time.Now().Format(time.RFC3339), "env": rc.Snapshot().LK.ActiveEnv}
for _, p := range strings.Split(os.Getenv("LK_PATHS"), ",") {
code, body, err := lkGet(context.Background(), ep, p)
var v any
if json.Unmarshal(body, &v) != nil {
v = string(body)
}
out[p] = map[string]any{"http": code, "err": fmt.Sprint(err), "body": v}
fmt.Println(p, "→ HTTP", code, err, len(body), "байт")
}
raw, _ := json.MarshalIndent(out, "", " ")
if err := os.WriteFile(os.Getenv("LK_OUT"), raw, 0o600); err != nil {
t.Fatal(err)
}
}