Тест «боевой ЛК → TEST3»: заявки выбранных клиентов ЕСИА Финанс — у нас всё по-настоящему (DEPO, QUIK МНП боевая запись только для них), в НРД с подменой инвестора на тест-клиента; «Исполнена» в ЛК по MS010; повтор отправки тоже с подменой; пометка и шаги ЛК в пути заявки; включатель на «Тестирование M2M»
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014FsEKyJrYF69Cj9ZXzFLRi
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user