chore: 初始开源发布
iotlcm-upstream-proxy:渠道缓存与转发网关。 - 内联原私有依赖:yunze-public → internal/pub/(18 文件), yunze-pb/pb → internal/pb/(9 文件);Consul 注册改用官方 gogf/gf/contrib/registry/consul/v2(API 兼容) - Go module:yz-svr → git.5iot.com/iotlcm-public/iotlcm-upstream-proxy - 凭据与内部标识脱敏:MySQL/Redis/Consul 凭据、私网与生产 IP、内网域名 - 移除内部资产:CI 触发器 - Dockerfile 改用公共基础镜像,移除写死的 registry 凭据 - 补 Apache-2.0 LICENSE,重写 README,LF 行尾 + .gitattributes
This commit is contained in:
@@ -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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user