sync: 同步 v1.0.4 开源代码并脱敏
This commit is contained in:
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user