chore: 并入 iotlcm-upstream-proxy 历史到 upstream-proxy/(原提交 44209ec)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:02 +08:00
117 changed files with 8690 additions and 0 deletions
@@ -0,0 +1,38 @@
package simKeyFill
import (
"context"
"encoding/json"
"net/http/httptest"
"testing"
"github.com/gogf/gf/v2/net/ghttp"
"git.5iot.com/iotlcm-public/iotlcm-upstream-proxy/internal/model"
"git.5iot.com/iotlcm-public/iotlcm-upstream-proxy/internal/service"
)
type snapshotTestAPI struct {
service.IUpstreamAPI
input *model.SimBaseReqJson
}
func (a *snapshotTestAPI) SimBase(_ context.Context, in *model.SimBaseReqJson) (model.SimBaseResJson, error) {
a.input = in
return nil, nil
}
func TestAsyncOperationPreservesCardSnapshot(t *testing.T) {
api := &snapshotTestAPI{}
service.RegisterUpstreamAPI(api)
defer service.RegisterUpstreamAPI(nil)
in := &model.SimBaseReqJson{SimKeys: []*model.SimKey{{ChanKey: "test", ICCID: "test-card", MSISDN: "snapshot-number"}}, ReqData: json.RawMessage(`{"operationId":"stable-id","submitOnly":true}`)}
_, err := NewSimKeyFill().SimKeyFill((&ghttp.Request{Request: httptest.NewRequest("POST", "/sim/change/sim-apn", nil)}).Context(), in)
if err != nil || api.input != in || api.input.SimKeys[0].MSISDN != "snapshot-number" {
t.Fatalf("异步请求不应重新填充或改写卡快照:%v", err)
}
}
func TestAsyncOperationRejectsIncompleteSnapshot(t *testing.T) {
_, err := NewSimKeyFill().SimKeyFill((&ghttp.Request{Request: httptest.NewRequest("POST", "/sim/change/sim-apn", nil)}).Context(), &model.SimBaseReqJson{SimKeys: []*model.SimKey{{ICCID: "test-card"}}, ReqData: json.RawMessage(`{"operationId":"stable-id"}`)})
if err == nil {
t.Fatal("缺失通道快照应在调用前拒绝")
}
}