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,78 @@
package upstreamimpl
import (
"context"
"testing"
"git.5iot.com/iotlcm-public/iotlcm-upstream-proxy/internal/model"
"git.5iot.com/iotlcm-public/iotlcm-upstream-proxy/internal/model/entity"
"git.5iot.com/iotlcm-public/iotlcm-upstream-proxy/internal/service"
)
// chanTemplateKeys lists every template iotlcm-upstream-chan registers in its
// own upstreamimpl init() functions. Source of truth:
//
// iotlcm-upstream-chan/internal/logic/upstreamimpl/sim_onelink_shared.go:18-29 (shared token family)
// iotlcm-upstream-chan/internal/logic/upstreamimpl/sim_daihe.go:17
// iotlcm-upstream-chan/internal/logic/upstreamimpl/sim_henan_xinjing_direct.go:18
// iotlcm-upstream-chan/internal/logic/upstreamimpl/sim_qianxun.go:25
// iotlcm-upstream-chan/internal/logic/upstreamimpl/sim_yunda.go:19
// iotlcm-upstream-chan/internal/logic/upstreamimpl/sim_recharge.go:19
// iotlcm-upstream-chan/internal/logic/upstreamimpl/sim_yd.go (sim_yd_v5)
// iotlcm-upstream-chan/internal/logic/upstreamimpl/sim_yd_mock.go:21
// iotlcm-upstream-chan/internal/service/mingqian/adapter.go:16
//
// Keep this list in sync when a template is added on the chan side: a template
// missing here is exactly the failure mode where channel refresh returns
// "channel template not registered".
var chanTemplateKeys = []string{
// 共享 Token 族
"sim_onelink_tengyu_v1",
"sim_onelink_xuzhou_mobile_v1",
"sim_onelink_lelian_v1",
"sim_onelink_qianxun_v1",
"sim_onelink_henan_xinjing_v1",
"sim_onelink_daihe_v1",
"sim_onelink_daliuliang_v1",
"sim__daliuliang_v1",
"sim_onelink_mobile_public_v1",
"sim_onelink_kedang_v1",
"sim_onelink_yunze_v1",
"sim_onelink_lanshu_v1",
"sim_onelink_beixin_v1",
// 非共享 Token 族
"sim_yd_v5",
"sim_yd_mock_v5",
"sim_sdtywl_v1",
"sim_daihe_v1",
"sim_henan_xinjing_direct_v1",
"sim_qianxun_v3",
"sim_yunda_v1",
"sim_mingqian_v3",
"sim_tibiot_v1",
"sim_dx_v1",
"sim_dx_v3",
}
// TestUpstreamTemplateParity guards the proxy/gateway template registration
// contract: the proxy only forwards to the gateway, so every template the
// gateway registers must also be registered here or RefreshChannel fails before
// any request is made.
func TestUpstreamTemplateParity(t *testing.T) {
for _, tempKey := range chanTemplateKeys {
tempKey := tempKey
t.Run(tempKey, func(t *testing.T) {
temp, ok := service.UpstreamAPI().GetTemp(tempKey)
if !ok || temp == nil {
t.Fatalf("template not registered in proxy: %s", tempKey)
}
config := &model.SimChannelConfigItemCache{
Template: &entity.TSimChannelTemplate{TempKey: tempKey},
Channel: &entity.TSimChannels{ChanKey: "parity-test"},
}
if instance := temp.NewTemp(context.Background(), config); instance == nil {
t.Fatalf("template failed to instantiate: %s", tempKey)
}
})
}
}