chore: 并入 iotlcm-upstream-proxy 历史到 upstream-proxy/(原提交 44209ec)
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package channelconfig
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-upstream-proxy/internal/model/entity"
|
||||
)
|
||||
|
||||
func TestChannelVersionDetectsCredentialChanges(t *testing.T) {
|
||||
normal := 0
|
||||
row := &channelConfigRow{IsNormal: &normal, TSimChannels: entity.TSimChannels{
|
||||
ChanKey: "telecom-test", TempKey: "sim_dx_v1", AppKey: "key", AppSecret: "secret",
|
||||
AccessToken: "token", RefreshToken: "refresh",
|
||||
}}
|
||||
config := NewChannelConfig()
|
||||
before := config.getChanVersion(context.Background(), row)
|
||||
for _, field := range []string{"appKey", "appSecret", "accessToken", "refreshToken", "tempKey"} {
|
||||
t.Run(field, func(t *testing.T) {
|
||||
changed := *row
|
||||
switch field {
|
||||
case "appKey":
|
||||
changed.AppKey = "new-key"
|
||||
case "appSecret":
|
||||
changed.AppSecret = "new-secret"
|
||||
case "accessToken":
|
||||
changed.AccessToken = "new-token"
|
||||
case "refreshToken":
|
||||
changed.RefreshToken = "new-refresh"
|
||||
case "tempKey":
|
||||
changed.TempKey = "sim_dx_v3"
|
||||
}
|
||||
if got := config.getChanVersion(context.Background(), &changed); got == before {
|
||||
t.Fatalf("%s change did not invalidate runtime version", field)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user