91d8584a9c
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014FsEKyJrYF69Cj9ZXzFLRi
72 lines
2.9 KiB
Go
72 lines
2.9 KiB
Go
package lkgateway
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"git.zetit.ru/zuevav/Bridge-and-Join-s/internal/m2m"
|
|
)
|
|
|
|
type captureSender struct{ got *m2m.M2MTransferRequest }
|
|
|
|
func (c *captureSender) Send(_ context.Context, req *m2m.M2MTransferRequest) (*m2m.M2MTransferResponse, error) {
|
|
c.got = req
|
|
return nil, nil
|
|
}
|
|
func (c *captureSender) SendDecision(context.Context, *m2m.M2MTransferDecision) error { return nil }
|
|
|
|
func TestRealNSDTest(t *testing.T) {
|
|
old := realTestFile
|
|
realTestFile = filepath.Join(t.TempDir(), "rt.json")
|
|
realTests.loaded = false
|
|
defer func() { realTestFile, realTests.loaded = old, false }()
|
|
rc, err := NewRuntimeConfig(filepath.Join(t.TempDir(), "setup.json"))
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
lk := rc.Snapshot().LK
|
|
lk.RealNSDTest = RealNSDTestSettings{Enabled: true, Docs: "1110 754503; 4500 000001"}
|
|
_ = rc.UpdateLK(lk)
|
|
|
|
if !realTestMatch(rc, "1110", "754503") || !realTestMatch(rc, "11 10", "754503") || realTestMatch(rc, "1110", "000000") {
|
|
t.Fatal("выбор клиентов по паспорту")
|
|
}
|
|
|
|
// подмена: в НРД — Бубликов, у нас запрос не меняется
|
|
req := sendFailRequest()
|
|
req.Data.InvestorInformation.LastName = "Погонщикова"
|
|
inv, as := realTestInvestor(rc, req.Data.InvestorInformation.IdentityDocument.DocumentType)
|
|
cap := &captureSender{}
|
|
if _, err := (substituteSender{real: cap, inv: inv}).Send(context.Background(), req); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if cap.got.Data.InvestorInformation.LastName != "Бубликов" || string(cap.got.Data.InvestorInformation.IdentityDocument.DocumentNumber) != "289090" ||
|
|
req.Data.InvestorInformation.LastName != "Погонщикова" || cap.got.Header.GUID != req.Header.GUID || as == "" {
|
|
t.Fatalf("подмена: ушло %+v, у нас %s", cap.got.Data.InvestorInformation, req.Data.InvestorInformation.LastName)
|
|
}
|
|
|
|
// QUIK: боевая запись только для тестовой заявки
|
|
q := rc.Snapshot().Quik
|
|
q.Emulate, q.WritesEnabled = true, false
|
|
_ = rc.UpdateQuik(q)
|
|
guid := string(req.Header.GUID)
|
|
if s := quikSettingsFor(rc, guid); !s.Emulate || s.WritesEnabled {
|
|
t.Fatal("обычная заявка — как в настройках")
|
|
}
|
|
realTestPut(RealTestRec{GUID: guid, Client: "Погонщикова", As: as})
|
|
if s := quikSettingsFor(rc, guid); s.Emulate || !s.WritesEnabled {
|
|
t.Fatal("тестовая заявка — боевая запись")
|
|
}
|
|
if _, ok := realTestSenderFor(rc, guid, req, cap).(substituteSender); !ok {
|
|
t.Fatal("повторная отправка тестовой заявки — тоже с подменой")
|
|
}
|
|
if !realTestAny() {
|
|
t.Fatal("есть незавершённая тестовая заявка")
|
|
}
|
|
realTestOnExecuted(context.Background(), rc, guid, false, "")
|
|
if r := realTestGet(guid); r == nil || !r.LKDone || realTestAny() {
|
|
t.Fatalf("итог в ЛК: %+v", r)
|
|
}
|
|
}
|