mirror of
https://github.com/MengMengCode/VoCat.git
synced 2026-08-20 23:03:44 +08:00
Fix something
This commit is contained in:
@@ -30,9 +30,9 @@ func testNotificationMetadata(t *testing.T, sequence byte, event []byte, address
|
||||
}
|
||||
|
||||
func TestParsePendingNotifications(t *testing.T) {
|
||||
installMetadata := testNotificationMetadata(t, 7, []byte{7, 0x80}, "install.example.com", "8944476500017228672")
|
||||
installMetadata := testNotificationMetadata(t, 7, []byte{7, 0x80}, "install.example.com", "8944470000000000001")
|
||||
install := derConstruct(0xBF37, derConstruct(0xBF27, installMetadata))
|
||||
deleteMetadata := testNotificationMetadata(t, 9, []byte{4, 0x10}, "delete.example.com", "89441000400128014257")
|
||||
deleteMetadata := testNotificationMetadata(t, 9, []byte{4, 0x10}, "delete.example.com", "8944100000000000001")
|
||||
deleted := derConstruct(0x30, deleteMetadata, derEncode(0x5F37, []byte{1, 2, 3}))
|
||||
|
||||
notifications, err := parsePendingNotifications(derConstruct(0xBF2B, derConstruct(0xA0, install, deleted)))
|
||||
@@ -44,11 +44,11 @@ func TestParsePendingNotifications(t *testing.T) {
|
||||
}
|
||||
// Results are grouped by receiver, then sorted by sequence number.
|
||||
if got := notifications[0]; got.SequenceNumber != 9 || got.Event != "delete" ||
|
||||
got.Address != "delete.example.com" || got.ICCID != "89441000400128014257" || !bytes.Equal(got.raw, deleted) {
|
||||
got.Address != "delete.example.com" || got.ICCID != "8944100000000000001" || !bytes.Equal(got.raw, deleted) {
|
||||
t.Fatalf("delete notification = %#v, raw=%X", got, got.raw)
|
||||
}
|
||||
if got := notifications[1]; got.SequenceNumber != 7 || got.Event != "install" ||
|
||||
got.Address != "install.example.com" || got.ICCID != "8944476500017228672" || !bytes.Equal(got.raw, install) {
|
||||
got.Address != "install.example.com" || got.ICCID != "8944470000000000001" || !bytes.Equal(got.raw, install) {
|
||||
t.Fatalf("install notification = %#v, raw=%X", got, got.raw)
|
||||
}
|
||||
|
||||
|
||||
@@ -55,9 +55,9 @@ func esimTestProfile(t *testing.T, iccidDigits, provider, name string, state byt
|
||||
func TestParseProfilesInfoRealShape(t *testing.T) {
|
||||
// BF2D root (this card echoes the request tag) -> A0 list -> E3 records.
|
||||
body := tlv([]byte{0xA0},
|
||||
esimTestProfile(t, "89441000400128014257", "Vodafone UK", "Vodafone UK eSIM", 0x00),
|
||||
esimTestProfile(t, "89441000430011604140", "Vodafone UK", "Vodafone UK eSIM", 0x01),
|
||||
esimTestProfile(t, "89852351225001058508", "Webbing", "WEBBING", 0x00),
|
||||
esimTestProfile(t, "8944100000000000001", "Vodafone UK", "Vodafone UK eSIM", 0x00),
|
||||
esimTestProfile(t, "8944100000000000002", "Vodafone UK", "Vodafone UK eSIM", 0x01),
|
||||
esimTestProfile(t, "8985200000000000001", "Webbing", "WEBBING", 0x00),
|
||||
)
|
||||
payload := tlv([]byte{0xBF, 0x2D}, body)
|
||||
|
||||
@@ -65,10 +65,10 @@ func TestParseProfilesInfoRealShape(t *testing.T) {
|
||||
if len(profiles) != 3 {
|
||||
t.Fatalf("expected 3 profiles, got %d: %#v", len(profiles), profiles)
|
||||
}
|
||||
if profiles[0].ICCID != "89441000400128014257" || profiles[0].State != 0 {
|
||||
if profiles[0].ICCID != "8944100000000000001" || profiles[0].State != 0 {
|
||||
t.Fatalf("profile[0] = %#v", profiles[0])
|
||||
}
|
||||
if profiles[1].ICCID != "89441000430011604140" || profiles[1].State != 1 || profiles[1].StateText != "已启用" {
|
||||
if profiles[1].ICCID != "8944100000000000002" || profiles[1].State != 1 || profiles[1].StateText != "已启用" {
|
||||
t.Fatalf("profile[1] = %#v", profiles[1])
|
||||
}
|
||||
if profiles[2].ServiceProvider != "Webbing" || profiles[2].Name != "WEBBING" || profiles[2].State != 0 {
|
||||
@@ -82,8 +82,8 @@ func TestParseProfilesInfoRealShape(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestParseProfilesInfoSkipsNestedMetadataE3WithoutICCID(t *testing.T) {
|
||||
real := esimTestProfile(t, "89441000400316048687", "Vodafone UK", "Vodafone UK eSIM", 0x01)
|
||||
duplicate := esimTestProfile(t, "89441000400316048687", "Duplicate", "Duplicate", 0x00)
|
||||
real := esimTestProfile(t, "8944100000000000003", "Vodafone UK", "Vodafone UK eSIM", 0x01)
|
||||
duplicate := esimTestProfile(t, "8944100000000000003", "Duplicate", "Duplicate", 0x00)
|
||||
metadata := tlv([]byte{0xE3}, tlv([]byte{0x80}, []byte{0x01}))
|
||||
empty := tlv([]byte{0xE3})
|
||||
payload := tlv([]byte{0xBF, 0x2D}, tlv([]byte{0xA0}, metadata, real, empty, duplicate))
|
||||
@@ -92,13 +92,13 @@ func TestParseProfilesInfoSkipsNestedMetadataE3WithoutICCID(t *testing.T) {
|
||||
if len(profiles) != 1 {
|
||||
t.Fatalf("profiles = %#v, want one addressable profile", profiles)
|
||||
}
|
||||
if profiles[0].ICCID != "89441000400316048687" || profiles[0].Name != "Vodafone UK eSIM" {
|
||||
if profiles[0].ICCID != "8944100000000000003" || profiles[0].Name != "Vodafone UK eSIM" {
|
||||
t.Fatalf("profile = %#v", profiles[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestICCIDRoundTrip(t *testing.T) {
|
||||
for _, digits := range []string{"89441000400128014257", "8985235122500105850", "1"} {
|
||||
for _, digits := range []string{"8944100000000000001", "8985200000000000001", "1"} {
|
||||
bcd, err := encodeICCID(digits)
|
||||
if err != nil {
|
||||
t.Fatalf("encodeICCID(%q): %v", digits, err)
|
||||
@@ -110,7 +110,7 @@ func TestICCIDRoundTrip(t *testing.T) {
|
||||
t.Fatalf("round trip %q -> %q", digits, got)
|
||||
}
|
||||
}
|
||||
if _, err := encodeICCID("894410004001280142571"); err == nil {
|
||||
if _, err := encodeICCID("894410000000000000001"); err == nil {
|
||||
t.Fatal("21-digit ICCID was accepted")
|
||||
}
|
||||
}
|
||||
@@ -126,11 +126,11 @@ func TestEnableProfileRequestPads18DigitICCIDToTenOctets(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDeleteProfileRequestAndResult(t *testing.T) {
|
||||
request, err := buildDeleteProfileRequest("89441000400128014257")
|
||||
request, err := buildDeleteProfileRequest("89441000000000000001")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := strings.ToUpper(hex.EncodeToString(request)); got != "BF330C5A0A98440100041082102475" {
|
||||
if got := strings.ToUpper(hex.EncodeToString(request)); got != "BF330C5A0A98440100000000000010" {
|
||||
t.Fatalf("DeleteProfile request = %s", got)
|
||||
}
|
||||
result, ok := deleteProfileResult([]byte{0xBF, 0x33, 0x03, 0x80, 0x01, 0x00})
|
||||
@@ -144,28 +144,28 @@ func TestDeleteProfileRequestAndResult(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSetNicknameRequestAndResult(t *testing.T) {
|
||||
request, err := buildSetNicknameRequest("89441000400128014257", "Test")
|
||||
request, err := buildSetNicknameRequest("89441000000000000001", "Test")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := strings.ToUpper(hex.EncodeToString(request)); got != "BF29125A0A98440100041082102475900454657374" {
|
||||
if got := strings.ToUpper(hex.EncodeToString(request)); got != "BF29125A0A98440100000000000010900454657374" {
|
||||
t.Fatalf("SetNickname request = %s", got)
|
||||
}
|
||||
result, ok := setNicknameResult([]byte{0xBF, 0x29, 0x03, 0x80, 0x01, 0x00})
|
||||
if !ok || result != 0 {
|
||||
t.Fatalf("SetNickname result = (%d, %v)", result, ok)
|
||||
}
|
||||
if _, err := buildSetNicknameRequest("89441000400128014257", strings.Repeat("名", 65)); !errors.Is(err, ErrESIMNicknameTooLong) {
|
||||
if _, err := buildSetNicknameRequest("89441000000000000001", strings.Repeat("名", 65)); !errors.Is(err, ErrESIMNicknameTooLong) {
|
||||
t.Fatalf("long nickname error = %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDisableProfileRequestAndResult(t *testing.T) {
|
||||
request, err := buildDisableProfileRequest("89441000400128014257")
|
||||
request, err := buildDisableProfileRequest("89441000000000000001")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := strings.ToUpper(hex.EncodeToString(request)); got != "BF3211A00C5A0A984401000410821024758101FF" {
|
||||
if got := strings.ToUpper(hex.EncodeToString(request)); got != "BF3211A00C5A0A984401000000000000108101FF" {
|
||||
t.Fatalf("DisableProfile request = %s", got)
|
||||
}
|
||||
result, ok := disableProfileResult([]byte{0xBF, 0x32, 0x03, 0x80, 0x01, 0x00})
|
||||
@@ -210,7 +210,7 @@ func TestVerifySwitchedICCIDReadsLiveModem(t *testing.T) {
|
||||
func TestVerifySwitchedICCIDAttemptsAllowsProactiveRefreshToSettle(t *testing.T) {
|
||||
const target = "89492026266006792824"
|
||||
client := &transcriptClient{steps: []clientStep{
|
||||
{command: "AT+CCID", response: okResponse("+CCID: 89441000400128014257F")},
|
||||
{command: "AT+CCID", response: okResponse("+CCID: 8944100000000000001F")},
|
||||
{command: "AT+CCID", response: okResponse("+CCID: " + target + "F")},
|
||||
}}
|
||||
manager, id := newStartedTestManager(t, client)
|
||||
|
||||
@@ -91,11 +91,11 @@ func TestCarrierForIMSIHandlesTwoAndThreeDigitMNCs(t *testing.T) {
|
||||
wantPLMN string
|
||||
wantCountry string
|
||||
}{
|
||||
{imsi: "234336570710174", wantPLMN: "23433", wantCountry: "GB"},
|
||||
{imsi: "234159609054263", wantPLMN: "23415", wantCountry: "GB"},
|
||||
{imsi: "234870123456789", wantPLMN: "23487", wantCountry: "GB"},
|
||||
{imsi: "454006395879502", wantPLMN: "45400", wantCountry: "HK"},
|
||||
{imsi: "310260123456789", wantPLMN: "310260", wantCountry: "US"},
|
||||
{imsi: "234330000000001", wantPLMN: "23433", wantCountry: "GB"},
|
||||
{imsi: "234150000000001", wantPLMN: "23415", wantCountry: "GB"},
|
||||
{imsi: "234870000000001", wantPLMN: "23487", wantCountry: "GB"},
|
||||
{imsi: "454000000000001", wantPLMN: "45400", wantCountry: "HK"},
|
||||
{imsi: "310260000000001", wantPLMN: "310260", wantCountry: "US"},
|
||||
}
|
||||
for _, item := range tests {
|
||||
plmn, name, country, ok := CarrierForIMSI(item.imsi)
|
||||
|
||||
@@ -580,7 +580,7 @@ func TestHandleESIMNotificationsListAndRetry(t *testing.T) {
|
||||
controller := &fakeEsimNotificationController{items: []device.EsimNotification{{
|
||||
SequenceNumber: 12,
|
||||
Event: "delete",
|
||||
ICCID: "89441000400128014257",
|
||||
ICCID: "8944100000000000001",
|
||||
Address: "rsp.example.com",
|
||||
AIDHex: "A0000005591010FFFFFFFF8900000100",
|
||||
CanRetry: true,
|
||||
|
||||
@@ -40,12 +40,12 @@ func TestConfiguredDeviceSummaryIgnoresVoWiFiRuntimeFromPreviousSIM(t *testing.T
|
||||
if err := database.UpsertVoWiFiRuntime(context.Background(), store.VoWiFiRuntime{
|
||||
DeviceID: "ec20_1",
|
||||
Phase: "stopping",
|
||||
ICCID: "89441000400128014257",
|
||||
IMSI: "234159608751160",
|
||||
ICCID: "8944100000000000001",
|
||||
IMSI: "234150000000001",
|
||||
TunnelReady: true,
|
||||
IMSReady: true,
|
||||
SMSReady: true,
|
||||
LocalPhone: "+447386083638",
|
||||
LocalPhone: "+447700900123",
|
||||
PhoneNumberSource: "ims_p_associated_uri",
|
||||
UpdatedAt: time.Now().UTC(),
|
||||
}); err != nil {
|
||||
@@ -60,7 +60,7 @@ func TestConfiguredDeviceSummaryIgnoresVoWiFiRuntimeFromPreviousSIM(t *testing.T
|
||||
if got["vowifi_active"] != false {
|
||||
t.Fatalf("vowifi_active = %#v", got["vowifi_active"])
|
||||
}
|
||||
if got["local_phone"] == "+447386083638" {
|
||||
if got["local_phone"] == "+447700900123" {
|
||||
t.Fatalf("old phone leaked into current SIM summary: %#v", got)
|
||||
}
|
||||
runtime, ok := got["vowifi_runtime"].(map[string]any)
|
||||
@@ -169,7 +169,7 @@ func TestSnapshotHasSIMDoesNotTreatUnknownStatusAsInserted(t *testing.T) {
|
||||
}
|
||||
for _, snapshot := range []*device.Snapshot{
|
||||
{SIMStatus: "pin_required"},
|
||||
{ICCID: "89441000400128014257"},
|
||||
{ICCID: "8944100000000000001"},
|
||||
{SIMReady: true},
|
||||
} {
|
||||
if !snapshotHasSIM(snapshot) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"vocat/internal/vowifi"
|
||||
)
|
||||
|
||||
const testProfileICCID = "89441000400128014257"
|
||||
const testProfileICCID = "8944100000000000001"
|
||||
|
||||
func newProfileBindingTestServer(t *testing.T) (*Server, *store.Store, *fakeVoWiFiController) {
|
||||
t.Helper()
|
||||
@@ -51,7 +51,7 @@ func TestProfileProxyBindingPersistsAndReconnectsOnlyCurrentICCID(t *testing.T)
|
||||
response := profileBindingRequest(t, server, http.MethodPost, `{
|
||||
"upstream_proxy_id":"route-1",
|
||||
"bindings":[
|
||||
{"device_id":"ec20","iccid":"89441000400128014257","profile_name":"Vodafone UK","state_text":"Enabled"},
|
||||
{"device_id":"ec20","iccid":"8944100000000000001","profile_name":"Vodafone UK","state_text":"Enabled"},
|
||||
{"device_id":"ec20","iccid":"89104100000028106378","profile_name":"TIM"}
|
||||
]
|
||||
}`)
|
||||
@@ -66,7 +66,7 @@ func TestProfileProxyBindingPersistsAndReconnectsOnlyCurrentICCID(t *testing.T)
|
||||
t.Fatalf("reconnects = %d, want only the current ICCID to reconnect", controller.reconnects)
|
||||
}
|
||||
|
||||
response = profileBindingRequest(t, server, http.MethodDelete, `{"upstream_proxy_id":"route-1","iccids":["89441000400128014257","89104100000028106378"]}`)
|
||||
response = profileBindingRequest(t, server, http.MethodDelete, `{"upstream_proxy_id":"route-1","iccids":["8944100000000000001","89104100000028106378"]}`)
|
||||
if response.Code != http.StatusOK {
|
||||
t.Fatalf("DELETE status = %d, body = %s", response.Code, response.Body.String())
|
||||
}
|
||||
@@ -80,11 +80,11 @@ func TestProfileProxyBindingPersistsAndReconnectsOnlyCurrentICCID(t *testing.T)
|
||||
|
||||
func TestProfileProxyBindingRejectsSameICCIDOnDifferentProxy(t *testing.T) {
|
||||
server, database, _ := newProfileBindingTestServer(t)
|
||||
first := profileBindingRequest(t, server, http.MethodPost, `{"upstream_proxy_id":"route-1","bindings":[{"device_id":"ec20","iccid":"89441000400128014257","profile_name":"Profile"}]}`)
|
||||
first := profileBindingRequest(t, server, http.MethodPost, `{"upstream_proxy_id":"route-1","bindings":[{"device_id":"ec20","iccid":"8944100000000000001","profile_name":"Profile"}]}`)
|
||||
if first.Code != http.StatusOK {
|
||||
t.Fatalf("initial bind status = %d, body = %s", first.Code, first.Body.String())
|
||||
}
|
||||
second := profileBindingRequest(t, server, http.MethodPost, `{"upstream_proxy_id":"route-2","bindings":[{"device_id":"ec20","iccid":"89441000400128014257","profile_name":"Profile"}]}`)
|
||||
second := profileBindingRequest(t, server, http.MethodPost, `{"upstream_proxy_id":"route-2","bindings":[{"device_id":"ec20","iccid":"8944100000000000001","profile_name":"Profile"}]}`)
|
||||
if second.Code != http.StatusConflict {
|
||||
t.Fatalf("rebind status = %d, want 409, body = %s", second.Code, second.Body.String())
|
||||
}
|
||||
|
||||
@@ -236,10 +236,10 @@ func (bot *telegramBot) getUpdates(
|
||||
func (bot *telegramBot) handleUpdate(ctx context.Context, config telegramRuntimeConfig, update telegramUpdate) {
|
||||
if callback := update.CallbackQuery; callback != nil {
|
||||
if callback.Message == nil || !bot.authorized(config, callback.Message.Chat.ID, callback.From.ID) {
|
||||
_ = bot.answerCallback(ctx, config, callback.ID, "无权限")
|
||||
go func() { _ = bot.answerCallback(context.Background(), config, callback.ID, "无权限") }()
|
||||
return
|
||||
}
|
||||
_ = bot.answerCallback(ctx, config, callback.ID, "")
|
||||
go func() { _ = bot.answerCallback(context.Background(), config, callback.ID, "") }()
|
||||
bot.handleCallback(ctx, config, callback)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ func TestResolveTelegramPhoneNumberRejectsPlaceholderAndStaleRuntime(t *testing.
|
||||
}
|
||||
state := &vowifi.State{
|
||||
ICCID: "previous-card",
|
||||
PhoneNumber: "+447386083638",
|
||||
PhoneNumber: "+447700900123",
|
||||
}
|
||||
if got := resolveTelegramPhoneNumber("", state, snapshot); got != "--" {
|
||||
t.Fatalf("stale or placeholder number leaked as %q", got)
|
||||
@@ -135,10 +135,10 @@ func TestResolveTelegramPhoneNumberRejectsPlaceholderAndStaleRuntime(t *testing.
|
||||
}
|
||||
|
||||
func TestTelegramCarrierPresentationSeparatesHomeAndServingNetworks(t *testing.T) {
|
||||
if got := telegramHomeCarrier("234336570710174"); !strings.Contains(got, "🇬🇧") || !strings.Contains(got, "23433") {
|
||||
if got := telegramHomeCarrier("234330000000001"); !strings.Contains(got, "🇬🇧") || !strings.Contains(got, "23433") {
|
||||
t.Fatalf("home carrier = %q", got)
|
||||
}
|
||||
if got := telegramHomeCarrier("454006395879502", "Saily"); !strings.Contains(got, "1O1O / csl / Club Sim") || !strings.Contains(got, "45400") || !strings.Contains(got, "🇭🇰") || strings.Contains(got, "Saily") {
|
||||
if got := telegramHomeCarrier("454000000000001", "Saily"); !strings.Contains(got, "1O1O / csl / Club Sim") || !strings.Contains(got, "45400") || !strings.Contains(got, "🇭🇰") || strings.Contains(got, "Saily") {
|
||||
t.Fatalf("profile brand overrode home carrier = %q", got)
|
||||
}
|
||||
if got := telegramHomeCarrier("999991234567890", "Unknown Brand"); got != "Unknown Brand" {
|
||||
|
||||
@@ -128,7 +128,7 @@ func TestMigration12ConvertsOnlyKnownActiveDeviceBindingToICCID(t *testing.T) {
|
||||
INSERT INTO device_proxy_bindings (device_id, upstream_proxy_id, created_at, updated_at) VALUES
|
||||
('known', 'route', 100, 100), ('unknown', 'route', 100, 100);
|
||||
INSERT INTO vowifi_runtime (device_id, iccid, updated_at)
|
||||
VALUES ('known', '89441000400128014257', 100);
|
||||
VALUES ('known', '8944100000000000001', 100);
|
||||
PRAGMA user_version = 11;
|
||||
`); err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -138,7 +138,7 @@ func TestMigration12ConvertsOnlyKnownActiveDeviceBindingToICCID(t *testing.T) {
|
||||
}
|
||||
|
||||
database := openTestStore(t, path)
|
||||
binding, err := database.DeviceProxyBinding(ctx, "89441000400128014257")
|
||||
binding, err := database.DeviceProxyBinding(ctx, "8944100000000000001")
|
||||
if err != nil || binding.DeviceID != "known" || binding.UpstreamProxyID != "route" {
|
||||
t.Fatalf("migrated binding = %+v, %v", binding, err)
|
||||
}
|
||||
@@ -789,11 +789,11 @@ func TestProxyCredentialsAndCountryRules(t *testing.T) {
|
||||
t.Fatalf("CountryRule() = %+v, %v", rule, err)
|
||||
}
|
||||
if err := database.UpsertDeviceProxyBinding(ctx, DeviceProxyBinding{
|
||||
DeviceID: "ec20-1", ICCID: "89441000400128014257", ProfileName: "Vodafone", UpstreamProxyID: "up-1",
|
||||
DeviceID: "ec20-1", ICCID: "8944100000000000001", ProfileName: "Vodafone", UpstreamProxyID: "up-1",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
binding, err := database.DeviceProxyBinding(ctx, "89441000400128014257")
|
||||
binding, err := database.DeviceProxyBinding(ctx, "8944100000000000001")
|
||||
if err != nil || binding.UpstreamProxyID != "up-1" || binding.DeviceID != "ec20-1" || binding.ProfileName != "Vodafone" {
|
||||
t.Fatalf("DeviceProxyBinding() = %+v, %v", binding, err)
|
||||
}
|
||||
@@ -803,7 +803,7 @@ func TestProxyCredentialsAndCountryRules(t *testing.T) {
|
||||
if _, err := database.CountryRule(ctx, "CN"); !errors.Is(err, ErrNotFound) {
|
||||
t.Fatalf("country rule should cascade with upstream deletion, got %v", err)
|
||||
}
|
||||
if _, err := database.DeviceProxyBinding(ctx, "89441000400128014257"); !errors.Is(err, ErrNotFound) {
|
||||
if _, err := database.DeviceProxyBinding(ctx, "8944100000000000001"); !errors.Is(err, ErrNotFound) {
|
||||
t.Fatalf("device binding should cascade with upstream deletion, got %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ func matchCarrierProfile(match carrierProfileMatch, identity SIMIdentity) (int,
|
||||
score += 20
|
||||
sources = append(sources, "spn")
|
||||
hasSelectorMatch = true
|
||||
} else if !hasHomePLMNMatch || spn != "" {
|
||||
} else {
|
||||
return 0, "", false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,3 +117,19 @@ func TestGlobalRoamingProviderResolution(t *testing.T) {
|
||||
t.Fatalf("Jersey Telecom profile = %#v", jersey)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCTExcelMVNOResolution(t *testing.T) {
|
||||
ctexcel := ResolveCarrierProfile(SIMIdentity{
|
||||
IMSI: "234330000000001",
|
||||
ICCID: "8944300000000000001",
|
||||
SPN: "CTExcel",
|
||||
HomeMCC: "234",
|
||||
HomeMNC: "33",
|
||||
})
|
||||
if ctexcel.ID != "ipcc-ctexcel-23433" {
|
||||
t.Fatalf("CTExcel profile ID = %q, want ipcc-ctexcel-23433", ctexcel.ID)
|
||||
}
|
||||
if ctexcel.IMSDialURIScheme != "sip" || !ctexcel.IMSUserEqPhone {
|
||||
t.Fatalf("CTExcel dial URI scheme = %q, userEqPhone = %v", ctexcel.IMSDialURIScheme, ctexcel.IMSUserEqPhone)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6451,6 +6451,39 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "ipcc-ctexcel-23433",
|
||||
"match": {
|
||||
"home_plmns": [
|
||||
"23433",
|
||||
"23430"
|
||||
],
|
||||
"spns": [
|
||||
"CTExcel",
|
||||
"CTExcel UK",
|
||||
"China Telecom",
|
||||
"China Telecom UK"
|
||||
],
|
||||
"iccid_prefixes": [
|
||||
"894430"
|
||||
]
|
||||
},
|
||||
"route": {
|
||||
"mcc": "234",
|
||||
"mnc": "33"
|
||||
},
|
||||
"epdg": {
|
||||
"hostname": "epdg.epc.mnc033.mcc234.pub.3gppnetwork.org"
|
||||
},
|
||||
"ike": {
|
||||
"proposal": "modern"
|
||||
},
|
||||
"ims": {
|
||||
"dial_uri_scheme": "sip",
|
||||
"user_eq_phone": true,
|
||||
"ipsec_encryption": "aes-cbc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "ipcc-ee-23433",
|
||||
"match": {
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestProxyResolverUsesICCIDProfileBinding(t *testing.T) {
|
||||
}
|
||||
if err := database.UpsertDeviceProxyBinding(context.Background(), store.DeviceProxyBinding{
|
||||
DeviceID: "ec20",
|
||||
ICCID: "89441000400128014257",
|
||||
ICCID: "8944100000000000001",
|
||||
ProfileName: "Vodafone UK",
|
||||
UpstreamProxyID: "clash",
|
||||
}); err != nil {
|
||||
@@ -46,7 +46,7 @@ func TestProxyResolverUsesICCIDProfileBinding(t *testing.T) {
|
||||
}
|
||||
route, err := (ProxyResolver{Store: database}).Resolve(
|
||||
context.Background(),
|
||||
vowifi.ProxyRequest{DeviceID: "ec20", ICCID: "89441000400128014257", HomeMCC: "234", HomeMNC: "15"},
|
||||
vowifi.ProxyRequest{DeviceID: "ec20", ICCID: "8944100000000000001", HomeMCC: "234", HomeMNC: "15"},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -67,7 +67,7 @@ func TestProxyResolverDoesNotLeakBindingToAnotherProfileOnSameDevice(t *testing.
|
||||
if err := database.UpsertUpstreamProxy(context.Background(), store.UpstreamProxy{ID: "proxy", Name: "Proxy", Addr: "127.0.0.1:1080", Enabled: true}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := database.UpsertDeviceProxyBinding(context.Background(), store.DeviceProxyBinding{DeviceID: "ec20", ICCID: "89441000400128014257", ProfileName: "A", UpstreamProxyID: "proxy"}); err != nil {
|
||||
if err := database.UpsertDeviceProxyBinding(context.Background(), store.DeviceProxyBinding{DeviceID: "ec20", ICCID: "8944100000000000001", ProfileName: "A", UpstreamProxyID: "proxy"}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
route, err := (ProxyResolver{Store: database}).Resolve(context.Background(), vowifi.ProxyRequest{DeviceID: "ec20", ICCID: "89104100000028106378"})
|
||||
@@ -137,12 +137,12 @@ func TestProxyResolverICCIDBindingWithDisabledProxyFailsClosed(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := database.UpsertDeviceProxyBinding(ctx, store.DeviceProxyBinding{
|
||||
DeviceID: "ec20", ICCID: "89441000400128014257", ProfileName: "Manual", UpstreamProxyID: "disabled",
|
||||
DeviceID: "ec20", ICCID: "8944100000000000001", ProfileName: "Manual", UpstreamProxyID: "disabled",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, err := (ProxyResolver{Store: database}).Resolve(ctx, vowifi.ProxyRequest{
|
||||
DeviceID: "ec20", ICCID: "89441000400128014257", HomeMCC: "234",
|
||||
DeviceID: "ec20", ICCID: "8944100000000000001", HomeMCC: "234",
|
||||
})
|
||||
if err == nil {
|
||||
t.Fatal("disabled explicit ICCID binding unexpectedly fell back to another route")
|
||||
@@ -169,7 +169,7 @@ func TestProxyResolverMaterializesCountryRuleAsICCIDBinding(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
request := vowifi.ProxyRequest{
|
||||
DeviceID: "ec20", ICCID: "89441000400128014257", HomeMCC: "234",
|
||||
DeviceID: "ec20", ICCID: "8944100000000000001", HomeMCC: "234",
|
||||
}
|
||||
resolver := ProxyResolver{Store: database}
|
||||
route, err := resolver.Resolve(ctx, request)
|
||||
@@ -214,7 +214,7 @@ func TestInsertDeviceProxyBindingIfAbsentDoesNotReplaceExplicitBinding(t *testin
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
iccid := "89441000400128014257"
|
||||
iccid := "8944100000000000001"
|
||||
if err := database.UpsertDeviceProxyBinding(ctx, store.DeviceProxyBinding{
|
||||
DeviceID: "ec20", ICCID: iccid, ProfileName: "Manual", UpstreamProxyID: "explicit",
|
||||
}); err != nil {
|
||||
@@ -257,12 +257,12 @@ func TestProxyResolverPrefersICCIDBindingOverCountryRule(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := database.UpsertDeviceProxyBinding(context.Background(), store.DeviceProxyBinding{
|
||||
DeviceID: "ec20", ICCID: "89441000400128014257", ProfileName: "Physical SIM", UpstreamProxyID: "profile",
|
||||
DeviceID: "ec20", ICCID: "8944100000000000001", ProfileName: "Physical SIM", UpstreamProxyID: "profile",
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
route, err := (ProxyResolver{Store: database}).Resolve(context.Background(), vowifi.ProxyRequest{
|
||||
DeviceID: "ec20", ICCID: "89441000400128014257", HomeMCC: "234",
|
||||
DeviceID: "ec20", ICCID: "8944100000000000001", HomeMCC: "234",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -400,10 +400,10 @@ func TestStateProjectorDoesNotAttachOldSessionNumberToNewLiveSIM(t *testing.T) {
|
||||
}
|
||||
if err := projector.Save(context.Background(), vowifi.State{
|
||||
DeviceID: "ec20",
|
||||
ICCID: "89441000400128014257",
|
||||
IMSI: "234159608751160",
|
||||
ICCID: "8944100000000000001",
|
||||
IMSI: "234150000000001",
|
||||
Phase: vowifi.PhaseStopping,
|
||||
PhoneNumber: "+447386083638",
|
||||
PhoneNumber: "+447700900123",
|
||||
PhoneNumberSource: vowifi.PhoneSourcePAssociatedURI,
|
||||
UpdatedAt: time.Now().UTC(),
|
||||
}); err != nil {
|
||||
@@ -413,10 +413,10 @@ func TestStateProjectorDoesNotAttachOldSessionNumberToNewLiveSIM(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if runtime.ICCID != "89441000400128014257" || runtime.IMSI != "234159608751160" {
|
||||
if runtime.ICCID != "8944100000000000001" || runtime.IMSI != "234150000000001" {
|
||||
t.Fatalf("runtime identity = %q/%q", runtime.ICCID, runtime.IMSI)
|
||||
}
|
||||
if runtime.LocalPhone != "+447386083638" {
|
||||
if runtime.LocalPhone != "+447700900123" {
|
||||
t.Fatalf("runtime phone = %q", runtime.LocalPhone)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ const {
|
||||
} = await import(moduleURL);
|
||||
|
||||
test("uses the current physical SIM when the device has no eSIM profiles", () => {
|
||||
const iccid = "89441000400128014257";
|
||||
const iccid = "8944100000000000001";
|
||||
|
||||
assert.deepEqual(buildAutomaticTaskProfileOptions([], iccid, "Current SIM"), [
|
||||
{
|
||||
@@ -30,7 +30,7 @@ test("uses the current physical SIM when the device has no eSIM profiles", () =>
|
||||
});
|
||||
|
||||
test("does not duplicate the current SIM when it is already in the eSIM inventory", () => {
|
||||
const iccid = "89441000400128014257";
|
||||
const iccid = "8944100000000000001";
|
||||
|
||||
assert.deepEqual(
|
||||
buildAutomaticTaskProfileOptions(
|
||||
@@ -49,7 +49,7 @@ test("does not duplicate the current SIM when it is already in the eSIM inventor
|
||||
});
|
||||
|
||||
test("does not replace a saved profile when a failed inventory only exposes the current SIM", () => {
|
||||
const currentICCID = "89441000400128014257";
|
||||
const currentICCID = "8944100000000000001";
|
||||
const savedICCID = "89104100000028106378";
|
||||
const options = buildAutomaticTaskProfileOptions([], currentICCID, "Current SIM");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user