sync: 同步生产版 v1.0.4 并脱敏
This commit is contained in:
@@ -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("缺失通道快照应在调用前拒绝")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user