e47e6cfbdc
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014FsEKyJrYF69Cj9ZXzFLRi
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
//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)
|
|
}
|
|
}
|