sync: 同步 v1.0.4 开源代码并脱敏

This commit is contained in:
MiFaZhan
2026-10-29 14:59:32 +08:00
parent 14f4bb64e1
commit 3e5a7453b8
74 changed files with 3297 additions and 248 deletions
+1 -1
View File
@@ -8,9 +8,9 @@ import (
"strings"
"time"
"github.com/gogf/gf/v2/errors/gerror"
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/consts"
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/model"
"github.com/gogf/gf/v2/errors/gerror"
)
const TemplateKey = "sim_mingqian_v3"
+9 -8
View File
@@ -4,8 +4,6 @@ import (
"context"
"encoding/json"
"fmt"
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/model"
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/model/entity"
"net/http"
"net/http/httptest"
"regexp"
@@ -13,6 +11,8 @@ import (
"strings"
"testing"
"time"
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/model"
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/model/entity"
)
func testAdapter(t *testing.T, handler http.HandlerFunc) *Adapter {
@@ -165,13 +165,13 @@ func TestOperationsAreSafe(t *testing.T) {
})
input := &model.SimCardStatusChangeInput{SimKeys: []*model.SimKey{{ICCID: "A"}, {ICCID: "B"}}, ReqData: model.SimCardStatusChangeInputItem{OperType: "0"}}
result, _ := adapter.ChangeSimStatus(context.Background(), input)
if calls != 1 || result[0].Code != 0 || result[1].Code == 0 {
t.Fatal("stop operation must reach the confirmed endpoint and inspect per-card success flags")
if calls != 0 || result[0].Code == 0 {
t.Fatal("operations must be disabled by default")
}
before := calls
adapter.operations = true
input.ReqData.OperType = "1"
result, _ = adapter.ChangeSimStatus(context.Background(), input)
if calls != before || result[0].Code == 0 {
if calls != 0 || result[0].Code == 0 {
t.Fatal("unconfirmed resume path must not send any request")
}
adapter.resumePath = "/simlist/test-resume"
@@ -182,7 +182,7 @@ func TestOperationsAreSafe(t *testing.T) {
t.Fatal("must inspect per-card success flags")
}
}
before = calls
before := calls
input.ReqData.OperType = "invalid"
adapter.ChangeSimStatus(context.Background(), input)
if calls != before {
@@ -206,7 +206,7 @@ func TestResponseFailuresAndNoRetry(t *testing.T) {
func TestConfiguration(t *testing.T) {
cfg := &model.SimChannelConfigItemCache{Template: &entity.TSimChannelTemplate{TempConfig: `{"api":{"timeout":"1s"}}`}, Channel: &entity.TSimChannels{AppKey: "app", AppSecret: "secret"}}
adapter, err := New(cfg)
if err != nil || adapter.resumePath != "" {
if err != nil || adapter.operations {
t.Fatalf("invalid default configuration: %v", err)
}
cfg.Channel.AppSecret = ""
@@ -243,6 +243,7 @@ func TestOperationBatchLimitAndHTTPFailure(t *testing.T) {
}
writer.WriteHeader(http.StatusTooManyRequests)
})
adapter.operations = true
keys := make([]*model.SimKey, 21)
for index := range keys {
keys[index] = &model.SimKey{ICCID: strconv.Itoa(index)}
+1 -1
View File
@@ -5,9 +5,9 @@ import (
"math"
"strings"
"github.com/gogf/gf/v2/errors/gerror"
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/consts"
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/model"
"github.com/gogf/gf/v2/errors/gerror"
)
type PackageFlowOutput = []*model.SimBaseRes[model.SimPackageFlowItem]
+1
View File
@@ -54,6 +54,7 @@ type (
QuerySimApnInfo(ctx context.Context, input *model.SimApnInfoInput) (output model.SimApnInfoOutput, err error)
// 物联网卡状态变更
ChangeSimStatus(ctx context.Context, input *model.SimCardStatusChangeInput) (output model.SimCardStatusChangeOutput, err error)
QuerySimApnCapability(ctx context.Context, input *model.SimCardOperateChangeApnInput) (model.SimApnCapabilityOutput, error)
ChangeSimCardOperateApn(ctx context.Context, input *model.SimCardOperateChangeApnInput) (output model.SimCardOperateChangeApnOutput, err error)
}
)